We are going to use a technology called
SVG (Scalable Vector Graphics)
. It’s all about drawing shapes on the screen. Let’s install an Elm Package to help us work with SVG. Go to
in the search box. After a short while a list of suggested packages should show up. Install the one called simply
cartesian coordinates system
. To get some intuition about it, imagine that you are a villain in an old James Bond movie. For some sinister purpose you need to tell somebody exactly where a flower pot is located on a large table. The problem is that you can only communicate through an old fashioned phone
. To fool mr. Bond you need to be very precise, so saying something like “it’s roughly in the middle” won’t work.
Now the dot is not in the corner anymore, but it’s not in the center yet. If we want our dot to be exactly in the center of the screen, we’ll have to set
to values equal to exactly half of the
of the SVG viewport. We could calculate the position of the circle as:
It works a little bit like a photo camera pointing directly at the surface. You can move it up, down (along the
axis) and left and right (along the
axis). You can also change its focal length to cover more or less area. Unlike a lens of the camera you set the width and height separately. If you set it so that the dot is in the middle of your frame, then no matter how big the print of the picture will be, the dot will always be in the center. Increasing the
of the viewbox will make more of the surrounding surface visible and the dot will become smaller, but its position won’t change. Let’s see it in action: