Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Created April 26, 2020 00:06
Show Gist options
  • Save sandrabosk/c1c466dfdeace78175f2569140ee0539 to your computer and use it in GitHub Desktop.
Save sandrabosk/c1c466dfdeace78175f2569140ee0539 to your computer and use it in GitHub Desktop.

Canvas intro - check for understanding

Let´s start with some basic shapes! First, we will try the create the RSS symbol. Something like this:

Steps:

  1. Create folder and all the files:
$ mkdir canvas-rss-symbol
$ cd canvas-rss-symbol
$ touch index.html index.js style.css
$ code .
  1. Add index.html starter code:
<!--  index.html -->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Canvas RSS symbol</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <canvas id="canvas" width="300" height="300"></canvas>    
    
    <!-- add js file in the end when the DOM is already loaded -->
    <script src="index.js"></script>
    
</body>
</html>
  1. Play with the gathered knowledge on how to create: rectangles, triangles, lines, arcs and curves.

Happy coding! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment