HACKER Q&A
📣 fsloth

How do you draw lines (code golf)


Modern computing is super hostile for doing simple things with minimum effort. This separates us from the pleasure and immediacy of trying out simple things quickly and in robust manner.

All serious languages have trivial printf, console.print or similar quality-of-life function to output strings to a console in their basic library.

Sadly, not so much for rendering even the most simple of graphics primitives.

What’s your most simple way of drawing n lines in 2d?

Slightly more formally: Lines are represented by a startpoint and endpoint in the 2D cartesian plane. Given a set of lines, draw them on the output surface so that all of the enpoints of the lines are within the bounds of the surface.

Output surface can be anything reasonable - bmp, png, html page…

(I have some professional background in graphics programming so I know many longwided ways of achieving this :D)