Class StrokeRec

java.lang.Object
icyllis.arc3d.sketch.StrokeRec

public class StrokeRec extends Object
This class collects stroke params from paint and constructs new paths by stroking geometries.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    A fill style.
    Create from paint, assuming resScale = 1.
    StrokeRec(Paint paint, float resScale)
    Create from paint.
    StrokeRec(Paint paint, int style, float width)
    Create from paint with overrides, assuming resScale = 1.
    StrokeRec(Paint paint, int style, float width, float resScale)
    Create from paint with overrides.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Apply these stroke parameters to a paint.
    boolean
    Apply these stroke parameters to the src path, emitting the result to dst.
    int
     
    int
     
    float
    Gives a conservative value for the outset that should be applied to a geometries bounds to account for any inflation due to applying this stroke to the geometry.
    static float
    getInflationRadius(float strokeWidth, int cap, int join, int align, float miterLimit)
     
    int
     
    float
     
    float
    ResScale is the "intended" resolution for the output.
    Default is 1.0.
    Larger values (res > 1) indicate that the result should be more precise, since it will be zoomed up, and small errors will be magnified.
    Smaller values (0 invalid input: '<' res invalid input: '<' 1) indicate that the result can be less precise, since it will be zoomed down, and small errors may be invisible.
    int
     
    float
     
    boolean
    Compare if two Strokes have an equal effect on a path.
    void
    init(Paint paint, int style, float width, float resScale)
     
    boolean
     
    boolean
     
    boolean
    Returns true if this represents any thick stroking, i.e.
    void
    setAlign(int align)
     
    void
    setCap(int cap)
     
    void
     
    void
     
    void
    setJoin(int join)
     
    void
    setMiterLimit(float miterLimit)
     
    void
    setResScale(float resScale)
     
    void
    setStrokeParams(int cap, int join, int align, float miterLimit)
     
    void
    setStrokeStyle(float width, boolean strokeAndFill)
    Specify the strokewidth, and optionally if you want stroke + fill.
    void
    setWidth(float width)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • StrokeRec

      public StrokeRec()
      A fill style.
    • StrokeRec

      public StrokeRec(Paint paint)
      Create from paint, assuming resScale = 1.
    • StrokeRec

      public StrokeRec(Paint paint, float resScale)
      Create from paint.
    • StrokeRec

      public StrokeRec(Paint paint, int style, float width)
      Create from paint with overrides, assuming resScale = 1.
    • StrokeRec

      public StrokeRec(Paint paint, int style, float width, float resScale)
      Create from paint with overrides.
  • Method Details

    • init

      public void init(Paint paint, int style, float width, float resScale)
    • getStyle

      public int getStyle()
    • isFillStyle

      public boolean isFillStyle()
    • isHairlineStyle

      public boolean isHairlineStyle()
    • isStrokeStyle

      public boolean isStrokeStyle()
      Returns true if this represents any thick stroking, i.e. applyToPath() will return true.
    • setFillStyle

      public void setFillStyle()
    • setHairlineStyle

      public void setHairlineStyle()
    • setStrokeStyle

      public void setStrokeStyle(float width, boolean strokeAndFill)
      Specify the strokewidth, and optionally if you want stroke + fill. Note, if width==0, then this request is taken to mean:
      strokeAndFill==true new style will be Fill
      strokeAndFill==false new style will be Hairline
    • getWidth

      public float getWidth()
    • setWidth

      public void setWidth(float width)
    • getCap

      public int getCap()
    • getJoin

      public int getJoin()
    • getAlign

      public int getAlign()
    • getMiterLimit

      public float getMiterLimit()
    • setCap

      public void setCap(int cap)
    • setJoin

      public void setJoin(int join)
    • setAlign

      public void setAlign(int align)
    • setMiterLimit

      public void setMiterLimit(float miterLimit)
    • setStrokeParams

      public void setStrokeParams(int cap, int join, int align, float miterLimit)
    • getResScale

      public float getResScale()
      ResScale is the "intended" resolution for the output.
      Default is 1.0.
      Larger values (res > 1) indicate that the result should be more precise, since it will be zoomed up, and small errors will be magnified.
      Smaller values (0 invalid input: '<' res invalid input: '<' 1) indicate that the result can be less precise, since it will be zoomed down, and small errors may be invisible.
    • setResScale

      public void setResScale(float resScale)
    • applyToPath

      public boolean applyToPath(Shape src, PathConsumer dst)
      Apply these stroke parameters to the src path, emitting the result to dst.

      If there was no change (i.e. style == hairline or fill) this returns false and dst is unchanged. Otherwise returns true and the result is emitted to dst.

      src and dst must NOT come from the same object.

    • applyToPaint

      public void applyToPaint(Paint paint)
      Apply these stroke parameters to a paint.
    • getInflationRadius

      public float getInflationRadius()
      Gives a conservative value for the outset that should be applied to a geometries bounds to account for any inflation due to applying this stroke to the geometry.
    • hasSameEffect

      public boolean hasSameEffect(StrokeRec other)
      Compare if two Strokes have an equal effect on a path. Equal Strokes produce equal paths. Equality of produced paths does not take the ResScale parameter into account.
    • getInflationRadius

      public static float getInflationRadius(float strokeWidth, int cap, int join, int align, float miterLimit)