Proper way to draw dynamic number of objects with <Drawing/> depending on timestamp #976
-
I was hoping to draw a dynamic number of objects with a My first approach was (simplified code): const clock = useClockValue();
const draw = ({ canvas, paint, timestamp }) => {
paint.setColor(Skia.Color("#555"));
const alpha = someFunctionDependingOnTimestampMs(clock.value);
paint.setAlphaf(alpha);
canvas.drawCircle(cx, cy, paint);
}
<Canvas>
<Drawing drawing={draw} />
</Canvas> However I didn't get what's expected (alpha value changing as time goes on). When I touch on the canvas and move along, the alpha does update though. I then tried to use the I feel that I must be missing some fields or use incorrectly, but I couldn't find any example code for now. Besides, is there a way to do Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
yes that's a nice catch, here we don't detect that the clock animation value is part of the drawing. If you know that the animation is continuous (every frame will draw something different) you can simply use: |
Beta Was this translation helpful? Give feedback.
yes that's a nice catch, here we don't detect that the clock animation value is part of the drawing. If you know that the animation is continuous (every frame will draw something different) you can simply use:
<Canvas mode="continuous"
. If not, we may need to update theDrawing
component to register animation values.