diff options
author | David Runge <dave@sleepmap.de> | 2015-12-30 03:43:22 +0100 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2015-12-30 03:43:22 +0100 |
commit | 33a44587ecf9c6b2287b460743207f856f811067 (patch) | |
tree | ab7626f0a0ea6cf01aefb5cff02bd57b3ccb7f91 /AutoVisual | |
download | processing-sketchbook-33a44587ecf9c6b2287b460743207f856f811067.tar.gz processing-sketchbook-33a44587ecf9c6b2287b460743207f856f811067.tar.bz2 processing-sketchbook-33a44587ecf9c6b2287b460743207f856f811067.tar.xz processing-sketchbook-33a44587ecf9c6b2287b460743207f856f811067.zip |
AutoVisual: First commit of AutoVisual, a sketch based upon Islamic Geometric Patterns by Eric Broug. Partially functioning implementations of square, pentagon and hexagon base patterns.
Diffstat (limited to 'AutoVisual')
-rw-r--r-- | AutoVisual/AutoVisual.pde | 27 | ||||
-rw-r--r-- | AutoVisual/IGPFamily.pde | 115 | ||||
-rw-r--r-- | AutoVisual/IGPHexagon.pde | 96 | ||||
-rw-r--r-- | AutoVisual/IGPPentagon.pde | 27 | ||||
-rw-r--r-- | AutoVisual/IGPSquare.pde | 97 |
5 files changed, 362 insertions, 0 deletions
diff --git a/AutoVisual/AutoVisual.pde b/AutoVisual/AutoVisual.pde new file mode 100644 index 0000000..9db7ba9 --- /dev/null +++ b/AutoVisual/AutoVisual.pde @@ -0,0 +1,27 @@ +IGPSquare square; +IGPHexagon hexagon; +IGPPentagon pentagon; +float midx; +float midy; +float circleSize = 256; + +void setup() { + size(640, 360); + midx = width/2; + midy = height/2; + square = new IGPSquare(midx, midy, circleSize, 12); +// square = new IGPSquare(midx, midy, circleSize, 16); + hexagon = new IGPHexagon(midx, midy, circleSize); + pentagon = new IGPPentagon(midx, midy, circleSize); +} + +void draw() { + background(0); + noFill(); + square.displayConstructionLines(); + square.display(); + hexagon.displayConstructionLines(); + hexagon.display(); + pentagon.displayConstructionLines(); + pentagon.display(); +} diff --git a/AutoVisual/IGPFamily.pde b/AutoVisual/IGPFamily.pde new file mode 100644 index 0000000..3451d88 --- /dev/null +++ b/AutoVisual/IGPFamily.pde @@ -0,0 +1,115 @@ +class IGPFamily { + PVector mid; + float diameter; + float radius; + ArrayList <PVector> alphaCircleVectors; + ArrayList <PVector> constructionCircleCenters; + ArrayList <PVector> constructionPartsTwelve; + ArrayList <PVector> constructionPartsSixteen; + + IGPFamily(float x, float y, float d){ + ellipseMode(CENTER); + colorMode(RGB, 1.0, 1.0, 1.0, 1.0); + mid = new PVector(x, y); + diameter = d; + radius = d/2; + setVectorsOnAlphaCircle(); + println("New IGP object: x="+mid.x+"/ y="+mid.y+"/ diameter="+diameter); + } + + void setVectorsOnAlphaCircle(){ + constructionCircleCenters = new ArrayList <PVector> (6); + constructionCircleCenters.add(getVectorOnAlphaCircle(0)); + constructionCircleCenters.add(getVectorOnAlphaCircle(30)); + constructionCircleCenters.add(getVectorOnAlphaCircle(60)); + constructionCircleCenters.add(getVectorOnAlphaCircle(90)); + constructionCircleCenters.add(getVectorOnAlphaCircle(120)); + constructionCircleCenters.add(getVectorOnAlphaCircle(150)); + constructionCircleCenters.add(getVectorOnAlphaCircle(180)); + constructionCircleCenters.add(getVectorOnAlphaCircle(210)); + constructionCircleCenters.add(getVectorOnAlphaCircle(240)); + constructionCircleCenters.add(getVectorOnAlphaCircle(270)); + constructionCircleCenters.add(getVectorOnAlphaCircle(300)); + constructionCircleCenters.add(getVectorOnAlphaCircle(330)); + } + + PVector getVectorOnCircle(PVector mid, float degree){ + PVector point = new PVector(mid.x + radius*cos(radians(degree)), mid.y + radius * sin(radians(degree))); + return point; + } + + PVector getVectorOnAlphaCircle(float degree){ + return getVectorOnCircle(mid, degree); + } + + void createSquare(PVector mid, float diameter){ + rect(mid.x, mid.y, diameter, diameter); + } + + void createOuterSquare() { + stroke(0.66, 0.66, 0.66, 0.4); + rectMode(CENTER); + createSquare(mid, diameter); + } + + void createInnerSquare() { + stroke(0.66, 0.66, 0.66, 0.4); + rectMode(CENTER); + createSquare(mid, sqrt(sq(diameter)/2)); + } + + void createInnerSquareTilted(float angle){ + rectMode(CENTER); + stroke(0.66, 0.66, 0.66, 0.4); + translate(mid.x, mid.y); + pushMatrix(); + rotate(radians(angle)); + createSquare(new PVector(0, 0), sqrt(sq(diameter)/2)); + popMatrix(); + translate(mid.x*(-1), mid.y*(-1)); + } + + void createCircle(PVector v) { + ellipse(v.x, v.y, diameter, diameter); + } + + void createAlphaCircle() { + stroke(1.0, 0.0, 0.0, 1.0); + createCircle(mid); + } + + void createConstructionCircles(){ + stroke(0.66, 0.66, 0.66, 0.4); + for (PVector constructionCircle : constructionCircleCenters) { + createCircle(constructionCircle); + } + } + + void createLine(PVector from, PVector to){ + beginShape(LINES); + vertex(from.x, from.y); + vertex(to.x, to.y); + endShape(); + } + + void createVerticalHorizontalConstructionLines(){ + createLine(constructionCircleCenters.get(0), constructionCircleCenters.get(2)); + createLine(constructionCircleCenters.get(1), constructionCircleCenters.get(3)); + } + + void createDiagonalConstructionLines(){ + createLine(new PVector(constructionCircleCenters.get(1).x-radius, constructionCircleCenters.get(2).y-radius), new PVector(constructionCircleCenters.get(3).x+radius, constructionCircleCenters.get(0).y+radius)); + createLine(new PVector(constructionCircleCenters.get(1).x+radius, constructionCircleCenters.get(0).y-radius), new PVector(constructionCircleCenters.get(3).x-radius, constructionCircleCenters.get(2).y+radius)); + } + + void display() { + createAlphaCircle(); + } + + void displayConstructionLines() { + stroke(0.66, 0.66, 0.66, 0.4); + createConstructionCircles(); + createVerticalHorizontalConstructionLines(); + } + +} diff --git a/AutoVisual/IGPHexagon.pde b/AutoVisual/IGPHexagon.pde new file mode 100644 index 0000000..aeb4164 --- /dev/null +++ b/AutoVisual/IGPHexagon.pde @@ -0,0 +1,96 @@ +class IGPHexagon extends IGPFamily{ + + IGPHexagon(float x, float y, float d){ + super(x, y, d); + setVectorsOnAlphaCircle(); + setVectorsOnConstructionCircles(); + } + + void setVectorsOnConstructionCircles(){ + int amount = 12; + constructionPartsTwelve = new ArrayList <PVector>(12); + // 0° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(0), 0)); + // 30° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(2), 0)); + // 60° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(2), 60)); + // 90° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(2), 120)); + // 120° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(4), 120)); + // 150° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(6), 120)); + // 180° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(6), 180)); + // 210° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(8), 180)); + // 240° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(8), 240)); + // 270° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(8), 300)); + // 300° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(10), 300)); + // 330° + constructionPartsTwelve.add(getVectorOnCircle(constructionCircleCenters.get(10), 0)); + } + + void createDividingConstructionLines(int amount){ + stroke(0.66, 0.66, 0.66, 0.4); + createLine(constructionPartsTwelve.get(0), constructionPartsTwelve.get(6)); + createLine(constructionPartsTwelve.get(1), constructionPartsTwelve.get(7)); + createLine(constructionPartsTwelve.get(2), constructionPartsTwelve.get(8)); + createLine(constructionPartsTwelve.get(3), constructionPartsTwelve.get(9)); + createLine(constructionPartsTwelve.get(4), constructionPartsTwelve.get(10)); + createLine(constructionPartsTwelve.get(5), constructionPartsTwelve.get(11)); + } + + void createDividingLines(int amount){ + stroke(0.0, 0.66, 0.0, 0.4); + createLine(constructionCircleCenters.get(0), constructionCircleCenters.get(6)); + createLine(constructionCircleCenters.get(1), constructionCircleCenters.get(7)); + createLine(constructionCircleCenters.get(2), constructionCircleCenters.get(8)); + createLine(constructionCircleCenters.get(3), constructionCircleCenters.get(9)); + createLine(constructionCircleCenters.get(4), constructionCircleCenters.get(10)); + createLine(constructionCircleCenters.get(5), constructionCircleCenters.get(11)); + } + + void createConstructionCircles(){ + stroke(0.66, 0.66, 0.66, 0.4); + createCircle(constructionCircleCenters.get(0)); + createCircle(constructionCircleCenters.get(2)); + createCircle(constructionCircleCenters.get(4)); + createCircle(constructionCircleCenters.get(6)); + createCircle(constructionCircleCenters.get(8)); + createCircle(constructionCircleCenters.get(10)); + } + + void createInnerHexagon(){ + stroke(0.0, 0.0, 0.66, 0.4); + beginShape(LINES); + vertex(constructionCircleCenters.get(1).x, constructionCircleCenters.get(1).y); + vertex(constructionCircleCenters.get(3).x, constructionCircleCenters.get(3).y); + vertex(constructionCircleCenters.get(3).x, constructionCircleCenters.get(3).y); + vertex(constructionCircleCenters.get(5).x, constructionCircleCenters.get(5).y); + vertex(constructionCircleCenters.get(5).x, constructionCircleCenters.get(5).y); + vertex(constructionCircleCenters.get(7).x, constructionCircleCenters.get(7).y); + vertex(constructionCircleCenters.get(7).x, constructionCircleCenters.get(7).y); + vertex(constructionCircleCenters.get(9).x, constructionCircleCenters.get(9).y); + vertex(constructionCircleCenters.get(9).x, constructionCircleCenters.get(9).y); + vertex(constructionCircleCenters.get(11).x, constructionCircleCenters.get(11).y); + vertex(constructionCircleCenters.get(11).x, constructionCircleCenters.get(11).y); + vertex(constructionCircleCenters.get(1).x, constructionCircleCenters.get(1).y); + endShape(); + } + + void display() { + super.display(); + createDividingLines(12); + createInnerHexagon(); + } + + void displayConstructionLines(){ + super.displayConstructionLines(); + createDividingConstructionLines(12); + } +} diff --git a/AutoVisual/IGPPentagon.pde b/AutoVisual/IGPPentagon.pde new file mode 100644 index 0000000..155027f --- /dev/null +++ b/AutoVisual/IGPPentagon.pde @@ -0,0 +1,27 @@ +class IGPPentagon extends IGPFamily{ + + IGPPentagon(float x, float y, float d){ + super(x, y, d); + setVectorsOnAlphaCircle(); + } + + void setVectorsOnAlphaCircle(){ + constructionCircleCenters = new ArrayList <PVector> (6); + constructionCircleCenters.add(getVectorOnAlphaCircle(0)); + constructionCircleCenters.add(getVectorOnAlphaCircle(30)); + constructionCircleCenters.add(getVectorOnAlphaCircle(60)); + constructionCircleCenters.add(getVectorOnAlphaCircle(90)); + constructionCircleCenters.add(getVectorOnAlphaCircle(120)); + constructionCircleCenters.add(getVectorOnAlphaCircle(150)); + constructionCircleCenters.add(getVectorOnAlphaCircle(180)); + constructionCircleCenters.add(getVectorOnAlphaCircle(210)); + constructionCircleCenters.add(getVectorOnAlphaCircle(240)); + constructionCircleCenters.add(getVectorOnAlphaCircle(270)); + constructionCircleCenters.add(getVectorOnAlphaCircle(300)); + constructionCircleCenters.add(getVectorOnAlphaCircle(330)); + } + + void display() { + createConstructionCircles(); + } +} diff --git a/AutoVisual/IGPSquare.pde b/AutoVisual/IGPSquare.pde new file mode 100644 index 0000000..80e3700 --- /dev/null +++ b/AutoVisual/IGPSquare.pde @@ -0,0 +1,97 @@ +class IGPSquare extends IGPFamily { + int parts; + + IGPSquare(float x, float y, float d, int p){ + super(x, y, d); + parts = p; + setVectorsOnAlphaCircle(); +// setConstructionCircleCenters(); + setVectorsOnOuterSquare(); + } + + void setVectorsOnAlphaCircle(){ + constructionCircleCenters = new ArrayList <PVector> (4); + constructionCircleCenters.add(getVectorOnAlphaCircle(0)); + constructionCircleCenters.add(getVectorOnAlphaCircle(90)); + constructionCircleCenters.add(getVectorOnAlphaCircle(180)); + constructionCircleCenters.add(getVectorOnAlphaCircle(270)); + } + + void setConstructionCircleCenters(){ + constructionCircleCenters = new ArrayList <PVector> (4); + constructionCircleCenters.add(alphaCircleVectors.get(0)); + constructionCircleCenters.add(alphaCircleVectors.get(3)); + constructionCircleCenters.add(alphaCircleVectors.get(6)); + constructionCircleCenters.add(alphaCircleVectors.get(9)); + } + + void setVectorsOnOuterSquare(){ + int amount = 12; + constructionPartsTwelve = new ArrayList <PVector>(12); + constructionPartsTwelve.add(constructionCircleCenters.get(0)); + constructionPartsTwelve.add(new PVector(constructionCircleCenters.get(1).x+radius/2+radius/amount, mid.y-radius)); + constructionPartsTwelve.add(new PVector(mid.x+radius, constructionCircleCenters.get(0).y-radius/2-radius/amount)); + constructionPartsTwelve.add(constructionCircleCenters.get(1)); + constructionPartsTwelve.add(new PVector(mid.x+radius, constructionCircleCenters.get(0).y+radius/2+radius/amount)); + constructionPartsTwelve.add(new PVector(constructionCircleCenters.get(3).x+radius/2+radius/amount, mid.y+radius)); + constructionPartsTwelve.add(constructionCircleCenters.get(2)); + constructionPartsTwelve.add(new PVector(constructionCircleCenters.get(3).x-radius/2-radius/amount, mid.y+radius)); + constructionPartsTwelve.add(new PVector(mid.x-radius, constructionCircleCenters.get(2).y+radius/2+radius/amount)); + constructionPartsTwelve.add(constructionCircleCenters.get(3)); + constructionPartsTwelve.add(new PVector(mid.x-radius, constructionCircleCenters.get(2).y-radius/2-radius/amount)); + constructionPartsTwelve.add(new PVector(constructionCircleCenters.get(1).x-radius/2-radius/amount, mid.y-radius)); + constructionPartsSixteen = new ArrayList <PVector>(16); + constructionPartsSixteen.add(constructionCircleCenters.get(0)); + constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(1).x+radius/2-radius/amount, mid.y-radius)); + constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(1).x-radius, constructionCircleCenters.get(2).y-radius)); + constructionPartsSixteen.add(new PVector(mid.x+radius, constructionCircleCenters.get(0).y-radius/2+radius/amount)); + constructionPartsSixteen.add(constructionCircleCenters.get(1)); + constructionPartsSixteen.add(new PVector(mid.x+radius, constructionCircleCenters.get(0).y+radius/2-radius/amount)); + constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(1).x+radius, constructionCircleCenters.get(0).y-radius)); + constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(3).x+radius/2-radius/amount, mid.y+radius)); + constructionPartsSixteen.add(constructionCircleCenters.get(2)); + constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(3).x-radius/2+radius/amount, mid.y+radius)); + constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(3).x+radius, constructionCircleCenters.get(0).y+radius)); + constructionPartsSixteen.add(new PVector(mid.x-radius, constructionCircleCenters.get(2).y+radius/2-radius/amount)); + constructionPartsSixteen.add(constructionCircleCenters.get(3)); + constructionPartsSixteen.add(new PVector(mid.x-radius, constructionCircleCenters.get(2).y-radius/2+radius/amount)); + constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(3).x-radius, constructionCircleCenters.get(2).y+radius)); + constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(1).x-radius/2+radius/amount, mid.y-radius)); + } + + void createDividingConstructionLines(int amount){ + if(amount == 12){ + stroke(0.0, 0.66, 0.0, 0.4); + createLine(constructionPartsTwelve.get(0), constructionPartsTwelve.get(6)); + createLine(constructionPartsTwelve.get(1), constructionPartsTwelve.get(7)); + createLine(constructionPartsTwelve.get(2), constructionPartsTwelve.get(8)); + createLine(constructionPartsTwelve.get(3), constructionPartsTwelve.get(9)); + createLine(constructionPartsTwelve.get(4), constructionPartsTwelve.get(10)); + createLine(constructionPartsTwelve.get(5), constructionPartsTwelve.get(11)); + }else if (amount == 16){ + amount = 12; + stroke(0.0, 0.0, 0.66, 0.4); + createLine(constructionPartsSixteen.get(0), constructionPartsSixteen.get(8)); + createLine(constructionPartsSixteen.get(1), constructionPartsSixteen.get(9)); + createLine(constructionPartsSixteen.get(2), constructionPartsSixteen.get(10)); + createLine(constructionPartsSixteen.get(3), constructionPartsSixteen.get(11)); + createLine(constructionPartsSixteen.get(4), constructionPartsSixteen.get(12)); + createLine(constructionPartsSixteen.get(5), constructionPartsSixteen.get(13)); + createLine(constructionPartsSixteen.get(6), constructionPartsSixteen.get(14)); + createLine(constructionPartsSixteen.get(7), constructionPartsSixteen.get(15)); + } + } + + void display() { + super.display(); + createOuterSquare(); + if (parts == 16){ + createInnerSquare(); + createInnerSquareTilted(45); + createDividingConstructionLines(16); + }else if (parts == 12){ + createDividingConstructionLines(12); + } + } + +} |