Skip to content

Instantly share code, notes, and snippets.

@hiroto3432
Created April 1, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiroto3432/a2b2e67445f802386a4dc0d1357d7363 to your computer and use it in GitHub Desktop.
Save hiroto3432/a2b2e67445f802386a4dc0d1357d7363 to your computer and use it in GitHub Desktop.
void setup(){
size(500,500);
surface.setResizable(true);
//PSurface psf = getSurface();
//psf.setResizable(true);
frameRate(30);
textAlign(CENTER,CENTER);
}
int PWidth = 500;
int PHeight = 500;
float ScaleW = 1.0;
float ScaleH = 1.0;
void draw() throws IllegalArgumentException{
if(PWidth != width || PHeight!=height){
ScaleW *= (float)width / PWidth;
ScaleH *= (float)height / PHeight;
PWidth = width;
PHeight = height;
}
println(ScaleW,ScaleH);
scale(ScaleW,ScaleH);
background(0);
noStroke();
fill(0,255,0);
ellipse(100,100,200,200);
fill(255,255,0);
rect(200,200,300,300);
fill(255);
textSize(48);
text("W:" + PWidth,350,100);
text("H:" + PHeight,100,350);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment