Skip to content

ShadowNodeEffect

class ShadowNodeEffect
Extends: NodeEffect<Node>
Package: dev.joid.lib.ui.node.effect.impl · Module: core · Source: ShadowNodeEffect.java

Draws a soft shadow of the shape of a node under it, or a glow when the color is light.

A dark grey rectangle casting a soft blue shadow below it

The shadow does not read the pixels of the node: it draws a rounded rectangle with the radius and the sides of the RoundedNodeEffect of the node, a disc for a CircleNode or a node with a CircleNodeEffect, and a plain rectangle otherwise. It is drawn before the node and its children, which cover it. Its priority is -50 (Control the order of effects).

ReturnsSignatureSummary
ShadowNodeEffectcreate(Color color, float blur) factoryCreates a shadow of this color and blur, in design pixels, centered under the node.
ShadowNodeEffectcreate(Supplier colorSupplier, Supplier blurSupplier) factoryCreates a shadow whose color and blur follow suppliers: signals, derived values or lambdas.
ShadowNodeEffect(Supplier colorSupplier, Supplier blurSupplier) protectedCalled by a subclass with the same arguments as create(Supplier,Supplier).

PropertyTypeDefaultSummary
blur signalfloatset at creationSoftness of the shadow, in design pixels: the distance over which it fades out around the shape.
color signalColorset at creationColor of the shadow where it is densest; its alpha sets the strength.
offsetX signaldouble0DHorizontal shift of the shadow, in design pixels; a positive value moves it to the right.
offsetY signaldouble0DVertical shift of the shadow, in design pixels; a positive value moves it down.
Inherited from NodeEffect (2)

priority · scope

ReturnsSignatureSummary
voiddraw(Node node, Runnable body)Draws the shadow, then the node.
Inherited from NodeEffect (4)

shouldApply · toShaderPass · toShaderPasses · copy

ShadowNodeEffect create(Color color, float blur) factory

Creates a shadow of this color and blur, in design pixels, centered under the node.

ShadowNodeEffect create(Supplier<Color> colorSupplier, Supplier<Float> blurSupplier) factory

Creates a shadow whose color and blur follow suppliers: signals, derived values or lambdas.

ShadowNodeEffect(Supplier<Color> colorSupplier, Supplier<Float> blurSupplier) protected

Called by a subclass with the same arguments as create(Supplier,Supplier).

  • this blur(float blur) fluent
  • this blur(Supplier<Float> blurSupplier) fluent signal
  • float getBlur()

Default: set at creation

Softness of the shadow, in design pixels: the distance over which it fades out around the shape.

  • this color(Color color) fluent
  • this color(Supplier<Color> colorSupplier) fluent signal
  • Color getColor()

Default: set at creation

Color of the shadow where it is densest; its alpha sets the strength.

  • this offsetX(double offsetX) fluent
  • this offsetX(Supplier<Double> offsetXSupplier) fluent signal
  • double getOffsetX()

Default: 0D

Horizontal shift of the shadow, in design pixels; a positive value moves it to the right.

  • this offsetY(double offsetY) fluent
  • this offsetY(Supplier<Double> offsetYSupplier) fluent signal
  • double getOffsetY()

Default: 0D

Vertical shift of the shadow, in design pixels; a positive value moves it down.

void draw(Node node, Runnable body)

Draws the shadow, then the node.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page