Page 1 of 1

### Python Curve Generator

Posted: Thu Jan 03, 2013 8:11 pm
I have released this code under GPLV3 at: https://github.com/Digital-Larry/curves-python

Basic idea behind the GPL license is that you can download it and play with it (including making code changes) for your own amusement as much as you like, but if you distribute it to anyone else, please add your changes back to the repository.

You will need to install the Pygame library. I used the Raspbian "Pisces" image and did

Code: Select all

apt-get install python-pygame
to get pygame installed.

Make a folder somewhere on your system and copy the files from the github repository into it.

Then you just execute

Code: Select all

python main.py
And it should work.

At present, this is laid out for 800x600 screen size which you could probably easily increase to get better resolution out of HDMI.

The "curve" class is used to create 2 different curves every 30 seconds or so. Each curve uses the "randomize" function to set a group of parameters used to dictate what that curve will look like. These parameters not only choose which function will be used to draw the functions, but parameters within these functions as well. There is lots of opportunity to experiment with new functions. Each curve has the following:

x_pos function - how the x-position changes with time
y_pos function - how the y-position changes with time
color function - how the color changes with time
radius function - how the radius of the drawn circle changes with time

This started with a very basic sin(time) function for x and cos(time) function for y. That should draw a circle if your aspect ratio is 1 to 1. I'd think this would be interesting for anyone studying trigonometric functions.

### Re: Python Curve Generator

Posted: Thu Jan 03, 2013 9:33 pm
Pressing the space bar will clear the screen and start a new pair of curves.
Pressing the "s" key will create a jpg snapshot of the current screen.

Here's a few of many thousands of possibilities:

### Re: Python Curve Generator

Posted: Thu Jan 03, 2013 9:43 pm
Looks nice, will have a play at some point!

### Re: Python Curve Generator

Posted: Sun Jan 06, 2013 5:02 pm
If you have git installed, here's an easy way to check out the code:

Code: Select all

git clone https://github.com/Digital-Larry/curves-python.git
This will create a curves-python folder and copy all the files into it.

### Re: Python Curve Generator

Posted: Mon Jan 07, 2013 12:04 am
finally, the cool-looking graphics demos are starting to appear.