Giter Site home page Giter Site logo

grz0zrg / twigs Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 1.0 7.33 MB

Twigs – 512 bytes procedural graphics in C code (IFS Fractal, Linux, fbdev)

Home Page: https://www.pouet.net/prod.php?which=86990

License: MIT License

Makefile 28.91% Shell 5.89% C 62.32% Assembly 2.88%
demoscene ifs fractal fbdev framebuffer linux bytes tinycode 512-bytes procedural-art

twigs's Introduction

Twigs by The Orz

512 bytes Linux procedural graphics for Inércia Demoparty 2020

this doesn't use any libraries (not even the standard C library) and use two syscalls (open / mmap) to output to the Linux framebuffer device (fbdev), the magic lie in the code organization, symmetry, algorithms used (IFS Fractal / chaos game), GCC optimization flags and the compression stub / self executing shell script (without: 551 bytes)

goal was to port one of my IFS procedural gfx sketched in Processing as a C only 512 bytes linux intro

side goal was to serve as a proof of concept that many of my 2D IFS sketches can be reduced to a <= 512 bytes program. I believe it can be done in less than 256 bytes also with agressive optimizations like ELF headers reduction or on different platform which doesn't have OS clutters like DOS with Mode 13h

prototyped first with my software graphics library

the party version in party directory was the original release and use floats but does not use saturation arithmetic so the image accumulate noise

the improved version in party_improved directory is compiled with gcc-12 (with -Oz flag instead of -Os) and is tailored for 1920x1080, 32 bits and use saturation arithmetic done with SSE2 instructions and fixed point arithmetic instead of floats (quick conversion with a stripped down and modified fixedptc ), the RNG can also use the hardware RNG (rdrand) although there is not much gain in quality or size, this version also doesn't draw outside screen boundary (the party version just limited the index so there was a single white pixel in the lower right corner), this version is also smaller overall with 491 bytes for the final binary

the 100% ELF version in src (and root binary) is like the improved version except it use a custom 32 bits ELF header with overlap and the fbdev setup is done in assembly, it does not rely anymore on a compression stub / self executing shell script and the final binary is 426 bytes with rdrand instruction.

Note : party version 32 bits binary (-m32) is slightly bigger than the 64 bits binary which is 504 bytes (1920x1080x32)

requirements:

  • 32 bits /dev/fb0 (framebuffer) with supported resolution
  • high quality: the framebuffer should be set to display resolution

how to run:

  • switch to console with Ctrl+Alt+F2 (Ctrl+Alt+F1 to switch back to X)
  • check /dev/fb0 is writable to you (or launch with sudo to bypass this step)
  • check /dev/fb0 current resolution with fbset tool
  • run the appropriate binary

permission issue: add current user to either 'tty' or 'video' group or use 'sudo'

change graphical terminal resolution:

  • check supported resolution with "vbeinfo" in GRUB command prompt
  • "GRUB_GFXMODE=WxH" in /etc/default/grub (where W/H is a value)
  • sudo update-grub

the single line RNG come from here

code by grz, party code built with GCC 7.5.0

greetings to all sizecoders

twigs's People

Contributors

grz0zrg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

moneytech

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.