Advertisement
JoshuaDavis

scrubbing SVG and looking for colors

May 2nd, 2015
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. 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
  2.  
  3. // work around
  4.  
  5. static final color getPShapeFillColor(final PShape sh) {
  6.   try {
  7.     final java.lang.reflect.Field f =
  8.       PShape.class.getDeclaredField("fillColor");
  9.  
  10.     f.setAccessible(true);
  11.     return f.getInt(sh);
  12.   }
  13.  
  14.   catch (ReflectiveOperationException cause) {
  15.     throw new RuntimeException(cause);
  16.   }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement