We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › setting an origin of an svg image
Page Index Toggle Pages: 1
setting an origin of an svg image (Read 353 times)
setting an origin of an svg image
Feb 7th, 2009, 11:55pm
 
hi,
i'm trying to make a tree grow from the bottom of a 500x500 screen. the tree is supposed to grow larger as the hours of the day pass, and a leaf will appear for every minute in the hour. when it hits midnight, the tree should shrink back down to the initial small state.

how do i get the base of the tree to be anchored to the bottom of the screen and make it grow upwards? is there some kind of shapeMode function besides CENTER? right now, my svg image is approx 331 x 374px. i would like to have it scaled down to .25 its size to start out with, then grow to the 331 x 374 size.

here's part of my code below. any help is appreciated. thanks!


PShape tree;

float s;
float m;
float h;

void setup(){
 size(500, 500);
 smooth();
 tree = loadShape("tree.svg");
 noStroke();
 noLoop();
}

void draw(){
 background(0);

 s = map(second(), 0, 60, 0, 500);
 m = map(minute() + norm(second(), 0, 60), 0, 60, 0, 500);
 h = map(hour() + norm(hour(), 0, 60), 0, 24,0, 500);

 hrs();
}

//hours
void hrs(){
 pushMatrix();
 translate(width/2, height/2);
 for (int i = 0; i < h; i++){
   scale(0.25+i);
   shape(tree); //shape(sh, x, y, width, height)
   shapeMode(CENTER);
   println("grow tree grow!");
 }
 popMatrix();
}
Re: setting an origin of an svg image
Reply #1 - Feb 12th, 2009, 7:32am
 
im not sure if this is the way i did it some time ago, but i think so... just edit the svg file in illustrator and move the shape and the point you want to be the center of your file to (0,0) should be left upper corner of you document, and save it... i guess that worked for me. not sure though
Page Index Toggle Pages: 1