-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented resetMatrix and applyMatrix
- Loading branch information
Showing
5 changed files
with
107 additions
and
4 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
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
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
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
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,71 @@ | ||
<!DOCTYPE html> | ||
<html lang=""> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>p5.js example</title> | ||
<style> body {padding: 0; margin: 0;} </style> | ||
|
||
<script src="addScreenPositionFunction.js"></script> | ||
<script src="lib/p5.js"></script> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
|
||
p5.disableFriendlyErrors = true; | ||
|
||
|
||
// set mode to "2D" or "3D" to quickly test if WEBGL is also working | ||
var mode = "2D"; | ||
|
||
function setup() { | ||
if (mode == "2D") createCanvas(windowWidth, windowHeight); | ||
else createCanvas(windowWidth, windowHeight, WEBGL); | ||
|
||
addScreenPositionFunction(); | ||
|
||
rectMode(CENTER); | ||
stroke(255); | ||
} | ||
|
||
function draw() { | ||
// resetTransformationTracker(); | ||
|
||
background(0); | ||
|
||
push(); | ||
|
||
// just for testing: this should be reset | ||
scale(1.4); | ||
|
||
resetMatrix(); | ||
|
||
if (mode == "2D") translate(width / 2, height / 2); | ||
|
||
let f = frameCount / 100; | ||
applyMatrix(noise(f) * 2, noise(f+100)-0.5, noise(f+200)-0.5, noise(f+300) * 2, noise(f+400) * 200 - 100, noise(f+500) * 200 - 100); | ||
|
||
line(-100, -100, 100, 100); | ||
|
||
var p1 = screenPosition(-100, -100, 0); | ||
var p2 = screenPosition(100, 100, 0); | ||
|
||
if (mode != "2D") rotateY(90); | ||
|
||
fill(128); | ||
rect(0, 0, 100, 100); | ||
|
||
pop(); | ||
|
||
fill(255, 0, 0); | ||
circle(p1.x, p1.y, 10); | ||
circle(p2.x, p2.y, 10); | ||
} | ||
|
||
function mousePressed() { | ||
noLoop(); | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |