xxxxxxxxxx
var myImage; // Declare image variable name
var brush;
function preload() {
myImage = loadImage("mona lisa.jpg"); // Load the image from openprocessing into myImage variable
brush = loadImage("brush.png");
}
function setup() {
// Creates the application window params: width=600, height=750
createCanvas(600, 750);
}
function draw() {
//background(255);
// Place loaded myImage variable into the image() function to display it on the canvas
//image(myImage, 0, 0, width, height);
noStroke();
//blendMode(MULTIPLY);
let x = floor(random(0, myImage.width));
let y = floor(random(0, myImage.height));
// To Make it interactive comment the above lines
// and uncomment the following two lines and vice versa
//let x = mouseX;
//let y = mouseY;
let pix = myImage.get(x, y); // returns the pixel color of the specific x and y coordinate
fill(red(pix), green(pix), blue(pix), 255); // set the fill color from loaded image
// // option 1
var sz = random(5, 10);
//circle(x, y, sz*100);
// option 2
push();
fill(red(pix), green(pix), blue(pix), 55); // set the fill color from loaded image
var dice = random(-30, 30);
rectMode(CENTER);
angleMode(DEGREES);
translate(x,y);
rotate(40)
rect(0, 0, sz);
pop();
// option 3 with custom brush
// Refer to course prensentation
push();
imageMode(CENTER);
angleMode(DEGREES);
translate(x, y);
rotate(random(360));
scale(random(0.1, 0.4));
tint(red(pix), green(pix), blue(pix), 100);
image(brush, 0, 0);
pop();
}