Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
See the solution for rendering the Space, Board, and Token objects.
Jump to Solution Timestamps
1:40 - drawSVGSpace() solution
2:43 - drawHTMLBoard() solution
4:03 - drawHTMLToken() solution
Some Background on SVGs
SVG stands for Scalable Vector Graphics. MDN describes SVG as an XML-based markup language for describing two dimensional based vector graphics. It says βSVG is essentially to graphics what HTML is to textβ. Essentially, SVG is a way to write, or describe, a graphic element in code. SVGs are great for displaying shapes on your website or app.
You might be wondering: why not just use CSS? Well, CSS can do a lot, for sure. But the reason SVGs are the right choice for this part of the app is because it offers the ability to clip and mask objects. On a real life βFour in a Rowβ board, the spaces that the tokens are dropped into are actually holes in the board. To recreate this βholeβ effect in our game, we have to use SVGs masking capabilities.
For...of Loops
Check out the JavaScript Syntax Reference or the MDN documentation to learn more about for...of
loops.
Code Correction
Line 17 in the drawSVGSpace()
method in the Space.js file is unnecessary. Remember when I mentioned that apps often go through many iterations? Adding the data-column
attribute to the SVG element was important in a previous iteration, but not used in the final project. Feel free to ignore it. Its presence doesn't anything, but you won't see it utilized in the rest of the course.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up