-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from cansik/master
added hello peasy offscreen example
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |