SFML community forums

General => SFML projects => Topic started by: 4B on April 14, 2014, 09:47:57 pm

Title: Spirograph
Post by: 4B on April 14, 2014, 09:47:57 pm
In the last two days I programmed a little spirograph made in C++, SFML.

For now I can't show you my code, because it's looking awful, but I made a little video of the spirograph in action. Please forgive me for the bad quality, it's my very first video and I just made it in 5 minutes.

https://www.youtube.com/watch?v=kwdgm9EVMtU


If somebody wants to see the code just tell me and I'll put it on github after refactoring.
Title: Re: Spirograph
Post by: Nexus on April 15, 2014, 01:04:18 pm
Cool idea! I like how the SFML project section has more and more variety :)

You probably rotate every "stick" with a certain angular velocity relative to its parent? Do you draw to a render texture or how are the pixels stored?
Title: Re: Spirograph
Post by: Geheim on April 15, 2014, 02:15:31 pm
Very well done, it looks great!
It's indeed fascinating how SFML is used in so many ways ;)

Are you going to work more on this project? Maybe adding some kind of user interface to manipulate it in realtime?

Anyways thanks for sharing and keep it up!
Title: Re: Spirograph
Post by: 4B on April 15, 2014, 04:02:10 pm
I'm glad you like it.

@Nexus Almost. A random-number-generator defines of how many "sticks"(havn't got a better word, too) the whole arm consists. Then the program defines a specific length and anglePerSec for every stick with a random-generator, too. So the sticks don't depend on each other. The calculations are a bit harder. For every stick you need to calculate the rotation. The next arm will be connected to the first and also rotates with the specific anglePerSec-speed.

Every frame I'm drawing a line between the previous tip of the arm and the current tip of the arm. Then the program draws the line to a RenderTexture which gets displayed.


@Geheim I'm going to add a UI and I'm planning to implement screenshots so the program can fill a gallery with the screens automatically.