Artists
Translations
Structure
Translated by
Krystof Pesek
Based on:
Structure
by
Zdenek Sykora
Category:
experimental
p5.js
Processing
Play
Stop
/* Part of the ReCode Project (http://recodeproject.com) Based on "Structure" by Zdenek Sykora Originally published in "Computer Graphics and Art" vol1 no2, 1976 Copyright (c) 2012 Krystof Pesek - OSI/MIT license (http://recodeproject/license). */ let theta; let plny; let moznosti = [0, 90, 180, 270]; let r; function setup() { createCanvas(576, 704); imageMode(CENTER); plny = createGraphics(32, 32); createShaped(); theta = []; for (let i = 0; i < 3000; i++) { theta[i] = moznosti[floor(random(4))]; } } function draw() { background(0); r = plny.width; let idx = 0; for (let y = 0; y <= height / plny.height; y++) { for (let x = 0; x <= width / plny.width; x++) { push(); translate(x * r + plny.width/2, y * r + plny.height/2); rotate(radians(theta[idx])); theta[idx] += 0.004 * degrees(frameCount/200.0 * atan2(mouseY - y*r, mouseX - x*r)); image(plny, 0, 0); pop(); idx += 1; } } } function createShaped() { let W = plny.width; let H = plny.height; plny.fill(255); plny.noStroke(); plny.arc(W/2, H/2, W - 2, H - 2, 0, PI); }
/* Part of the ReCode Project (http://recodeproject.com) Based on "Structure" by Zdenek Sykora Originally published in "Computer Graphics and Art" vol1 no2, 1976 Copyright (c) 2012 Krystof Pesek - OSI/MIT license (http://recodeproject/license). */ ///////////////////////////////// float theta[]; PGraphics plny; int [] moznosti = {0,90,180,270}; float [] rot = {1,2,4}; float r; ///////////////////////////////// void setup(){ size(576,704,P2D); imageMode(CENTER); plny = createGraphics(32,32,JAVA2D); createShaped(); theta = new float[3000]; for (int i = 0 ; i < theta.length ; i ++){ theta[i] = moznosti[(int)random(4)]; } } ///////////////////////////////// void draw(){ background(0); r = plny.width; int idx = 0; for(int y = 0;y <= height/plny.height;y++){ for(int x = 0;x <= width/plny.width;x++){ pushMatrix(); translate(x*r+plny.width/2,y*r+plny.height/2); rotate(radians(theta[idx])); theta[idx] += 0.004*degrees(frameCount/200.0*atan2(mouseY-y*r,mouseX-x*r)); image (plny,0,0); popMatrix(); idx += 1; } } } ///////////////////////////////// void createShaped(){ int W = plny.width; int H = plny.height; plny.beginDraw(); plny.smooth(); plny.fill(255); plny.noStroke(); plny.arc(W/2,H/2,W-2,H-2,0,PI); plny.endDraw(); } /////////////////////////////////