Skip to content

Commit

Permalink
][+°><°+][
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaudry committed Feb 5, 2024
1 parent f29c00e commit 5daf76d
Showing 1 changed file with 123 additions and 0 deletions.
123 changes: 123 additions & 0 deletions p5-experiments/plottableperspective010.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<!DOCTYPE html>
<html lang="en">
<html>

<head>
<meta charset="UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.5.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.min.js"></script>
<script src="https://unpkg.com/[email protected]"></script>
<style>
body {
padding: 0;
margin: 0;
}
</style>
</head>

<body>
<script>
//pixel = dpi * mm / 25.4 mm
//A3: 297mm × 420mm
//96dpi is for plotting on the UUNA TEK iDraw
//w=96*297/25.4=1122.5
//h=96*420/25.4=1587.4
var echelle = 1
var w = 1122 * echelle
var h = 1587 * echelle
var rightmargin = 0.8 * w
var leftmargin = 0.2 * w
var topmargin = 0.2 * h
var bottommargin = 0.8 * h
var actualwidth = rightmargin - leftmargin
var actualheight = bottommargin - topmargin
var cnv, imgbtn, maxcount
var dataforonerow = []

function setup() {
//getsvg()
getpng()
centerCanvas();
colorMode(HSB, 360, 100, 100, 250);
strokeCap(SQUARE)
background(0,0,0)
noFill()
maxcount = random(39, 45)
}

function getsvg() {
cnv = createCanvas(w, h, SVG);
imgbtn = createButton("save svg");
placebtn();
imgbtn.mouseClicked(savesvg);
}
function getpng() {
cnv = createCanvas(w, h);
imgbtn = createButton("save png");
placebtn();
imgbtn.mouseClicked(savepng);
}

function centerCanvas() {
var x = (windowWidth - w) / 2;
var y = (windowHeight - h) / 2;
cnv.position(x, y);
}

function placebtn() {
var x = (windowWidth - w) / 2;
var y = (windowHeight - h) / 2;
imgbtn.position(x - 200, y + h / 2 + 42)
}

function savesvg() {
save("plottableperspective001.svg");
}
function savepng() {
save("plottableperspective001.png");
}

function draw() {
var cx, cy, offset, leftoff, rightoff
//background(0, 0, 0)
stroke(0,0,100)
eye()
//noLoop()
}

function eye(){
var cx, cy, rad1, rad2, rad3, angle1, angle2, angle3
var x1,y1,x2,y2,x3,y3,x4,y4
cx=w*0.5
cy=h*0.5
rad1=0.1*w
rad2=0.4*w
rad3=rad1+0.5*(rad2-rad1)
angle1=radians(random(0,180))
angle2=angle1+radians(random(0,180))
angle3=angle1+0.5*(angle2-angle1)
x1=cx
y1=cy
x2=cx+rad1*cos(angle1)
y2=cy+rad1*sin(angle1)
x3=cx+rad2*cos(angle3)
y3=cy+rad2*sin(angle3)
x4=cx+rad3*cos(angle2)
y4=cy+rad3*sin(angle2)
quad(x1,y1,x2,y2,x3,y3,x4,y4)
stroke(0,100,100);ellipse(x1,y1,7,7)
stroke(90,100,100);ellipse(x2,y2,7,7)
stroke(180,100,100);ellipse(x3,y3,7,7)
stroke(270,100,100);ellipse(x4,y4,7,7)
}


function getpointonline(origin, destination, t) {
return ((1 - t) * origin + (t * destination))

}

</script>
</body>

</html>

0 comments on commit 5daf76d

Please sign in to comment.