FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Responsive Form, Games
(Moderator: REAS)
   simple tree example
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: simple tree example  (Read 458 times)
svela

WWW Email
simple tree example
« on: Dec 17th, 2002, 4:47pm »

little tree example:
http://archive.hiutale.net/tree/
 
this is one of my first proce55ing sketches..
 
svela

WWW Email
Re: simple tree example
« Reply #1 on: Dec 17th, 2002, 4:48pm »

source:
 
// simple tree example
// by svela
 
int pl = 150;
float rot = 0.0;
 
void setup() {
  size(300,300);
  background(#333333);
}
 
void loop() {
float size = mouseY;
if(mousePressed) {
rot = rot; }
else {
rot = rot+0.01; }
if(keyPressed) {
if(key == '2') {
translate(150,50,-size);
rotateY(rot); }
if(key == '1') {
translate(0,150,-size);
rotateX(rot); }
if(key == '3') {
translate(150,150,-size);
rotateZ(rot); } }
 
// tree
stroke(145, 125, 53);
line(pl,pl,pl,pl-10);
line(pl,pl-10,pl-10,pl-20);
line(pl,pl-10,pl+10,pl-20);
line(pl,pl,pl,pl-20);
line(pl,pl-20,pl-5,pl-25);
line(pl,pl-20,pl+5,pl-25);
line(pl,pl-20,pl,pl-30);
 
// leafs
noStroke();
fill(33, 230, 23);
ellipse(pl-2,pl-32,5,5);
ellipse(pl+5,pl-28,5,5);
ellipse(pl-9,pl-28,5,5);
ellipse(pl-13,pl-21,5,5);
ellipse(pl+9,pl-21,5,5);
}
 
REAS


WWW
Re: simple tree example
« Reply #2 on: Dec 17th, 2002, 6:47pm »

thank you for posting this svela. it's a wonderful format for examples, but i found it difficult to get the tree to move the way i wanted it to.
 
+ casey
 
svela

WWW Email
Re: simple tree example
« Reply #3 on: Dec 18th, 2002, 6:53pm »

new version:
http://archive.hiutale.net/tree/
 
source:
 
// simple tree example 0.1
// by svela
 
int pl = 150;
float rot = 0.0;
 
void setup() {
  size(300,300);
  background(#333333);
}
 
void loop() {
float size = mouseY;
float lor = mouseX/2;
if(mousePressed) {
rot = rot; }
else {
rot = rot+0.01; }
if(keyPressed) {
if(key == '2') {
translate(lor,50,-size);
rotateY(rot); }
if(key == '1') {
translate(lor,150,-size);
rotateX(rot); }
if(key == '3') {
translate(lor,150,-size);
rotateZ(rot); } }
 
// tree
stroke(145, 125, 53);
line(pl,pl,pl,pl-10);
line(pl,pl-10,pl-10,pl-20);
line(pl,pl-10,pl+10,pl-20);
line(pl,pl,pl,pl-20);
line(pl,pl-20,pl-5,pl-25);
line(pl,pl-20,pl+5,pl-25);
line(pl,pl-20,pl,pl-30);
 
// leafs
noStroke();
fill(33, 230, 23);
ellipse(pl-2,pl-32,5,5);
ellipse(pl+5,pl-28,5,5);
ellipse(pl-9,pl-28,5,5);
ellipse(pl-13,pl-21,5,5);
ellipse(pl+9,pl-21,5,5);
}
 
gaza


Re: simple tree example
« Reply #4 on: Dec 18th, 2002, 11:04pm »

not moving or zooming for me (?) ... : (
 
svela

WWW Email
Re: simple tree example
« Reply #5 on: Dec 19th, 2002, 3:43pm »

version0.3 is out
http://archive.hiutale.net/tree/
 
 
// simple tree example 0.3
// by svela
 
int pl = 0;
float rot = 0.0;
 
void setup() {
  size(300,300);
  background(#333333);
}
 
void loop() {
float size = mouseY;
float lor = mouseX/2;
if(mousePressed) {
rot = rot; }
else {
rot = rot+0.01; }
if(keyPressed) {
if(key == '2') {
translate(lor*2,height/2,-size);
rotateY(rot); }
if(key == '1') {
translate(lor*2,height/2,-size);
rotateX(rot); }
if(key == '3') {
translate(lor*2,height/2,-size);
rotateZ(rot); } }
else {
translate(lor*2,height/2,-size);
rot = rot-0.01; }
 
// tree
stroke(145, 125, 53);
line(pl,pl,pl,pl-10);
line(pl,pl-10,pl-10,pl-20);
line(pl,pl-10,pl+10,pl-20);
line(pl,pl,pl,pl-20);
line(pl,pl-20,pl-5,pl-25);
line(pl,pl-20,pl+5,pl-25);
line(pl,pl-20,pl,pl-30);
 
// leafs
noStroke();
fill(33, 230, 23);
ellipse(pl-2,pl-32,5,5);
ellipse(pl+5,pl-28,5,5);
ellipse(pl-9,pl-28,5,5);
ellipse(pl-13,pl-21,5,5);
ellipse(pl+9,pl-21,5,5);
}
 
Pages: 1 

« Previous topic | Next topic »