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 & HelpPrograms › problems with scaling
Page Index Toggle Pages: 1
problems with scaling (Read 979 times)
problems with scaling
Nov 7th, 2009, 10:59am
 
Hey, I'm just started to study Java and Processing and have been playing around with loops, basic shapes, coordinates, maths etc, and have been to produce a simple drawing consisting of these principles. However i've made the screen size 300 by 300, after saving this, then trying to scale either in photoshop or in processing I lose some serious image quality. I''ve had a look at the scale(), resize() references and some tutorial pages but nothing seems to work for me :/  am I missing something simple?

Heres my code, its a recreation of a cross section of a pillar..

size(300, 300);                  //Creates a logo size of 300 px by 300 px
background(255);                   //Sets background colour to white
int o = 150;                       //Declares variable int o and assigns 150 to it, (origin)
smooth();                         //Smooths all lines to drawn from this point
ellipse(o, o, 220, 220);       //Creates a circle with diameter 220 px and origin at 150, 150
fill(100);                           //Sets fill to grey from this point on
ellipse(o, o, 180,180);        //Creates a circle with diameter 180 px and origin at 150, 150          
fill(255);                         //Sets fill to white from this point on
noStroke();                        //Removes Outline
for (float m = 0; m <=60; m = m + 2.5)      //Small circle positions
{                                
 double hAngle = 2.0 * Math.PI * m/60;
 double hX = o + 93 * Math.sin(hAngle);
 double hY = o - 93 * Math.cos(hAngle);
 float X = (float)hX;
 float Y = (float)hY;
 ellipse(X, Y, 22, 22);
}
noFill();                         //Removes fill
stroke(0);                        //Sets Outline to black

ellipse(o, o, 200, 200);      //Creates a circle with diameter 200 px and origin at 150, 150
ellipse(o, o, 180,180);       //Creates a circle with diameter 180 px and origin at 150, 150
ellipse(o, o, 270, 270);       //Creates a circle with diameter 270 px and origin at 150, 150
rectMode(CENTER);                 //Sets origin to center of square
rect(o, o, 270, 270);         //Creates a square with length 270 px and origin at 150, 150
rect(o, o, 275, 275);         //Creates a square with length 275 px and origin at 150, 150
for (float arC = 4.25; arC <=50; arC = arC + 15) //Creates 4 arcs for each corner
{
 double aAngle = 2.0 * Math.PI * arC/60;
 double aAngleStop = 2.0 * Math.PI * (arC+6.5)/60;
 float Start = (float)aAngle;
 float Stop = (float)aAngleStop;
 arc(o, o, 285, 285, Start, Stop );
}
line(211.35, 21.38, 278.62, 21.38);      //produces lines to connect the arcs.
line(278.62, 21.38, 278.62, 88.65);
line(278.62, 211.35, 278.62, 278.62);
line(278.62, 278.62, 211.35, 278.62);
line(88.65, 278.62, 21.38, 278.62);
line(21.38, 278.62, 21.38, 211.35);
line(21.38, 88.65, 21.38, 21.38);
line(21.38, 21.38, 88.65, 21.38);

float h2 = sq(135) + sq(135);          //To work out the position for the four corner circles.
float h = sqrt(h2);
h = h - 142.5;
println(h);
for (float m = 7.5; m <=60; m = m + 15)      //4 corner circles
{                                
 double hAngle = 2.0 * Math.PI * m/60;
 double hX = o + ((270 + h)/2) * Math.sin(hAngle);
 double hY = o - ((270 + h)/2) * Math.cos(hAngle);
 float X = (float)hX;
 float Y = (float)hY;
 ellipse(X, Y, 24, 24);
 ellipse(X, Y, 5, 5);
}
for (float m = 0; m < 60; m = m + 0.5)      //Small line positions using rectangles
{                                
 double hAngle = 2.0 * Math.PI * m/60;
 double hX = o + 95 * Math.sin(hAngle);
 double hY = o - 95 * Math.cos(hAngle);
 float X = (float)hX;
 float Y = (float)hY;
 noFill();
 pushMatrix();
 translate(X, Y);
 rotate(2.0 * PI * m/60);
 rect(0, 0, 0, 9);
 popMatrix();
}
for (float m = 0; m <=60; m = m + 2.5)      //Small decor positions
{                                
 double hAngle = 2.0 * Math.PI * m/60;
 double hX = o + 95 * Math.sin(hAngle);
 double hY = o - 95 * Math.cos(hAngle);
 float X = (float)hX;
 float Y = (float)hY;
 fill(255);
 strokeWeight(1);
 pushMatrix();
 translate(X, Y);
 rotate(2.0 * PI * m/60);
 ellipse(0, 0, 15, 10);
 popMatrix();
}
save("experimenting.gif");

Sorry its a bit messy!

Thanks,

Matt
Re: problems with scaling
Reply #1 - Nov 7th, 2009, 11:52am
 
looks like you can use the PDF export to get vector data not an image.
You can then resize it to any size you want :

http://processing.org/reference/libraries/pdf/index.html
Re: problems with scaling
Reply #2 - Nov 7th, 2009, 11:55am
 
ah seems like a simple solution! thanks i'll check it out
Re: problems with scaling
Reply #3 - Nov 7th, 2009, 12:01pm
 
it works a treat! thanks alot!
Page Index Toggle Pages: 1