Skip to content

Commit

Permalink
Merge pull request #34 from cansik/master
Browse files Browse the repository at this point in the history
added hello peasy offscreen example
  • Loading branch information
Jonathan Feinberg authored Feb 9, 2018
2 parents b6b13d3 + 1dbbb95 commit 68066cc
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions examples/HelloPeasy_Offscreen/HelloPeasy_Offscreen.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import peasy.PeasyCam;

PeasyCam cam;
PGraphics canvas;

void setup()
{
size(500, 500, P2D);
cam = new PeasyCam(this, 400);

canvas = createGraphics(width, height, P3D);
}

void draw()
{
// draw a simple rotating cube around a sphere onto an offscreen canvas
canvas.beginDraw();
canvas.background(55);

canvas.pushMatrix();

canvas.rotateX(radians(frameCount % 360));
canvas.rotateZ(radians(frameCount % 360));

canvas.noStroke();
canvas.fill(20, 20, 20);
canvas.box(100);

canvas.fill(150, 255, 255);
canvas.sphere(60);

canvas.popMatrix();
canvas.endDraw();

// apply view matrix of peasy to canvas
cam.getState().apply(canvas);

// draw canvas onto onscreen
image(canvas, 0, 0);
}

0 comments on commit 68066cc

Please sign in to comment.