Skip to main content

Command Palette

Search for a command to run...

Geometric art | C++

Published
•1 min read•View as Markdown

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.

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.

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.

Output-

output

The Builder rocks it!

Fun with C++

Part 1 of 2

Insights | Codes | Interesting facts | More...

Up next

Rotating cube | C++

Magic of a cube!