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 › how i can save in an image format
Page Index Toggle Pages: 1
how i can save in an image format? (Read 522 times)
how i can save in an image format?
Jul 29th, 2009, 8:01am
 
save("name.tif"); is non working in this code, any suggestions?
//////////////////////////
import net.nexttext.*;
import net.nexttext.behaviour.*;
import net.nexttext.behaviour.control.*;
import net.nexttext.behaviour.dform.*;
import net.nexttext.behaviour.physics.*;
import net.nexttext.behaviour.standard.*;

Book book;
PFont font;

void setup() {
 size(1200, 1500);
 background(42);
 smooth();
 make(width/2, height/2, 6, 1425, 1360, color(253,10,10), 45,
 color(15,155,255), SQUARE, ROUND);
 make(width/2, height/2, 12, 137, 203, color(3,210,10), 45,
 color(15,0,0, 93), SQUARE, MITER);
 
   book = new Book(this);

 // load and set the font
 font = createFont("GeometricBlack.ttf", 288);
 textFont(font);
 textAlign(CENTER);
 fill(255);
 stroke(96);
 strokeWeight(15);

 // build the text
 book.addText("biri biri", width/2, height/2);

}
void draw() {

 book.stepAndDraw();
}




void make(float x, float y, float s, float rad1, float rad2, color c1,
float init,  color c2, int endCap, int endJoin) {
 float px=0;
 float py=0;
 float angle = init;
 float ang=(360/s)/2.0;
 float ang2=(360/s)/4.0;
 strokeWeight(s*5);
 stroke(c2);
 strokeCap(endCap);
 strokeJoin(endJoin);
 fill(c1);
 beginShape();
 for(int i=0;i<s; i++){
   px=x+cos(radians(angle))*rad1;
   py=y+sin(radians(angle))*rad1;
   vertex(px,py);
   angle+=ang;
   px=x+cos(radians(angle))*rad1; //nice x/cos...
   py=y+sin(radians(angle))*rad1;
   vertex(px,py);
   angle+=ang2;
   px=x+cos(radians(angle))*rad2;
   py=y+sin(radians(angle))*rad2;
   vertex(px,py);

   px = x;
   py = y;
   vertex(px,py);
/*
   float foo = px;
   px = py;
   py = foo;
   vertex(px,py);
*/
   angle+=ang2;
 }
 endShape(CLOSE);
}

//save("biri.tif");
Re: how i can save in an image format?
Reply #1 - Jul 29th, 2009, 9:54am
 
save() must be in draw(), perhaps triggered by a mouse click or a key press (ie. it can also be in keyPressed() or similar) or after a while.
Re: how i can save in an image format?
Reply #2 - Jul 29th, 2009, 11:38am
 
thanks a lot, that really helps!
Page Index Toggle Pages: 1