Skip to content

Commit 9763b55

Browse files
committed
more general version of icon making
1 parent 96f65d4 commit 9763b55

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

app/src/processing/app/ui/Toolkit.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,18 @@ static public void setIcon(Window window) {
689689
* @param size size in pixels (handling for 2x done automatically)
690690
*/
691691
static public ImageIcon renderIcon(String name, String color, int size) {
692-
Image image = renderMonoImage(name, color, size);
692+
return renderIcon(Platform.getContentFile("lib/" + name + ".svg"), color, size);
693+
}
694+
695+
696+
/**
697+
* Create an Icon object from an SVG path name.
698+
* @param file full path to icon
699+
* @param color color to apply to the monochrome icon
700+
* @param size size in pixels (handling for 2x done automatically)
701+
*/
702+
static public ImageIcon renderIcon(File file, String color, int size) {
703+
Image image = renderMonoImage(file, color, size);
693704
if (image == null) {
694705
return null;
695706
}
@@ -718,16 +729,10 @@ public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
718729
}
719730

720731

721-
static protected Image renderMonoImage(String name, String color, int size) {
722-
File file = Platform.getContentFile("lib/" + name + ".svg");
732+
static protected Image renderMonoImage(File file, String color, int size) {
723733
String xmlOrig = Util.loadFile(file);
724734

725735
if (xmlOrig != null) {
726-
/*
727-
final String REPLACE_COLOR = "#9B9B9B";
728-
String xmlStr = xmlOrig.replace(REPLACE_COLOR, color);
729-
return Toolkit.svgToImageMult(xmlStr, size, size);
730-
*/
731736
StringDict replace = new StringDict(new String[][] {
732737
{ "#9B9B9B", color }
733738
});
@@ -737,9 +742,11 @@ static protected Image renderMonoImage(String name, String color, int size) {
737742
}
738743

739744

745+
/*
740746
static private Image svgToImageMult(String xmlStr, int wide, int high) {
741747
return svgToImage(xmlStr, highResMultiply(wide), highResMultiply(high));
742748
}
749+
*/
743750

744751

745752
static public Image svgToImageMult(String xmlStr, int wide, int high, StringDict replacements) {

0 commit comments

Comments
 (0)