Package swingtree.api

Interface ShadowFractionsSupplier

All Known Implementing Classes:
UI.ShadowType
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@Immutable @FunctionalInterface public interface ShadowFractionsSupplier
A shadow fractions supplier is used to render ShadowConf styles by supplying the shape of a shadow's "falloff curve", that is to say, the way in which the shadow color fades from its full strength into full transparency across the blur region.

It supplies a Tuple of float values, the falloff fractions, which are the shadow intensities (1 = full shadow color, 0 = fully transparent) sampled at evenly spaced positions t = i / n for i in [0, n], where n is one less than the size of the returned tuple. The first fraction therefore describes the intensity at the solid edge of the shadow (typically 1) and the last one the intensity at the far, transparent end of the blur (typically 0). The number of supplied fractions also determines how finely the curve is sampled: smooth curves need only a few fractions, while stepped or oscillating curves need many more to stay crisp.

A gradient is built from at least two color stops, so the returned tuple must contain at least two fractions. The renderer treats a smaller tuple as a configuration error and defensively falls back to a plain linear falloff ([1, 0]) rather than failing.

Please take a look at UI.ShadowType for a rich set of predefined shadow falloff implementations.
There you will most likely find a shadow type that fits your needs.

  • Method Summary

    Modifier and Type
    Method
    Description
    sprouts.Tuple<Float>
    Supplies the shadow falloff fractions, that is the shadow intensities (1 = full shadow color, 0 = fully transparent) sampled at evenly spaced positions t = i / n away from the solid edge of the shadow, where n is one less than the size of the returned tuple.
  • Method Details

    • getFractions

      sprouts.Tuple<Float> getFractions()
      Supplies the shadow falloff fractions, that is the shadow intensities (1 = full shadow color, 0 = fully transparent) sampled at evenly spaced positions t = i / n away from the solid edge of the shadow, where n is one less than the size of the returned tuple.
      Returns:
      A Tuple of at least two falloff fractions, ordered from the solid edge of the shadow (t = 0) to the far, transparent end of the blur (t = 1).