xxxxxxxxxx
let img; //画像データ格納用変数を定義
function preload() { //画像をロード
img = loadImage("photo.jpg"); //ロードした画像を変数imgに格納
}
function setup() {
createCanvas(windowWidth, windowHeight);
img.resize(width, height); //画像をキャンバスの大きさにリサイズ
background(0); //背景を黒に
}
function draw() {
let x = int(random(width)); //ランダムに取得したx値の整数表現(int)
let y = int(random(height)); //ランダムに取得したy値の整数表現(int)
let col = img.get(x, y); //x,yのピクセル情報を取得
fill(col, 127);
noStroke();
let diameter = 20;
rect(x, y, diameter); //円を描画
}