diff options
author | David Runge <dave@sleepmap.de> | 2016-01-02 19:48:51 +0100 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2016-01-02 19:48:51 +0100 |
commit | b2c4efa974c3575e310339a72a5f10ad4e1aeba5 (patch) | |
tree | f9d3630bbb27acb92ee6e59795d9e89eb9ae742e /AutoVisual | |
parent | 7c668a004375978213fa843bd78d26d48e0ed5b1 (diff) | |
download | processing-sketchbook-b2c4efa974c3575e310339a72a5f10ad4e1aeba5.tar.gz processing-sketchbook-b2c4efa974c3575e310339a72a5f10ad4e1aeba5.tar.bz2 processing-sketchbook-b2c4efa974c3575e310339a72a5f10ad4e1aeba5.tar.xz processing-sketchbook-b2c4efa974c3575e310339a72a5f10ad4e1aeba5.zip |
AutoVisual/IGPFamily.pde: Fixing NullPointerException in
setStrokeColor() and setFillColor(). Adding useStrokeColor() and
useFillColor() to all drawing operations. Colorization now has to be set
prior to drawing the element by calling setStrokeColor() and/or
setFillColor() with a Float[] containing RGBA values.
Diffstat (limited to 'AutoVisual')
-rw-r--r-- | AutoVisual/IGPFamily.pde | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/AutoVisual/IGPFamily.pde b/AutoVisual/IGPFamily.pde index ff8d480..4434a79 100644 --- a/AutoVisual/IGPFamily.pde +++ b/AutoVisual/IGPFamily.pde @@ -14,6 +14,7 @@ class IGPFamily { IGPFamily(float x, float y, float d){ ellipseMode(CENTER); + rectMode(CENTER); colorMode(RGB, 1.0, 1.0, 1.0, 1.0); mid = new PVector(x, y); diameter = d; @@ -67,14 +68,14 @@ class IGPFamily { } void useStrokeColor(){ - if(strokeColor.length!=4 || strokeColor == null){ + if(this.strokeColor == null || this.strokeColor.length!=4){ strokeColor = defaultStrokeColor; } stroke(strokeColor[0], strokeColor[1], strokeColor[2], strokeColor[3]); } void useFillColor(){ - if(fillColor.length!=4 || fillColor == null){ + if(fillColor == null || fillColor.length!=4){ fillColor = defaultFillColor; } fill(fillColor[0], fillColor[1], fillColor[2], fillColor[3]); @@ -90,24 +91,20 @@ class IGPFamily { } void createSquare(PVector mid, float diameter){ + useStrokeColor(); + useFillColor(); rect(mid.x, mid.y, diameter, diameter); } void createOuterSquare() { - stroke(0.0, 0.0, 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)); @@ -117,22 +114,24 @@ class IGPFamily { } void createCircle(PVector v, float diameter) { + useStrokeColor(); + useFillColor(); ellipse(v.x, v.y, diameter, diameter); } void createAlphaCircle() { - stroke(1.0, 0.0, 0.0, 1.0); createCircle(mid, diameter); } void createConstructionCircles(){ - stroke(0.66, 0.66, 0.66, 0.4); for (PVector constructionCircle : constructionCircleCenters) { createCircle(constructionCircle, diameter); } } void createLine(PVector from, PVector to){ + useStrokeColor(); + useFillColor(); beginShape(LINES); vertex(from.x, from.y); vertex(to.x, to.y); @@ -140,7 +139,6 @@ class IGPFamily { } void createVerticalHorizontalConstructionLines(){ - //TODO: add for 16 parts createLine(alphaCircleVectors.get(0), alphaCircleVectors.get(6)); createLine(alphaCircleVectors.get(3), alphaCircleVectors.get(9)); } @@ -156,7 +154,8 @@ class IGPFamily { } void createInnerHexagon(){ - stroke(0.0, 0.0, 0.66, 0.4); + useStrokeColor(); + useFillColor(); beginShape(LINES); vertex(alphaCircleVectors.get(1).x, alphaCircleVectors.get(1).y); vertex(alphaCircleVectors.get(3).x, alphaCircleVectors.get(3).y); @@ -174,7 +173,8 @@ class IGPFamily { } void createInnerHexagonTilted(float angle){ - stroke(0.0, 0.0, 0.66, 0.4); + useStrokeColor(); + useFillColor(); translate(mid.x, mid.y); pushMatrix(); rotate(radians(angle)); @@ -197,12 +197,14 @@ class IGPFamily { } void createInnerTriangle(){ - stroke(0.0, 0.0, 0.66, 0.4); + useStrokeColor(); + useFillColor(); triangle(alphaCircleVectors.get(1).x, alphaCircleVectors.get(1).y, alphaCircleVectors.get(5).x, alphaCircleVectors.get(5).y, alphaCircleVectors.get(9).x, alphaCircleVectors.get(9).y); } void createInnerTriangleTilted(float angle){ - stroke(0.0, 0.0, 0.66, 0.4); + useStrokeColor(); + useFillColor(); translate(mid.x, mid.y); pushMatrix(); rotate(radians(angle)); @@ -253,7 +255,6 @@ class IGPFamily { } void displayConstructionLines() { - stroke(0.66, 0.66, 0.66, 0.4); createConstructionCircles(); createVerticalHorizontalConstructionLines(); } |