var MARGIN = 20;
var myFont;
function setup() {
var myCanvas = createCanvas(300, 300);
myCanvas.parent('myContainer');
stroke(255);
smooth();
frameRate(30);
fill(255);
}
function draw() {
background(230);
var s2 = second();
var m2 = minute();
var h2 = hour();
// var t =year()+"年"+ month()+"月"+day()+"日" + h2 + ":" + m2 + ":" + s2;
var t =year()+"/"+month()+"/"+day()+"/" + h2 + ":" + m2 + ":" + s2;
noStroke();
textAlign(CENTER);
textSize(12);
fill(50);
text(t, width/2, 260);
noStroke();
textAlign(CENTER);
textSize(17);
fill(150);
text("KyouMinakami", width/2, 245);
var s = second();
var m = minute() + (s/60.0);
var h = hour()%12 + (m/60.0);
translate(width/2, height/2);
rotate(radians(180));
// 文字盤の表示
push();
fill(80);
noStroke();
for(var i=0; i<60; i++){
// rotate(radians(6));
rotate(radians(5.990));
rect(width/2-MARGIN,0,3,1);
}
for(var i=0; i<12; i++){
//rotate(radians(30));
rotate(radians(29.990));
rect(width/2-MARGIN,0,4,2);
}
pop();
noFill();
stroke(255,0,0);
// 秒針
push();
rotate(radians(s*(360/60)));
strokeWeight(1);
line(0,0,0,width/2-MARGIN);
pop();
noFill();
stroke(50)
// 分針
push();
rotate(radians(m*(360/60)));
strokeWeight(2);
line(0,0,0,width/2-MARGIN);
pop();
// 時針
push();
rotate(radians(h*(360/12)));
strokeWeight(4);
line(0,0,0,width/3-MARGIN);
pop();
}
//ハート
function heart(){
var R = 3;
fill(255,255,255)
noStroke();
strokeJoin(ROUND);
push();
translate(width/2, height/2);
beginShape();
for (var theta = 0; theta < 360; theta++) {
var x = R * (16 * sin(radians(theta)) * sin(radians(theta)) * sin(radians(theta)));
var y = (-1) * R * (13 * cos(radians(theta)) - 5 * cos(radians(2 * theta))
- 2 * cos(radians(3 * theta)) - cos(radians(4 * theta)));
vertex(x, y);
}
endShape(CLOSE);
pop();
}
コメントを残す