From 11b08adc57c57a0d8eb6d7cd92c160e18f5446a7 Mon Sep 17 00:00:00 2001 From: Lev Date: Sat, 26 Jun 2021 19:48:31 -0500 Subject: [PATCH] Update completed the challenge --- .../Topic 6/6.1.5 Random Font/sketch.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/CM2030 Graphics Programming/Topic 6/6.1.5 Random Font/sketch.js b/CM2030 Graphics Programming/Topic 6/6.1.5 Random Font/sketch.js index 6fea13d..f2e0807 100644 --- a/CM2030 Graphics Programming/Topic 6/6.1.5 Random Font/sketch.js +++ b/CM2030 Graphics Programming/Topic 6/6.1.5 Random Font/sketch.js @@ -1,9 +1,11 @@ -var font; +let font; +let max; + function preload() { font = loadFont('assets/Calistoga-Regular.ttf'); } -var points; +let points; function setup() { createCanvas(900, 400); @@ -14,14 +16,19 @@ function setup() { sampleFactor: .3, simplifyThreshold: 0 }); - + max = 20; } function draw() { background(0); - // *** your code here **** - + for (let i = 0; i < points.length; i++) { + let xmap = map(mouseX, 0, width, 0, max); + let ymap = map(mouseX, 0, width, 0, max); + let deltaX = random(-xmap, xmap); + let deltaY = random(-ymap, ymap); + ellipse(points[i].x + deltaX, points[i].y + deltaY, 10, 10); + } noLoop(); }