Class CharcoalStroke

  • All Implemented Interfaces:
    FilteredStroke, Stroke


    public class CharcoalStroke
    extends Object
    implements FilteredStroke
    This applies the CharcoalEffect to another Stroke. By default this is built on top of a BasicStroke, but you can use any other relatively simple stroke. The nature of the charcoal effect requires continuous areas of at least 2 pixels to really be visible.

    It is not recommended to layer a CharcoalStroke on top of another CharcoalStroke, because they are very complex.

    • Constructor Detail

      • CharcoalStroke

        public CharcoalStroke(float width,
                              float crackSize,
                              float angle)
        Create a new CharcoalStroke built on top of a BasicStroke.
        Parameters:
        width - the width of the BasicStroke.
        crackSize - a value from 0-1 indicating how deep the crack should be.
        angle - the angle, in radians.
      • CharcoalStroke

        public CharcoalStroke(Stroke s,
                              float crackSize,
                              float angle,
                              int randomSeed)
        Create a new CharcoalStroke built on top of another Stroke.
        Parameters:
        s - the stroke to apply the charcoal effect to.
        crackSize - a value from 0-1 indicating how deep the crack should be.
        angle - the angle, in radians.
        randomSeed - the random seed to use.
      • CharcoalStroke

        public CharcoalStroke(float width,
                              float crackSize)
        This creates a CharcoalStroke on top of a simple BasicStroke, with a fixed angle of 45 degrees.
        Parameters:
        width - the width of the BasicStroke
        crackSize - a value from 0-1 indicating how deep the crack should be.
    • Method Detail

      • getRandomSeed

        public int getRandomSeed()
        Returns:
        the random seed this object uses.
      • getAngle

        public float getAngle()
        Returns:
        the angle (in radians) this effect uses.
      • deriveStroke

        public CharcoalStroke deriveStroke(float cracks)
        Creates a similar stroke where only the crack depth (0-1) is redefined.
        Parameters:
        cracks - the new crack depth.
        Returns:
        a new stroke.
      • deriveStroke

        public FilteredStroke deriveStroke(Stroke newStroke)
        Creates a similar stroke where the underlying stroke is redefined.
        Specified by:
        deriveStroke in interface  FilteredStroke
        Parameters:
        newStroke - the new underlying Stroke. This could be a BasicShape, or your own stroke. It is not recommended to layer a CharcoalStroke on top of another CharcoalStroke, because they are very complex.
        Returns:
        a new stroke that is built on top of s
      • createStrokedShape

        public Shape createStrokedShape(Shape p)
      • getStroke

        public Stroke getStroke()
        Returns the underlying stroke this CharcoalStroke is layered on top of.
        Specified by:
        getStroke in interface  FilteredStroke
        Returns:
        the underlying stroke being filtered.
      • getCrackSize

        public float getCrackSize()
        Returns the crack size. This is a float from 0 to 1 indicating how deep the cracks in this effect run.
        Returns:
        the crack size, as a float from [0, 1].