Lesson 3 - Scene graph and transform
infinitecanvas.cc·4h
Flag this post

In the last lesson we drew a circle, in this lesson you will learn the following:

  • Transformations. Make shapes support pan, zoom, rotate, and skew transformations.
  • Scene graph.

Finally, we will use the above features to realize a simple model of the Solar System.

js

(async () => {
const { Canvas, Circle, Group } = Lesson3;
const canvas = await Utils.createCanvas(Canvas, 400, 400);

const solarSystem = new Group();
const earthOrbit = new Group();
const moonOrbit = new Group();

const sun = new Circle({
cx: 0,
cy: 0,
r: 100,
fill: 'red',
});
const earth = new Circle({
cx: 0,
cy: 0,
r: 50,
fill: 'blue',
});
const moon = new Circle({
cx: 0,
cy: 0,
r: 25,
fill: 'yellow',
});
solarSystem.appendChild(sun);
solarSystem.appendChild(earthOrbit);
earthOrbit.appendChild(earth);
earthO...

Similar Posts

Loading similar posts...