コード例 #1
0
 public DiffuseLightingGenerator(Color lightColor, IFilterLight light, decimal diffuseConstant, decimal surfaceScale)
 {
     this.LightColor      = lightColor;
     this.Light           = light;
     this.DiffuseConstant = diffuseConstant;
     this.SurfaceScale    = surfaceScale;
 }
コード例 #2
0
 public SpecularLightingGenerator(
     Color lightColor,
     decimal specularConstant,
     decimal surfaceScale,
     decimal brightnessScale,
     decimal specularExponent,
     IFilterLight light)
 {
     LightColor       = lightColor;
     SpecularConstant = specularConstant;
     SurfaceScale     = surfaceScale;
     BrightnessScale  = brightnessScale;
     Light            = light;
     SpecularExponent = specularExponent;
 }
コード例 #3
0
        private static XElement BuildLightComponent(IFilterLight filterLight, CoordinatesConverter coordinatesConverter)
        {
            if (filterLight is Spotlight spotlight)
            {
                SvgCoordinate3d startPosition = spotlight.LightSource.Pipe(coordinatesConverter.ToSvgCoord);
                SvgCoordinate3d endPosition   = spotlight.LightDestination.Pipe(coordinatesConverter.ToSvgCoord);

                return
                    (XElementBuilder.WithName("feSpotLight")
                     .Add(
                         new XAttribute("x", startPosition.X),
                         new XAttribute("y", startPosition.Y),
                         new XAttribute("z", startPosition.Z),
                         new XAttribute("pointsAtX", endPosition.X),
                         new XAttribute("pointsAtY", endPosition.Y),
                         new XAttribute("pointsAtZ", endPosition.Z),
                         new XAttribute("specularExponent", spotlight.SpecularExponent),
                         new XAttribute("limitingConeAngle", spotlight.ConeAngle.Degrees)
                         )
                     .Build());
            }
            if (filterLight is DistantLight distantLight)
            {
                return(XElementBuilder.WithName("feDistantLight")
                       .Add(
                           new XAttribute("azimuth", distantLight.Azimuth.Degrees),
                           new XAttribute("elevation", distantLight.Elevation.Degrees))
                       .Build());
            }
            if (filterLight is PointLight pointLight)
            {
                var coordinate = coordinatesConverter.ToSvgCoord(pointLight.Coordinate);
                return(XElementBuilder.WithName("fePointLight").Add(
                           new XAttribute("x", coordinate.X),
                           new XAttribute("y", coordinate.Y),
                           new XAttribute("z", coordinate.Z))
                       .Build());
            }

            throw new Exception($"unable to generate a light source from type '{filterLight}'");
        }