Flutter Engine
The Flutter Engine
SkSVGFeLightSource.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
11
13 // Computing direction from azimuth+elevation is two 3D rotations:
14 // - Rotate [1,0,0] about y axis first (elevation)
15 // - Rotate result about z axis (azimuth)
16 // Which is just the first column vector in the 3x3 matrix Rz*Ry.
17 const float azimuthRad = SkDegreesToRadians(fAzimuth);
18 const float elevationRad = SkDegreesToRadians(fElevation);
19 const float sinAzimuth = sinf(azimuthRad), cosAzimuth = cosf(azimuthRad);
20 const float sinElevation = sinf(elevationRad), cosElevation = cosf(elevationRad);
21 return SkPoint3::Make(cosAzimuth * cosElevation, sinAzimuth * cosElevation, sinElevation);
22}
23
24bool SkSVGFeDistantLight::parseAndSetAttribute(const char* n, const char* v) {
26 this->setAzimuth(SkSVGAttributeParser::parse<SkSVGNumberType>("azimuth", n, v)) ||
27 this->setElevation(SkSVGAttributeParser::parse<SkSVGNumberType>("elevation", n, v));
28}
29
30bool SkSVGFePointLight::parseAndSetAttribute(const char* n, const char* v) {
32 this->setX(SkSVGAttributeParser::parse<SkSVGNumberType>("x", n, v)) ||
33 this->setY(SkSVGAttributeParser::parse<SkSVGNumberType>("y", n, v)) ||
34 this->setZ(SkSVGAttributeParser::parse<SkSVGNumberType>("z", n, v));
35}
36
37bool SkSVGFeSpotLight::parseAndSetAttribute(const char* n, const char* v) {
39 this->setX(SkSVGAttributeParser::parse<SkSVGNumberType>("x", n, v)) ||
40 this->setY(SkSVGAttributeParser::parse<SkSVGNumberType>("y", n, v)) ||
41 this->setZ(SkSVGAttributeParser::parse<SkSVGNumberType>("z", n, v)) ||
42 this->setPointsAtX(SkSVGAttributeParser::parse<SkSVGNumberType>("pointsAtX", n, v)) ||
43 this->setPointsAtY(SkSVGAttributeParser::parse<SkSVGNumberType>("pointsAtY", n, v)) ||
44 this->setPointsAtZ(SkSVGAttributeParser::parse<SkSVGNumberType>("pointsAtZ", n, v)) ||
45 this->setSpecularExponent(
46 SkSVGAttributeParser::parse<SkSVGNumberType>("specularExponent", n, v)) ||
47 this->setLimitingConeAngle(
48 SkSVGAttributeParser::parse<SkSVGNumberType>("limitingConeAngle", n, v));
49}
#define SkDegreesToRadians(degrees)
Definition: SkScalar.h:77
SkPoint3 computeDirection() const
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition: SkSVGNode.cpp:90
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
Definition: SkPoint3.h:18