Class DistantLight
- Namespace
- Egami.Operations
- Assembly
- Egami.dll
A light infinitely far away, shining from one direction on every pixel, as SVG's feDistantLight. The direction toward the light is (cos Azimuth · cos Elevation, sin Azimuth · cos Elevation, sin Elevation) in the raster's coordinates (y down), which is the vector Skia's DistantLit factories take.
public sealed record DistantLight : Light, IEquatable<Light>, IEquatable<DistantLight>
- Inheritance
-
DistantLight
- Implements
- Inherited Members
Examples
// Three light sources, as SVG and Skia have them. Positions are pixels: x right, y down, z up out of the image.
Light sun = new DistantLight(azimuth: 225, elevation: 40); // from the top left, 40° up
Light bulb = new PointLight(new Vector3(60, 20, 80)) { Color = new Rgba8(255, 240, 210, 255) };
Light spot = new SpotLight(new Vector3(0, 0, 150), target: new Vector3(120, 60, 0), exponent: 4, coneAngle: 30);
// Two ways a surface reflects: matte (N·L) or shiny (a highlight, (N·H)^shininess).
LightingModel matte = LightingModel.Diffuse(kd: 1.2f);
LightingModel shiny = LightingModel.Specular(ks: 1, shininess: 20);
using Raster<Rgba8> map = logo.Derive(ops => ops.Lighting(sun, matte), Ct); // the light map, opaque
using Raster<Rgba8> glints = logo.Derive(ops => ops.Lighting(bulb, shiny), Ct); // alpha = brightest channel
using Raster<Rgba8> pool = logo.Derive(ops => ops.Lighting(spot, matte), Ct);
Constructors
DistantLight(float, float)
Initializes a new instance of the DistantLight class.
public DistantLight(float azimuth, float elevation)
Parameters
azimuthfloatThe direction of the light in the image plane, in degrees clockwise from the x axis (y points down), as SVG's azimuth.
elevationfloatThe angle of the light above the image plane, in degrees, from −90 to 90; 90 shines straight down.
Exceptions
- ArgumentOutOfRangeException
azimuthis not finite, orelevationis not from −90 to 90.
Properties
Azimuth
Gets the direction of the light in the image plane, in degrees clockwise from the x axis (y points down).
public float Azimuth { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not finite.
Elevation
Gets the angle of the light above the image plane, in degrees.
public float Elevation { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not from −90 to 90.