From bf6975a8d70807154a242f46df76747500f932ed Mon Sep 17 00:00:00 2001 From: DonoG Date: Thu, 29 Nov 2018 00:31:24 +1100 Subject: [PATCH] Update HPath.java Allow HColorPool for gradients to be applied either randomly, or based on HColorPool order.. --- src/main/java/hype/HPath.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/hype/HPath.java b/src/main/java/hype/HPath.java index f07d059d..aa6f0646 100644 --- a/src/main/java/hype/HPath.java +++ b/src/main/java/hype/HPath.java @@ -20,6 +20,7 @@ public class HPath extends HDrawable { private ArrayList vertexColors; private int mode; private boolean drawsHandles; + private boolean orderedPool = false; public HPath() { this(PConstants.PATH); @@ -36,6 +37,11 @@ public HPath vertexColors(HColorist clr) { return this; } + public HPath vertexOrder(boolean b) { + orderedPool = b; + return this; + } + public HPath texture(Object imgArg) { texture = H.getImage(imgArg); return this; @@ -48,6 +54,7 @@ public HPath createCopy() { copy.drawsHandles = drawsHandles; copy.vertexColor = vertexColor; copy.texture = texture; + copy.orderedPool = orderedPool; for (int i = 0; i < numVertices(); ++i) { copy.vertices.add(vertex(i).createCopy(copy)); if (vertexColors.size() > 0) { @@ -345,8 +352,16 @@ public void draw(PGraphics g, boolean usesZ, if (vertexColor instanceof HColorPool) { HColorPool c = (HColorPool) vertexColor; + if (vertexColors.size() <= numv) { - vertexColors.add(c.getColor()); + + if(orderedPool == false) { + vertexColors.add(c.getColor()); + } + else { + vertexColors.add(c.getColorAt(i%c.size())); + } + } v.vertexPoolColor = vertexColors.get(i); }