Class ShadowUtils


  • public class ShadowUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ShadowUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int _nComputeTonalAmbientColor​(int ambientColor, int spotColor)  
      static int _nComputeTonalSpotColor​(int ambientColor, int spotColor)  
      static void _nDrawShadow​(long canvasPtr, long pathPtr, float zPlaneX, float zPlaneY, float zPlaneZ, float lightPosX, float lightPosY, float lightPosZ, float lightRadius, int ambientColor, int spotColor, int flags)  
      static int computeTonalAmbientColor​(int ambientColor, int spotColor)
      Helper routine to compute ambient color value for one-pass tonal alpha.
      static int computeTonalSpotColor​(int ambientColor, int spotColor)
      Helper routine to compute spot color value for one-pass tonal alpha.
      static void drawShadow​(@NotNull Canvas canvas, @NotNull Path path, @NotNull io.github.humbleui.types.Point3 zPlaneParams, @NotNull io.github.humbleui.types.Point3 lightPos, float lightRadius, int ambientColor, int spotColor, boolean transparentOccluder, boolean geometricOnly)
      Draw an offset spot shadow and outlining ambient shadow for the given path using a disc light.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowUtils

        public ShadowUtils()
    • Method Detail

      • drawShadow

        public static void drawShadow​(@NotNull
                                      @NotNull Canvas canvas,
                                      @NotNull
                                      @NotNull Path path,
                                      @NotNull
                                      @NotNull io.github.humbleui.types.Point3 zPlaneParams,
                                      @NotNull
                                      @NotNull io.github.humbleui.types.Point3 lightPos,
                                      float lightRadius,
                                      int ambientColor,
                                      int spotColor,
                                      boolean transparentOccluder,
                                      boolean geometricOnly)
        Draw an offset spot shadow and outlining ambient shadow for the given path using a disc light. The shadow may be cached, depending on the path type and canvas matrix. If the matrix is perspective or the path is volatile, it will not be cached.
        Parameters:
        canvas - The canvas on which to draw the shadows.
        path - The occluder used to generate the shadows.
        zPlaneParams - Values for the plane function which returns the Z offset of the occluder from the canvas based on local x and y values (the current matrix is not applied).
        lightPos - The 3D position of the light relative to the canvas plane. This is independent of the canvas's current matrix.
        lightRadius - The radius of the disc light.
        ambientColor - The color of the ambient shadow.
        spotColor - The color of the spot shadow.
        transparentOccluder - The occluding object is not opaque. Knowing that the occluder is opaque allows us to cull shadow geometry behind it and improve performance.
        geometricOnly - Don't try to use analytic shadows.
      • computeTonalAmbientColor

        public static int computeTonalAmbientColor​(int ambientColor,
                                                   int spotColor)
        Helper routine to compute ambient color value for one-pass tonal alpha.
        Parameters:
        ambientColor - Original ambient color
        spotColor - Original spot color
        Returns:
        Modified ambient color
      • computeTonalSpotColor

        public static int computeTonalSpotColor​(int ambientColor,
                                                int spotColor)
        Helper routine to compute spot color value for one-pass tonal alpha.
        Parameters:
        ambientColor - Original ambient color
        spotColor - Original spot color
        Returns:
        Modified spot color
      • _nDrawShadow

        @Internal
        public static void _nDrawShadow​(long canvasPtr,
                                        long pathPtr,
                                        float zPlaneX,
                                        float zPlaneY,
                                        float zPlaneZ,
                                        float lightPosX,
                                        float lightPosY,
                                        float lightPosZ,
                                        float lightRadius,
                                        int ambientColor,
                                        int spotColor,
                                        int flags)
      • _nComputeTonalAmbientColor

        @Internal
        public static int _nComputeTonalAmbientColor​(int ambientColor,
                                                     int spotColor)
      • _nComputeTonalSpotColor

        @Internal
        public static int _nComputeTonalSpotColor​(int ambientColor,
                                                  int spotColor)