Thursday, June 11, 2015

Parabola!

In this tutorial I will be changing this code (made by 유창희 on open processing) to python from java. This code prints out a program that draws a parabola using math functions.   

First things first, we are going to change void setup(){} and void draw(){} to def setup (): and def draw (): Than delete all the semi colons and 
indent everything following our setup and draw functions. 
Than we are going to change float angle, y; to angle = 1. We do this because in
python we d not need to declare these as floats, we only need to set a value to angle. 
Than we are going to add global angle right under  def draw (): We do this because 
in python when we add angle into the math function it is only searching for angle in the 
def draw (): function, but by adding global angle it knows to look outside the function. 
So far your code should look like this:     



Than we are going to change the color codes for background and fill to RGB codes. background will be background(255,248,237) and fill will be fill(255,149,149)After that we change angle++ to angle+=1 Your code should look like this:  

When you run it you should get a program that draws a parabola and finishes like this:





1 comment:

  1. CASINO CASINO in HENDERSON - KAYAKA
    The 충주 출장안마 Casino 정읍 출장마사지 at HENDERSON offers one of 과천 출장샵 the best casino gaming options available. 청주 출장안마 The 포천 출장안마 excitement starts at the dining table at The Dining Room.

    ReplyDelete