Class Light
- Namespace
- Egami.Operations
- Assembly
- Egami.dll
A light for Lighting(Light, LightingModel, LightingOptions?): DistantLight, PointLight or SpotLight, the three light sources of the SVG 1.1 lighting filters (feDistantLight, fePointLight and feSpotLight), with Skia's parameters. Positions are in pixels of the raster, x to the right, y down and z up out of the image; a pixel's center is at (x + 0.5, y + 0.5), as in Skia.
public abstract record Light : IEquatable<Light>
- Inheritance
-
Light
- Implements
- Derived
- 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);
Properties
Color
Gets the light's color; alpha is ignored. Defaults to white. The color is used as stored, not converted to linear light.
public Rgba8 Color { get; init; }