Skip to content

Commit

Permalink
Merge pull request CodingTrain#35 from waielal/master
Browse files Browse the repository at this point in the history
 Added hour12() method to the sketch object CodingTrain#32
  • Loading branch information
meiamsome authored Oct 1, 2017
2 parents cacaa85 + 0ccdc14 commit 626017d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions clocks/clock-09.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var clock09 = function(sketch) {
for (let row = 0; row < dots.length; row++) {
for (let col = 0; col < dots[row].length; col++) {
if (dots[row][col] === 1)
drawClock(x + (5*size) * col - (10*size), y + (5 * size) * row - (15 * size), 5*size, 5*size);
drawClock(x + (5*size) * col - (10*size), y + (5 * size) * row - (15 * size), 5*size, 5*size);
}
}
}
Expand All @@ -28,7 +28,7 @@ var clock09 = function(sketch) {
function drawTime(hour, minute, second){
// Prefixing 0 before minute < 10
if(minute.length === 1) minute = "0" + minute;

// Calculating multiplying factor to size of each dot, so that clock fills whole space.
// Calculated by divinding availavle space(width) by required space (no. of cols * size of dot(5) )
// No. of cols = (No. of characters * No. of cols of each character) + Spaces in between characters + cols to leave before and after clock
Expand Down Expand Up @@ -66,7 +66,7 @@ var clock09 = function(sketch) {
sketch.fill(224);
sketch.ellipse(x,y,w,h);
// Draw the inner cirle
sketch.fill(255);
sketch.fill(255);
sketch.ellipse(x,y,w-1,h-1);
// Draw the arms / arcs
sketch.push();
Expand Down
5 changes: 5 additions & 0 deletions sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ window.addEventListener('load', function() {

clocks.forEach(function(data) {
data.p5 = new p5(function(sketch) {
// add the hour12 method to the sketch object
sketch.hour12 = function() {
let h = sketch.hour() % 12;
return (h == 0 ? 12 : h);
}
data.over = false;
// Original sketch
data.fn(sketch);
Expand Down

0 comments on commit 626017d

Please sign in to comment.