Add Initial commit
This commit is contained in:
17
CM2030 Graphics Programming/Topic 1/1.3.3/index.html
Normal file
17
CM2030 Graphics Programming/Topic 1/1.3.3/index.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>randomDot</title>
|
||||||
|
<script src="libraries/p5.min.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
<script src="libraries/p5.dom.js" type="text/javascript"></script>
|
||||||
|
<script src="libraries/p5.sound.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
<script src="sketch.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
<style> body {padding: 0; margin: 0;} canvas {vertical-align: top;} </style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
3031
CM2030 Graphics Programming/Topic 1/1.3.3/libraries/p5.dom.js
Normal file
3031
CM2030 Graphics Programming/Topic 1/1.3.3/libraries/p5.dom.js
Normal file
File diff suppressed because it is too large
Load Diff
36
CM2030 Graphics Programming/Topic 1/1.3.3/libraries/p5.min.js
vendored
Normal file
36
CM2030 Graphics Programming/Topic 1/1.3.3/libraries/p5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12873
CM2030 Graphics Programming/Topic 1/1.3.3/libraries/p5.sound.js
Normal file
12873
CM2030 Graphics Programming/Topic 1/1.3.3/libraries/p5.sound.js
Normal file
File diff suppressed because it is too large
Load Diff
71
CM2030 Graphics Programming/Topic 1/1.3.3/sketch.js
Normal file
71
CM2030 Graphics Programming/Topic 1/1.3.3/sketch.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
let secLength = 160;
|
||||||
|
let secWidth = 1;
|
||||||
|
let minLength = 140;
|
||||||
|
let minWidth = 3;
|
||||||
|
let hourLength = 90;
|
||||||
|
let hourWidth = 5;
|
||||||
|
|
||||||
|
function setup()
|
||||||
|
{
|
||||||
|
createCanvas(900, 600);
|
||||||
|
background(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw()
|
||||||
|
{
|
||||||
|
background(255);
|
||||||
|
noFill();
|
||||||
|
translate(width/2, height/2);
|
||||||
|
ellipse(0, 0, 350, 350);
|
||||||
|
|
||||||
|
push();
|
||||||
|
strokeWeight(secWidth);
|
||||||
|
stroke(200, 0, 0);
|
||||||
|
let secAngle = map(second(), 0, 60, 0, 360);
|
||||||
|
rotate(radians(secAngle));
|
||||||
|
line(0, 0, 0, -secLength);
|
||||||
|
pop();
|
||||||
|
|
||||||
|
push();
|
||||||
|
strokeWeight(minWidth);
|
||||||
|
let minAngle = map(minute(), 0, 60, 0, 360);
|
||||||
|
rotate(radians(minAngle));
|
||||||
|
line(0, 0, 0, -minLength);
|
||||||
|
pop();
|
||||||
|
|
||||||
|
push();
|
||||||
|
strokeWeight(hourWidth);
|
||||||
|
let hourAngle = map(hour(), 0, 12, 0, 360);
|
||||||
|
rotate(radians(hourAngle));
|
||||||
|
line(0, 0, 0, -hourLength);
|
||||||
|
|
||||||
|
push();
|
||||||
|
translate(0, -hourLength);
|
||||||
|
fill(255);
|
||||||
|
ellipse(0, 20, 20);
|
||||||
|
pop();
|
||||||
|
pop();
|
||||||
|
|
||||||
|
let hours = 12;
|
||||||
|
let hourStep = 360 / hours;
|
||||||
|
for(let i=0; i<hours; i++)
|
||||||
|
{
|
||||||
|
push();
|
||||||
|
rotate(radians(hourStep * i));
|
||||||
|
//translate(0,)
|
||||||
|
line(0, -175, 0, -140);
|
||||||
|
pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
let minStep = 360/60;
|
||||||
|
push()
|
||||||
|
for(let i=0; i<60; i++)
|
||||||
|
{
|
||||||
|
if( i % 5 != 0 )
|
||||||
|
{
|
||||||
|
line(0, -175, 0, -155);
|
||||||
|
}
|
||||||
|
rotate(PI / 30);
|
||||||
|
}
|
||||||
|
pop();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user