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.
Page Index Toggle Pages: 1
pixel ratio (Read 207 times)
pixel ratio
Nov 23rd, 2008, 12:49pm
 
hi,

I need to know how to do this .

Let say you have a 400x400 pixel applet . I want to double the pixel size so the window is 800x800 per exemple, like a zoom in . how would I do that ?


Thanks a lot Smiley
Re: pixel ratio
Reply #1 - Nov 23rd, 2008, 1:47pm
 
Not quite sure what you mean in your question - doubling the pixel size is not the same as doubling the number of pixels (and, in your example you are actually increasing the number of pixels by 4, not 2).

Depending on what you need to do:

1. Expressing all your screen coordinates as a fraction of the width and height variables keeps your sketch scaled to whatever the current sketch size is. This is probably the simplest and most flexible approach to scaling. If you double the area of your applet, so the sketch will double in area.

2. If you really wish to zoom in (note though that zooming usually involves losing the edges of a sketch as they are scaled outside of the viewable area), then the scale scale() method can be used inside draw(). You may also wish to look at http://www.soi.city.ac.uk/~jwo/processing/zoomPan for a zoom class that can be added to any sketch.

Apologies if I have misunderstood your question.

Re: pixel ratio
Reply #2 - Nov 23rd, 2008, 1:55pm
 
Mhmm .. Yea my sketch happens in a defenite space so I can't zoom in finally. But what I want to do is to have a very low fi feel with pixels being 3 or 4 times the normal pixel size . so I can make the sketch in small window and blow it up so the pixels looks bigger and more like tiles than pixels .

Does it makes sense ?
Re: pixel ratio
Reply #3 - Nov 23rd, 2008, 2:41pm
 
Example:
Code:
PGraphics pg;

void setup()
{
size(400, 400);
// smooth();

pg = createGraphics(100, 100, JAVA2D);
// pg.smooth();
}

void draw()
{
stroke(255);
background(40);

pg.beginDraw();
pg.background(200);
pg.fill(#FF0000);
pg.ellipse(10, 56, 12, 12);

pg.fill(#AA00FF);
pg.ellipse(15, 20, 5, 5);
for (int i = 1; i <= 3; i++)
pg.ellipse(24*i, 48, 8, 16);

pg.endDraw();
image(pg, 0, 0, 400, 400);
}
Page Index Toggle Pages: 1