@@ -331,6 +331,32 @@ export interface CanvasKit {
331331 colors ?: Float32Array | ColorIntArray | null , indices ?: number [ ] | null ,
332332 isVolatile ?: boolean ) : SkVertices ;
333333
334+ /**
335+ * Returns a Skottie animation built from the provided json string.
336+ * Requires that Skottie be compiled into CanvasKit.
337+ * @param json
338+ */
339+ MakeAnimation ( json : string ) : SkottieAnimation ;
340+
341+ /**
342+ * Returns a managed Skottie animation built from the provided json string and assets.
343+ * Requires that Skottie be compiled into CanvasKit.
344+ * @param json
345+ * @param assets - a dictionary of named blobs: { key: ArrayBuffer, ... }
346+ * @param filterPrefix - an optional string acting as a name filter for selecting "interesting"
347+ * Lottie properties (surfaced in the embedded player controls)
348+ */
349+ MakeManagedAnimation ( json : string , assets ?: Record < string , ArrayBuffer > ,
350+ filterPrefix ?: string ) : ManagedSkottieAnimation ;
351+
352+ /**
353+ * Returns a Particles effect built from the provided json string and assets.
354+ * Requires that Particles be compiled into CanvasKit
355+ * @param json
356+ * @param assets
357+ */
358+ MakeParticles ( json : string , assets ?: Record < string , ArrayBuffer > ) : Particles ;
359+
334360 /**
335361 * Returns the underlying data from SkData as a Uint8Array.
336362 * @param data
@@ -566,6 +592,14 @@ export interface MallocObj {
566592 toTypedArray ( ) : TypedArray ;
567593}
568594
595+ export interface ManagedSkottieAnimation extends SkottieAnimation {
596+ setColor ( key : string , color : InputColor ) : void ;
597+ setOpacity ( key : string , opacity : number ) : void ;
598+ getMarkers ( ) : object [ ] ;
599+ getColorProps ( ) : object [ ] ;
600+ getOpacityProps ( ) : object [ ] ;
601+ }
602+
569603/**
570604 * See Paragraph.h for more information on this class. This is only available if Paragraph has
571605 * been compiled in.
@@ -674,6 +708,105 @@ export interface PositionWithAffinity {
674708 affinity : Affinity ;
675709}
676710
711+ /**
712+ * See SkParticleEffect.h for more details.
713+ */
714+ export interface Particles extends EmbindObject < Particles > {
715+ /**
716+ * Draws the current state of the particles on the given canvas.
717+ * @param canvas
718+ */
719+ draw ( canvas : SkCanvas ) : void ;
720+
721+ /**
722+ * Returns a Float32Array bound to the WASM memory of these uniforms. Changing these
723+ * floats will change the corresponding uniforms instantly.
724+ */
725+ effectUniforms ( ) : Float32Array ;
726+
727+ /**
728+ * Returns the nth uniform from the effect.
729+ * @param index
730+ */
731+ getEffectUniform ( index : number ) : ParticlesUniform ;
732+
733+ /**
734+ * Returns the number of uniforms on the effect.
735+ */
736+ getEffectUniformCount ( ) : number ;
737+
738+ /**
739+ * Returns the number of float uniforms on the effect.
740+ */
741+ getEffectUniformFloatCount ( ) : number ;
742+
743+ /**
744+ * Returns the name of the nth effect uniform.
745+ * @param index
746+ */
747+ getEffectUniformName ( index : number ) : string ;
748+
749+ /**
750+ * Returns the nth uniform on the particles.
751+ * @param index
752+ */
753+ getParticleUniform ( index : number ) : ParticlesUniform ;
754+
755+ /**
756+ * Returns the count of uniforms on the particles.
757+ */
758+ getParticleUniformCount ( ) : number ;
759+
760+ /**
761+ * Returns the number of float uniforms on the particles.
762+ */
763+ getParticleUniformFloatCount ( ) : number ;
764+
765+ /**
766+ * Returns the name of the nth particle uniform.
767+ * @param index
768+ */
769+ getParticleUniformName ( index : number ) : string ;
770+
771+ /**
772+ * Returns a Float32Array bound to the WASM memory of these uniforms. Changing these
773+ * floats will change the corresponding uniforms instantly.
774+ */
775+ particleUniforms ( ) : Float32Array ;
776+
777+ /**
778+ * Sets the base position of the effect.
779+ * @param point
780+ */
781+ setPosition ( point : SkPoint ) : void ;
782+
783+ /**
784+ * Sets the base rate of the effect.
785+ * @param rate
786+ */
787+ setRate ( rate : number ) : void ;
788+
789+ /**
790+ * Starts playing the effect.
791+ * @param now
792+ * @param looping
793+ */
794+ start ( now : number , looping : boolean ) : void ;
795+
796+ /**
797+ * Updates the effect using the new time.
798+ * @param now
799+ */
800+ update ( now : number ) : void ;
801+ }
802+
803+ export interface ParticlesUniform {
804+ columns : number ;
805+ rows : number ;
806+ /** The index into the uniforms array that this uniform begins. */
807+ slot : number ;
808+ }
809+
677810/**
678811 * A simple wrapper around SkTextBlob and the simple Text Shaper.
679812 */
@@ -2181,6 +2314,48 @@ export interface SkVertices extends EmbindObject<SkVertices> {
21812314 uniqueID ( ) : number ;
21822315}
21832316
2317+ export interface SkottieAnimation extends EmbindObject < SkottieAnimation > {
2318+ /**
2319+ * Returns the animation duration in seconds.
2320+ */
2321+ duration ( ) : number ;
2322+ /**
2323+ * Returns the animation frame rate (frames / second).
2324+ */
2325+ fps ( ) : number ;
2326+
2327+ /**
2328+ * Draws current animation frame. Must call seek or seekFrame first.
2329+ * @param canvas
2330+ * @param dstRect
2331+ */
2332+ render ( canvas : SkCanvas , dstRect ?: InputRect ) : void ;
2333+
2334+ /**
2335+ * [deprecated] - use seekFrame
2336+ * @param t - value from [0.0, 1.0]; 0 is first frame, 1 is final frame.
2337+ * @param damageRect - will copy damage frame into this if provided.
2338+ */
2339+ seek ( t : number , damageRect ?: SkRect ) : SkRect ;
2340+
2341+ /**
2342+ * Update the animation state to match |t|, specified as a frame index
2343+ * i.e. relative to duration() * fps().
2344+ *
2345+ * Returns the rectangle that was affected by this animation.
2346+ *
2347+ * @param frame - Fractional values are allowed and meaningful - e.g.
2348+ * 0.0 -> first frame
2349+ * 1.0 -> second frame
2350+ * 0.5 -> halfway between first and second frame
2351+ * @param damageRect - will copy damage frame into this if provided.
2352+ */
2353+ seekFrame ( frame : number , damageRect ?: SkRect ) : SkRect ;
2354+
2355+ size ( ) : SkPoint ;
2356+ version ( ) : string ;
2357+ }
2358+
21842359/**
21852360 * Options used for SkPath.stroke(). If an option is omitted, a sensible default will be used.
21862361 */
0 commit comments