Skip to content

Commit 743dca3

Browse files
committed
fix for #768
1 parent 449661f commit 743dca3

File tree

1 file changed

+5
-6
lines changed
  • src/main/java/com/marginallyclever/makelangelo/makeart/io

1 file changed

+5
-6
lines changed

src/main/java/com/marginallyclever/makelangelo/makeart/io/LoadSVG.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,16 @@ private Color stringToColor(String strokeName) {
306306
int a = Integer.parseInt(strokeName.substring(6,8),16);
307307
return new Color(r,g,b,a);
308308
}
309-
} else if(strokeName.startsWith("rgb(")) {
310-
// isolate the portion between the ()
309+
} else if(strokeName.startsWith("rgb(") && strokeName.endsWith(")")) {
310+
// isolate the portion between the parentheses
311311
strokeName = strokeName.substring(4,strokeName.length()-1);
312-
strokeName = strokeName.substring(0,strokeName.indexOf(")"));
313312
if(strokeName.contains("%")) {
314313
// convert from percent to 0-255
315314
strokeName = strokeName.replace("%","");
316315
String [] parts = strokeName.split(",");
317-
int r = (int)(Integer.parseInt(parts[0])*255.0/100.0);
318-
int g = (int)(Integer.parseInt(parts[1])*255.0/100.0);
319-
int b = (int)(Integer.parseInt(parts[2])*255.0/100.0);
316+
int r = Integer.parseInt(parts[0]) * 255 / 100;
317+
int g = Integer.parseInt(parts[1]) * 255 / 100;
318+
int b = Integer.parseInt(parts[2]) * 255 / 100;
320319
return new Color(r,g,b);
321320
} else {
322321
// already in 0-255

0 commit comments

Comments
 (0)