DEV Community

conjurer
conjurer

Posted on • Updated on

Geometric art | C++

Some geometric art today!
Just some clicks and voila! A great pattern!

Libraries

  • SDL2
  • iostream
  • vector

int main()

User can choose between 2 modes, hence type.
sdl init

main while(1)

Detect if user wants to quit and exit;

Detect a left click on the screen to add edges in the vector, and hence on the screen. Event handler sets the coordinates (x, y).

Mouse movements are tracked on screen for location pointers.

user events
On keypress:

  • c : clear
  • m : connect 2 most recent clicks (type 1)
  • l : connect every point to every other point in vector (type 0)
  • u : undo the last line(s)

Types of connections

Set bg, drawing colors.
Decide pattern according to type.
Update the screen on render.
Wait 1s before returning.
art render

Output

output
The Builder rocks it!

Top comments (0)