33 bool fIgnoreShadowAlpha;
42 , fIgnoreShadowAlpha(
false) {
43 fName =
"ShadowUtils";
59 fConcavePaths.
back().
lineTo(28.867f, -16.6667f);
61 fConcavePaths.
back().
lineTo(28.867f, 16.6667f);
65 fConcavePaths.
back().
lineTo(-28.867f, 16.6667f);
67 fConcavePaths.
back().
lineTo(-28.867f, -16.6667f);
68 fConcavePaths.
back().
lineTo(-9.62f, -16.6667f);
73 fConcavePaths.
back().
cubicTo(100, 25, 60, 50, 50, 0);
74 fConcavePaths.
back().
cubicTo(0, -25, 40, -50, 50, 0);
81 fShowAmbient = !fShowAmbient;
85 fShowSpot = !fShowSpot;
93 fShowObject = !fShowObject;
105 fIgnoreShadowAlpha = !fIgnoreShadowAlpha;
118 this->drawBG(canvas);
120 static constexpr int kW = 800;
122 static constexpr SkScalar kLightR = 100.f;
124 static constexpr SkScalar kAmbientAlpha = 0.5f;
125 static constexpr SkScalar kSpotAlpha = 0.5f;
126 static constexpr SkPoint3 lightPos = { 250, 400, 500 };
133 matrices.
append()->reset();
134 matrices.
append()->setRotate(33.f, 25.f, 25.f).postScale(1.2f, 0.8f, 25.f, 25.f);
141 for (
auto&
m : matrices) {
143 for (
const auto&
path : fConvexPaths) {
145 m.mapRect(&postMBounds);
158 this->drawShadowedPath(canvas,
path, zPlaneParams, greenPaint, kAmbientAlpha,
159 lightPos, kLightR, kSpotAlpha,
flags);
175 for (
auto&
m : matrices) {
176 for (
const auto&
path : fConcavePaths) {
178 m.mapRect(&postMBounds);
184 this->drawShadowedPath(canvas,
path, zPlaneParams, greenPaint, kAmbientAlpha,
196 if (invCanvasM.
invert(&invCanvasM)) {
198 canvas->
concat(invCanvasM);
202 canvas->
drawCircle(lightPos.
fX, lightPos.
fY, kLightR / 10.f, blackPaint);
217 if (fIgnoreShadowAlpha) {
234 lightPos, lightWidth,
235 ambientColor, spotColor,
flags);
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
@ kGeometricOnly_ShadowFlag
@ kTransparentOccluder_ShadowFlag
void draw(SkCanvas *canvas) override
void load(SkScalar w, SkScalar h) override
bool onChar(SkUnichar uni) override
void translate(SkScalar dx, SkScalar dy)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
SkMatrix getTotalMatrix() const
void drawPath(const SkPath &path, const SkPaint &paint)
void concat(const SkMatrix &matrix)
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
bool invert(SkMatrix *inverse) const
void setStyle(Style style)
void setColor(SkColor color)
void setAntiAlias(bool aa)
@ kStroke_Style
set to stroke geometry
SkPath & addCircle(SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
SkPath & moveTo(SkScalar x, SkScalar y)
SkPath & lineTo(SkScalar x, SkScalar y)
SkPath & addRRect(const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
SkPath & addRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, SkPathDirection dir=SkPathDirection::kCW)
SkPath & addOval(const SkRect &oval, SkPathDirection dir=SkPathDirection::kCW)
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
void setNinePatch(const SkRect &rect, SkScalar leftRad, SkScalar topRad, SkScalar rightRad, SkScalar bottomRad)
static void DrawShadow(SkCanvas *canvas, const SkPath &path, const SkPoint3 &zPlaneParams, const SkPoint3 &lightPos, SkScalar lightRadius, SkColor ambientColor, SkColor spotColor, uint32_t flags=SkShadowFlags::kNone_ShadowFlag)
FlutterSemanticsFlag flags
static float max(float r, float g, float b)
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
constexpr float height() const
constexpr float width() const
static constexpr SkRect MakeWH(float w, float h)