May 2019
Beginner to intermediate
650 pages
14h 50m
English
The position of each moon depends on where the center of the SVG circle is placed, represented by the cx and cy attributes. Appending the circles to the plane object will place them in the vertical middle and only require the calculation of cx. The cy attribute can be omitted, since zero is the default.
The cx coordinate for the first moon is its radius, or half its diameter. The cx attribute for the next circle is the diameter of the previous circle, plus the (MARGIN_MOON) spacing, plus the radius of the current circle. We can calculate the cx attribute for each moon and store it in a property of the data object, so it can be retrieved later when drawing the circle. You can select any valid identifier ...
Read now
Unlock full access