60 return {axis * (1.0f /
length), std::acos(u.
dot(v))};
62 return {{0, 0, 0}, 0};
79 m.setRow(3, {0, 0, 0, 1});
80 m.setCol(3, {0, 0, 0, 1});
102 canvas->
concat(viewport * perspective * camera *
inv(viewport));
125 if (!
m.invert(&m2)) {
134 return m2.
rc(2,2) > 0;
161 paint.setAntiAlias(
true);
172 SkV3 fAxis = {0, 0, 0};
174 fPrevAngle = 1234567;
181 inline static constexpr double kSlowDown = 4;
182 inline static constexpr SkScalar kMaxSpeed = 16;
186 if (angle != fPrevAngle) {
198 if (fAngleSpeed > 0) {
200 double dtime = now - fPrevNow;
202 double delta = fAngleSign * fAngleSpeed * dtime;
204 fAngleSpeed -= kSlowDown * dtime;
205 if (fAngleSpeed < 0) {
214 if (fPrevNow != fNow) {
215 fAngleSpeed = (fAngle - fPrevAngle) / (fNow - fPrevNow);
216 fAngleSign = fAngleSpeed < 0 ? -1 : 1;
228 fPrevAngle = 1234567;
257 :
fSphere({200 + DX, 200 + DY}, 400)
282 for (
bool front : {
false,
true}) {
292 SkM44 localToWorld =
m *
f.asM44(200) *
inv(trans);
294 canvas->
concat(localToWorld);
295 this->
drawFace(canvas,
f.fColor, index++, front, localToWorld);
305 paint.setAntiAlias(
true);
307 paint.setColor(0x40FF0000);
327 fRotation = fRotateAnimator.
rotation() * fRotation;
328 fRotateAnimator.
reset();
340 fRotation = fRotateAnimator.
rotation() * fRotation;
341 fRotateAnimator.
start();
346 fRotateAnimator.
update(axis, angle);
373 const char code[] = R
"(
374 uniform shader color_map;
375 uniform shader normal_map;
377 uniform float4x4 localToWorld;
378 uniform float4x4 localToWorldAdjInv;
379 uniform float3 lightPos;
381 float3 convert_normal_sample(half4 c) {
382 float3 n = 2 * c.rgb - 1;
387 half4 main(float2 p) {
388 float3 norm = convert_normal_sample(normal_map.eval(p));
389 float3 plane_norm = normalize(localToWorldAdjInv * norm.xyz0).xyz;
391 float3 plane_pos = (localToWorld * p.xy01).xyz;
392 float3 light_dir = normalize(lightPos - plane_pos);
395 float dp = dot(plane_norm, light_dir);
396 float scale = min(ambient + max(dp, 0), 1);
398 return color_map.eval(p) * scale.xxx1;
409 const SkM44& localToWorld)
override {
416 builder.uniform(
"localToWorld") = localToWorld;
419 builder.child(
"color_map") = fImgShader;
420 builder.child(
"normal_map") = fBmpShader;
431#include
"modules/skottie/include/Skottie.h"
440 const char* files[] = {
441 "skottie/skottie-chained-mattes.json",
442 "skottie/skottie-gradient-ramp.json",
443 "skottie/skottie_sample_2.json",
444 "skottie/skottie-3d-3planes.json",
445 "skottie/skottie-text-animator-4.json",
446 "skottie/skottie-motiontile-effect-phase.json",
463 SkRect r = {0, 0, 400, 400};
465 fAnim[face]->
render(canvas, &r);
469 for (
auto& anim : fAnim) {
471 SkScalar t = fmod(1
e-9 * nanos, dur) / dur;
static SkM44 normals(SkM44 m)
static SkM44 inv(const SkM44 &m)
static bool isFrontFacing(const SkM44 &m)
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
std::unique_ptr< SkStreamAsset > GetResourceAsStream(const char *resource, bool useFileStream)
constexpr SkColor SK_ColorYELLOW
constexpr SkColor SK_ColorMAGENTA
constexpr SkColor SK_ColorCYAN
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
static SkScalar center(float pos0, float pos1)
void drawFace(SkCanvas *canvas, SkColor color, int face, bool front, const SkM44 &localToWorld) override
void load(SkScalar w, SkScalar h) override
virtual void drawFace(SkCanvas *, SkColor, int face, bool front, const SkM44 &localToWorld)=0
bool animate(double nanos) override
void draw(SkCanvas *canvas) override
Click * onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override
bool onChar(SkUnichar uni) override
CubeBaseSlide(Flags flags)
bool onClick(Click *click) override
void update(SkV3 axis, SkScalar angle)
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
virtual GrRecordingContext * recordingContext() const
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
SkM44 getLocalToDevice() const
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
void concat(const SkMatrix &matrix)
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
static SkM44 LookAt(const SkV3 &eye, const SkV3 ¢er, const SkV3 &up)
SkScalar rc(int r, int c) const
static SkM44 Rotate(SkV3 axis, SkScalar radians)
@ kUninitialized_Constructor
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
static SkM44 Perspective(float near, float far, float angle)
static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z=1)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
@ kStroke_Style
set to stroke geometry
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
static Result MakeForShader(SkString sksl, const Options &)
void drawFace(SkCanvas *canvas, SkColor color, int face, bool front, const SkM44 &) override
bool animate(double nanos) override
void load(SkScalar w, SkScalar h) override
virtual bool onChar(SkUnichar c)
void concatCamera(SkCanvas *canvas, const SkRect &area, SkScalar zscale)
static sk_sp< Animation > Make(const char *data, size_t length)
void render(SkCanvas *canvas, const SkRect *dst=nullptr) const
FlutterSemanticsFlag flags
const uint8_t uint32_t uint32_t GError ** error
static float min(float r, float g, float b)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SkSamplingOptions(SkFilterMode::kLinear))
SIN Vec< N, float > abs(const Vec< N, float > &x)
static SkM44 T(SkScalar x, SkScalar y, SkScalar z)
static SkM44 R(SkV3 axis, SkScalar rad)
SkM44 asM44(SkScalar scale) const
SkV3 computeWorldPos(const VSphere &s) const
void draw(SkCanvas *canvas) const
constexpr float centerX() const
constexpr float height() const
constexpr float centerY() const
constexpr float width() const
SkScalar lengthSquared() const
SkV3 cross(const SkV3 &v) const
SkScalar dot(const SkV3 &v) const
SkM44 computeRotation(SkV2 a, SkV2 b) const
RotateInfo computeRotationInfo(SkV2 a, SkV2 b) const
VSphere(SkV2 center, SkScalar radius)
SkV3 computeUnitV3(SkV2 v) const
bool contains(SkV2 v) const
SkV2 pinLoc(SkV2 p) const