xxxxxxxxxx
76
let x=0;
let y=0;
let a;
let b;
// let x = 0;
// let y = 0;
let r = 20; // Assign a value to r
let speedx = 2;
let speedy = 2;
function setup() {
createCanvas(600, 600);
}
function preload() {
img = loadImage('img.png');
img2 = loadImage('img.png');
}
function draw() {
background(220);
image(img, x, y, width, height);
// image(img, x - width, y, width, height);
// x = x + 1;
// if (x > width) {
// x = 0;
// }
// let ball1 = new Ball(width / 2, height / 2, r, speedx, speedy);
// ball1.drawBall();
// ball1.moveBall();
let c=img.get(mouseX,mouseY);
fill(c);
a= floor(random(img.width));
b= floor(random(img.height));
let myColour=color(255);
img.loadPixels();
img.set(a,b,myColour);
img.updatePixels();
image(img, x, y, width, height);
}
// class Ball {
// constructor(x, y, r, speedx, speedy) {
// this.x = x;
// this.y = y;
// this.r = r;
// this.speedx = speedx;
// this.speedy = speedy;
// }
// drawBall() {
// fill('white');
// circle(this.x, this.y, this.r);
// }
// moveBall(dx,dy) {
// this.x += dx;
// this.y += dy;
// }
// }
// function keyPressed() {
// if (key === 'ArrowUp') {
// ball1.moveBall(0, -speedy);
// } else if (key === 'ArrowDown') {
// ball1.moveBall(0, speedy);
// } else if (key === 'ArrowLeft') {
// ball1.moveBall(-speedx, 0);
// } else if (key === 'ArrowRight') {
// ball1.moveBall(speedx, 0);
// }
// }