JoshuaDavis icon

scrubbing SVG and looking for colors

JoshuaDavis | PRO | 05/02/15 01:39:42 PM UTC | 0 ⭐ | 541 👁️ | Never ⏰ | []
Java |

570 B

|

None

|

0 👍

/

0 👎

if (tempChild.getFill(i) == -16777216) {} // throws an error, Adobe Illustrator provides no fill() element in the tree for any artwork containing black #000000 / -16777216, and because of this calling the getFill() method fails... SAD TROMBONE
 
// work around
 
static final color getPShapeFillColor(final PShape sh) {
  try {
    final java.lang.reflect.Field f = 
      PShape.class.getDeclaredField("fillColor");
 
    f.setAccessible(true);
    return f.getInt(sh);
  }
 
  catch (ReflectiveOperationException cause) {
    throw new RuntimeException(cause);
  }
}

Comments