EEVblog Electronics Community Forum
Products => Computers => Programming => Topic started by: hamster_nz on September 21, 2020, 11:03:58 pm
-
I know it's pretty trivial, but I've been making posters of programs for on my wall of my workspace.
If anybody has some good ideas for interesting graphics that can be done in < 100 lines, with no libraries outside of the standard C ones I'll give them a go.
-
Can you post the code for the ones you have?
It's going to be tricky to do really interesting stuff without a basic vector library or a line drawing function. Adding those would eat pretty much all your lines.
-
The requirements seem quite odd. Why less than 100 lines? That’s an arbitrary limit, akin to to those in assigments in school. Why avoiding dependencies? In particular if that will considerably worsen the output and make the whole thing unneccesserily time wasting and buggy. o ᷼O
You may create a 3D figure by rotating a flat curve around the vertical axis and skewing the coördinate system so that whatever is closer is placed lower. The shape may be a wire mesh consisting of quadrlaterals, so there is no need to apply real 3D rendering algorithms. If you start rotation from the back and draw lines from the bottom, ordering of the points/segments is naturally fitting what you need. Adding colors makes it more intereting.
You may also create random aptterns based on L-systems. Preferably the L-system being used to define the crude geometry of the item and the actual generation just using that as the partial input.
-
Can you post the code for the ones you have?
It's going to be tricky to do really interesting stuff without a basic vector library or a line drawing function. Adding those would eat pretty much all your lines.
See the three files attached. The generated PPM file format is well-supported under Linux, but Windows users might need to use GIMP or some other image viewing utility to open them.
-
The requirements seem quite odd. Why less than 100 lines? That’s an arbitrary limit, akin to to those in assigments in school. Why avoiding dependencies? In particular if that will considerably worsen the output and make the whole thing unneccesserily time wasting and buggy. o ᷼O
You may create a 3D figure by rotating a flat curve around the vertical axis and skewing the coördinate system so that whatever is closer is placed lower. The shape may be a wire mesh consisting of quadrlaterals, so there is no need to apply real 3D rendering algorithms. If you start rotation from the back and draw lines from the bottom, ordering of the points/segments is naturally fitting what you need. Adding colors makes it more intereting.
You may also create random aptterns based on L-systems. Preferably the L-system being used to define the crude geometry of the item and the actual generation just using that as the partial input.
Printing on A2 at 300 DPI with a border gives vertical pixels 4660 for the code, and the font I'm using is 23x45 pixels. That gives 4660 / 45 = 103 lines. (at about 6.6 lines per inch).
I also want it so anybody who knows a bit of programming can walk up, have a look and have a look at what is going on, then maybe go and try it in the language of their choosing. The idea is that it is completely self-contained.
Wasting time generating a one-off image for poster isn't a big issue. Even if it took overnight I wouldn't be too bothered. If it is a 'special simple case' of a more generic problem, if it might attract interest I'm keen.
Maybe raytraced spheres over a chess board is next... ;)
-
WIP, but I am sure a lot of us know where this one will be heading....
-
Always like the Lorenz attractor plots. Been a long time (25? years) since wrote some 68K assembly for them. Might be tough to get it within 100 lines though.
-
Yep, it got there...
-
blueskull
Thanks, my brain removed the code from the image. I haven’t noticed them until you mentioned it and I rechecked the pictures.
hamster_nz
Then the rotated curves should fit into 100 lines and require no dependencies. The L-Systems idea may be harder to execute. While the basic generation itself should not take even half of that space, growing anything on top of the generated data may easily explode into thousands of lines.
-
Cool idea.
I'm guessing you don't want IOCCC-style 100 lines of code :-)
-
Cool idea.
I'm guessing you don't want IOCCC-style 100 lines of code :-)
If the picture is awesome enough... sure!