Wednesday, June 10, 2015

BASICS & CIRCLE


 I will be following along part with this tutorial but I will show you how to convert it from Java (the mode used in to the tutorial) to Python.  
So first things first, we’re going to open up Processing and make sure its in Python mode:


After we are sure its in Python we are going to add our set up and draw function. In the linked tutorial the maker puts void setup () and void draw () followed by curly brackets where he store all the code he wants to follow these commands. Since we are doing it in python mode these must look a little different. Our setup and draw functions will instead be def setup (): and def draw (): like this:


After our def setup ():  we will add all the things we want to happen once and once only, for example our desired screen size, and background color. After our def draw (): function we will put all the things we want to show up on our screen, for example shapes and their colors. I’m setting the screen size to 500 by 400 pixels and the background to light blue. In the tutorial he does his commands followed by a colon, we do not need to do this in Python. 
You will set the screen size by putting size(500,400) indented under your def setup(): function. You will set the background color (light blue, in this case) by putting background(194, 244, 255) indented under your def setup(): function. The numbers in the brackets next to background are RGB color code numbers for light blue, if you wish to make your background color different you can find more RGB codes here 
This is what your code should look like so far:

Now we are going to begin to add our shapes and playing with their colors. The shapes I will be doing today are circles (called ellipse in the code). Again, in the video tutorial linked he follows all lines of code with a colon, we do not need to do this. 
To make a circle we must put ellipse(250,200,150,150) indented under our def draw(): function. The number in brackets next to ellipse are the placement of the circle and the size, the placement of mine is 250 x and 200 y and the size is 150 by 150 pixels. To change the color of the stoke and fill of our ellipse we must add the stroke() and fill() command before our ellipse. I am going to make my stoke and fill both a dark purple. To do this we add the RGB color code to our brackets next to our stroke() and fill()command. 
Your code should now look like this:

And when you run your program it should look like this:


You have now successfully made a Python program that prints out a circle. Feel free to play around with the colors, sizes, and shapes position.   


1 comment:

  1. Both areas function smoking and non-smoking areas so you'll be able to|you probably can} play your method. Guests must immediately report any disputes relating 퍼스트카지노 to sport play. These are a number of the} top video games our guests are at present loving. Lush Eastern influences create a relaxing, zen-filled hideaway where you'll be able to|you probably can} take pleasure in gaming within the quiet calm.

    ReplyDelete