From 217a5e09a120f8d8ae3de0505ab4d9de918126f7 Mon Sep 17 00:00:00 2001 From: Jason Gorman Date: Wed, 30 Oct 2024 21:14:21 +0000 Subject: [PATCH] Update An Animated Solar System code example (#36576) --- .../web/api/canvas_api/tutorial/basic_animations/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/canvas_api/tutorial/basic_animations/index.md b/files/en-us/web/api/canvas_api/tutorial/basic_animations/index.md index 4b77901be73b174..f3eaae9d91cbddf 100644 --- a/files/en-us/web/api/canvas_api/tutorial/basic_animations/index.md +++ b/files/en-us/web/api/canvas_api/tutorial/basic_animations/index.md @@ -61,6 +61,8 @@ This example animates a small model of our solar system. const sun = new Image(); const moon = new Image(); const earth = new Image(); +const ctx = document.getElementById("canvas").getContext("2d"); + function init() { sun.src = "canvas_sun.png"; moon.src = "canvas_moon.png"; @@ -69,8 +71,6 @@ function init() { } function draw() { - const ctx = document.getElementById("canvas").getContext("2d"); - ctx.globalCompositeOperation = "destination-over"; ctx.clearRect(0, 0, 300, 300); // clear canvas