Class RMDoubleStroke

  • All Implemented Interfaces:
    Archivable, RMPropertyChanger, java.lang.Cloneable

    public class RMDoubleStroke
    extends RMStroke
    Strokes a path with 2 lines of different widths, with an arbitrary separation (d) between them.

    This works by taking the input path and creating 'offset curves'. The offset curve is defined as being parallel to the original curve at every point.

    For a given parametric curve C(t)={x(t),y(t)}, the slope of the curve at t is given by mC(t)=(dy/dt) / (dx/dt) = y'(t)/x'(t) and the the normal is therefore NC(t)=Normalize({-x'(t), y'(t)})

    An offset curve for a cubic bezier can not be represented by a single bezier. Therefore, we need to find a set of n curves OffC0,OffC1,...OffCn that fits, as closely as possible, the following points: OffsetPoint(t)=C(t)+d*NC(t)

    One possibility is to calculate a million OffsetPoints for the range t->{0,1} and run the curve fit code.

    In order to preserve continuity of the different bezier segments, it should also be required that mOffC0(0) = mC(0) and mOffCn(1) = mC(1) That is, the slopes at the beginning and end of the curve should the same in the offset curve as it is in the original curve. Also, since the offset points are obtained by walking along the normal vector for the original curve, the slope of the offset curve at offsetpoint(t) should be the same as mC(t). The curve fit code does not currently take into account the slope of the curve at a given input point, but it's something to look into. Knowing this may provide enough additional information to speed up the curve fit and/or reduce the number of input points needed for an accurate fit.

    • Constructor Detail

      • RMDoubleStroke

        public RMDoubleStroke()
        Creates a new plain double stroke.
      • RMDoubleStroke

        public RMDoubleStroke​(RMColor col,
                              float w)
        Creates a new double stroke.
      • RMDoubleStroke

        public RMDoubleStroke​(RMColor col,
                              float outerW,
                              float innerW,
                              float separation,
                              int positions)
        Creates a new double stroke.
    • Method Detail

      • getRulePositions

        public int getRulePositions()
        Returns the double stroke rule positions.
      • setRulePositions

        public void setRulePositions​(int _rulePositions)
      • getInnerRuleWidth

        public float getInnerRuleWidth()
        Returns the inner rule width.
      • setInnerRuleWidth

        public void setInnerRuleWidth​(float _innerRuleWidth)
      • getOuterRuleWidth

        public float getOuterRuleWidth()
        Returns the outer rule width.
      • setOuterRuleWidth

        public void setOuterRuleWidth​(float _outerRuleWidth)
      • getOuterStroke

        public RMStroke getOuterStroke()
        Return the stroke used on the outside of a clockwise path
      • getInnerStroke

        public RMStroke getInnerStroke()
        Return the stroke used on the inside of a clockwise path
      • getRuleSeparation

        public float getRuleSeparation()
      • setRuleSeparation

        public void setRuleSeparation​(float _ruleSeparation)
      • getBounds

        public RMRect getBounds​(RMShape aShape)
        Returns the bounds required to render this fill for this shape.
        Overrides:
        getBounds in class RMStroke
      • equals

        public boolean equals​(java.lang.Object anObj)
        Standard equals implementation.
        Overrides:
        equals in class RMStroke