galbostein
YaBB Newbies
Offline
Posts: 2
use class with "for"
Jan 8th , 2010, 1:46pm
hello first i'm sorry for my bad english i'm started with processing. i was in a workshop with simon Geilfus (Kinesis) in Brussel. now i want to work. I try to use a class in a "for" my class is ok, but i don't know how to use it with "for". this is my code: //------------------------------------------------- class Tri { float x; float y; float h; float w; float c1; float c2; float c3; float c4; float x2; float y2; Tri(float _x, float _y, float _h, float _w, float _c1, float _c2, float _c3, float _c4){ x = _x; y = _y; h = _h; w = _w; c1 = _c1; c2 = _c2; c3 = _c3; c4 = _c4; } void dessinerTri(){ float centerX = mouseX; float centerY = mouseY; if(mouseX < x) centerX = x; if(mouseX > x+w) centerX = x+w; if(mouseY < y) centerY = y; if(mouseY > y+h) centerY = y+h; fill(c1, random(mouseY), random(mouseX)); triangle(centerX, centerY, x, y, x+w, y); fill(c2, random(mouseY), random(mouseX)); triangle(centerX, centerY, x+w, y, x+w, y+h); fill(c3, random(mouseY), random(mouseX)); triangle( x+w, y+h, centerX, centerY, x, y+h); fill(c4, random(mouseY), random(mouseX)); triangle( x, y+h, centerX, centerY, x, y); } } //-------------------------------------------------------- void setup(){ size(500,500); } void draw(){ background(130); Tri tri01; tri01 = new Tri(10, 10, 30, 30, 10, 10, 10, 10); tri01.dessinerTri(); //THIS IS THE "FOR" THAT I WANT USE /* for(int i=0;i<=500;i+=50){ for(int j=0; j<= 500; j+=50){ dessinerTri(i, j); } } */ } i'm enjoy to integrate the processing community thanks