Class CharcoalEffect



  • public class CharcoalEffect
    extends Object
    This applies a charcoal effect to a shape. This basically takes a shape and applies several "cracks" of varying depth at a fixed angle. (The implementation is pretty simple, and there are a few interesting code snippets commented out that change how this renders.)
    • Field Detail

      • seed

        public final int seed
      • size

        public final float size
      • angle

        public final float angle
      • maxDepth

        public final float maxDepth
    • Constructor Detail

      • CharcoalEffect

        public CharcoalEffect(PathWriter dest,
                              float size,
                              float angle,
                              int randomSeed)
        Creates a new CharcoalEffect.
        Parameters:
        dest - the destination to write the new shape to.
        size - the size of the cracks. This is float from [0,1], where "0" means "no crack depth" and "1" means "high depth". The depth is always relative to the possible depth.
        angle - the angle of the cracks.
        randomSeed - the random seed.
      • CharcoalEffect

        public CharcoalEffect(PathWriter dest,
                              float size,
                              float angle,
                              int randomSeed,
                              float maxDepth)
        Creates a new CharcoalEffect.
        Parameters:
        dest - the destination to write the new shape to.
        size - the size of the cracks. This is float from [0,1], where "0" means "no crack depth" and "1" means "high depth". The depth is always relative to the possible depth.
        angle - the angle of the cracks.
        randomSeed - the random seed.
        maxDepth - this is the maximum crack depth. If this is zero, then no cracks will be added. If this is 5, then cracks will be at most 5 pixels. If you aren't sure what to make this value, use Float.MAX_VALUE.
    • Method Detail

      • filter

        public static GeneralPath filter(Shape shape,
                                         float size,
                                         float angle,
                                         int randomSeed,
                                         float maxDepth)
        Applies the CharcoalEffect to a shape.
        Parameters:
        shape - the shape to apply the effect to.
        size - the size of the cracks. This is float from [0,1], where "0" means "no crack depth" and "1" means "high depth". The depth is always relative to the possible depth.
        angle - the angle of the cracks.
        randomSeed - the random seed.
        maxDepth - this is the maximum crack depth. If this is zero, then no cracks will be added. If this is 5, then cracks will be at most 5 pixels. If you aren't sure what to make this value, use Float.MAX_VALUE.
        Returns:
        a new filtered path.
      • filter

        public static GeneralPath filter(Shape shape,
                                         float size,
                                         float angle,
                                         int randomSeed)
        Applies the CharcoalEffect to a shape.
        Parameters:
        shape - the shape to apply the effect to.
        size - the size of the cracks. This is float from [0,1], where "0" means "no crack depth" and "1" means "high depth". The depth is always relative to the possible depth.
        angle - the angle of the cracks.
        randomSeed - the random seed.
        Returns:
        a new filtered path.
      • write

        public void write(Shape s)
        Applies this effect to the shape provided.
        Parameters:
        s - the shape to write.