diff --git a/candy/src/processing/candy/SVG.java b/candy/src/processing/candy/SVG.java index 1b80f2fbb..1c7d05117 100755 --- a/candy/src/processing/candy/SVG.java +++ b/candy/src/processing/candy/SVG.java @@ -126,6 +126,9 @@ import processing.xml.*; *
  • Patterns *
  • Embedded images * + * + * For those interested, the SVG specification can be found + * here. */ public class SVG { @@ -458,6 +461,8 @@ public class SVG { boolean stroke = parent.g.stroke; int strokeColor = parent.g.strokeColor; float strokeWeight = parent.g.strokeWeight; + int strokeCap = parent.g.strokeCap; + int strokeJoin= parent.g.strokeJoin; boolean fill = parent.g.fill; int fillColor = parent.g.fillColor; @@ -469,6 +474,8 @@ public class SVG { parent.g.stroke = stroke; parent.g.strokeColor = strokeColor; parent.g.strokeWeight = strokeWeight; + parent.g.strokeCap = strokeCap; + parent.g.strokeJoin = strokeJoin; parent.g.fill = fill; parent.g.fillColor = fillColor; @@ -525,6 +532,8 @@ public class SVG { boolean stroke; int strokeColor; float strokeWeight; // default is 1 + int strokeCap; + int strokeJoin; Gradient strokeGradient; Paint strokeGradientPaint; String strokeName; // id of another object, gradients only? @@ -548,6 +557,8 @@ public class SVG { stroke = false; strokeColor = 0xff000000; strokeWeight = 1; + strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec + strokeJoin = PConstants.MITER; strokeGradient = null; strokeGradientPaint = null; strokeName = null; @@ -567,6 +578,8 @@ public class SVG { stroke = parent.stroke; strokeColor = parent.strokeColor; strokeWeight = parent.strokeWeight; + strokeCap = parent.strokeCap; + strokeJoin = parent.strokeJoin; strokeGradient = parent.strokeGradient; strokeGradientPaint = parent.strokeGradientPaint; strokeName = parent.strokeName; @@ -674,9 +687,43 @@ public class SVG { } if (properties.hasAttribute("stroke-width")) { - strokeWeight = properties.getFloatAttribute("stroke-width"); + // if NaN (i.e. if it's 'inherit') then default back to the inherit setting + strokeWeight = properties.getFloatAttribute("stroke-width", strokeWeight); } + if (properties.hasAttribute("stroke-linejoin")) { + String linejoin = properties.getStringAttribute("stroke-linejoin"); + if (linejoin.equals("inherit")) { + // do nothing, will inherit automatically + + } else if (linejoin.equals("miter")) { + strokeJoin = PConstants.MITER; + + } else if (linejoin.equals("round")) { + strokeJoin = PConstants.ROUND; + + } else if (linejoin.equals("bevel")) { + strokeJoin = PConstants.BEVEL; + } + } + + if (properties.hasAttribute("stroke-linecap")) { + String linecap = properties.getStringAttribute("stroke-linecap"); + if (linecap.equals("inherit")) { + // do nothing, will inherit automatically + + } else if (linecap.equals("butt")) { + strokeCap = PConstants.SQUARE; + + } else if (linecap.equals("round")) { + strokeCap = PConstants.ROUND; + + } else if (linecap.equals("square")) { + strokeCap = PConstants.PROJECT; + } + } + + // fill defaults to black (though stroke defaults to "none") // http://www.w3.org/TR/SVG/painting.html#FillProperties if (properties.hasAttribute("fill")) { @@ -804,6 +851,8 @@ public class SVG { if (stroke) { parent.stroke(strokeColor); parent.strokeWeight(strokeWeight); + parent.strokeCap(strokeCap); + parent.strokeJoin(strokeJoin); } else { parent.noStroke(); } diff --git a/core/src/processing/core/PConstants.java b/core/src/processing/core/PConstants.java index 4946d600b..a191aac0b 100644 --- a/core/src/processing/core/PConstants.java +++ b/core/src/processing/core/PConstants.java @@ -237,9 +237,9 @@ public interface PConstants { // stroke modes - static final int SQUARE = 1 << 0; + static final int SQUARE = 1 << 0; // called 'butt' in the svg spec static final int ROUND = 1 << 1; - static final int PROJECT = 1 << 2; + static final int PROJECT = 1 << 2; // called 'square' in the svg spec static final int MITER = 1 << 3; static final int BEVEL = 1 << 5; diff --git a/core/src/processing/core/PImage.java b/core/src/processing/core/PImage.java index 0b8816e35..70869540e 100644 --- a/core/src/processing/core/PImage.java +++ b/core/src/processing/core/PImage.java @@ -504,6 +504,7 @@ public class PImage implements PConstants, Cloneable { int col = 255 - pixels[i]; pixels[i] = 0xff000000 | (col << 16) | (col << 8) | col; } + format = RGB; } else { // Converts RGB image data into grayscale using diff --git a/core/todo.txt b/core/todo.txt index 81971272e..1c7a534ea 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -42,6 +42,7 @@ X remove print(array) since it's silly? [0] "potato" [1] "tomato" [2] "apple" +X fix filter(GRAY) on an ALPHA image to produce a good RGB image 0125p2 X updatePixels ref is wrong diff --git a/todo.txt b/todo.txt index 772faebd1..0cdbf50d5 100644 --- a/todo.txt +++ b/todo.txt @@ -20,10 +20,41 @@ X preprocessor cannot handle L or l added to 'long' values X http://dev.processing.org/bugs/show_bug.cgi?id=492 X change constructors for Capture, also framerate to frameRate _ need to update reference +X re-architect svg to properly inherit fill/stroke/etc from parents +X object can specify fill/stroke for everyone below +X need to discern between having a fill specified and one not being present + +_ java.extension.dirs has the library/extn stuff +_ can probably set this blank +_ the jar from which a class file has been loaded +_ getClass().getProtectionDomain().getCodeSource().getLocation().getFile() + +_ don't allow for (blah; blah; blah) ; +_ or if (blah blah blah) ; +_ it's never useful. students can use { } if they want an empty block + +_ "one file added to sketch" should be more descriptive +_ Added "blah.jpg" to the data folder of the sketch +_ cmd-w doesn't close window of opened applet (running inside p5) +_ ESC won't cancel rename +_ rename location is awkward, do it on the tab? +_ map() is not colored, neither is norm +_ pdf examples are shot + +_ change pde files to use utf8 +_ 1) if file contains binary data and +_ 2) its mod date is earlier than when p5 0125 was installed +_ offer to convert it, or ignore +_ then re-save the file to update the mod date +_ ...or, when first running p5 0125, offer to update sketches _ the first time someone hides a tab, put up a msg explaining what it does +_ "don't warn me about this anymore" +_ add "don't warn me about this" for sketch renaming +_ make sure renamed version doesn't exist already _ archive sketch shouldn't include applet or application dirs +_ or should it? this was how projects were being uploaded for class... _ add to mac reference for present mode _ can make full screen work via Info.plist key