Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyengiabach1201 authored Sep 4, 2023
1 parent aa3110f commit 649e594
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</head>
<body>
<script src="https://www.gstatic.com/firebasejs/8.4.3/firebase.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5@1.0.0/lib/p5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5@1.7.0/lib/p5.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="main.js"></script>

Expand Down Expand Up @@ -39,4 +39,4 @@ <h1>Colorful!!!</h1>
</div>
</div>
</body>
</html>
</html>
18 changes: 6 additions & 12 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function setup() {

// pointsData.remove()

var canvas = createCanvas(400, 400)
createCanvas(400, 400)
background(255)
fill(col)
noStroke()
Expand All @@ -29,8 +29,8 @@ function setup() {
points.push(point.val())
})

canvas.mousePressed(drawPoint)
canvas.mouseMoved(drawPointIfMousePressed)
mousePressed = drawPoint
mouseDragged = drawPoint

$("canvas").detach().prependTo("#main");
}
Expand All @@ -41,16 +41,10 @@ function draw() {
for (var i = 0; i < points.length; i++) {
var point = points[i]
fill(point.color)
circle(point.x, point.y, 10)
circle(point.x, point.y, point.size)
}
}

function drawPoint() {
pointsData.push({ x: mouseX, y: mouseY, color: col })
}

function drawPointIfMousePressed() {
if (mouseIsPressed) {
drawPoint()
}
async function drawPoint() {
await pointsData.push({ x: mouseX, y: mouseY, color: col, size: Math.floor(Math.random() * 15) + 5 })
}

0 comments on commit 649e594

Please sign in to comment.