xxxxxxxxxx
let img, input;
let radius = 150;
let CL, LW = 2;
let pixel_size, pixel_theta;
function setup() {
createCanvas(windowWidth,windowHeight);
background(100);
CL = 2*radius*PI;
pixel_size = (CL-CL/LW)/(CL/LW)+LW;
pixel_theta = (pixel_size/2) / radius;
//img = loadImage("35762p.jpg");
//image(a, 0, 0);
//pixelDensity(3);
//noLoop();
input = createFileInput(handleFile);
input.position(0, 0);
}
function draw() {
background(0);
if(img){
image(img, 150, 50, 2*radius, 2*radius);
noFill();
stroke(255);
circle(300, 200, 2*radius);
for(let r=0; r<radius; r+=LW){
for(let th=0; th<2*PI; th+=pixel_theta){
fill(get(r*cos(th+pixel_theta/2)+300,r*sin(th+pixel_theta/2)+200));
noStroke();
push();
translate(1*r*cos(th) + 1000, 1*r*sin(th) + 300);
rotate(th);
rect(0, 0, pixel_size);//(i,10));
pop();
}
}
}
}
function toPolar(x, y) {
return createVector(sqrt(x*x+y*y), atan(y, x));
}
function toSquare(x, y) {
return createVector(sqrt(x*x+y*y), atan(y, x));
}
function handleFile(file) {
print(file);
if (file.type === 'image') {
img = createImg(file.data, '');
img.hide();
} else {
img = null;
}
}
function createPixel(r, th, color) {
var x = r;
var y = th;
this.led = function() {
fill(color);
push();
translate(x, y);
rotate(th);
//rect();
pop();
}
}