Gimmerz
YaBB Newbies
Offline
Posts: 4
Variables problem
May 27th , 2010, 2:11pm
Hi, im currently working though the Processing book and have just tried to use variables so that I can change a shape in proportion to changing the canvas size. I can get this technique to work for the ellipse (as in the example) and also for a rectangle. However I just cant get my triangle to work in the same way. I write out my code and the 6 parameters for the triangle, I run this to check that my triangle is positioned where I want it and that its the correct size. I then go through changing the parameters to width*,height* (code numbers shown below) etc. however when I run the script I dont get a good result, the triangle has moved or changed shape. I think my main problem is that I can understand how to keep the same co ordinates for the shape whilst using the width* and height* commands. If I kept the numbers that I initially used to create the triangle (when I was checking to see that it was how I wanted it) then the * would just scale it up too big. I start with this: size(400,400); stroke(255); ellipse(width*0.5,height*0.5,width*0.5,height*0.5); triangle(200,20,100,100,300,100); then because im happy that the triangle appears as i want it I try changing the parameters using width*, height* etc however I cant get the shape to stay in the same position and also, it changes shape. I dont know how to work out the numbers that I need to use to keep it the same and so that it scales when I change the size() values. does this make sense? is there an easier way to scale everything up within the scene? hope you can help out, thanks G