1. JSFiddle or Repl.it
We're going to be using JSFiddle to create our own emojis. Firstly you need to open JSFiddle in a new tab (right click and open in new tab) https://repl.it/
You should then see a set of four squares - we're going to be working on the top left box "HTML"
There are two really important buttons in the top bar to focus on:
- Run = press this every time you want to see what your code does - this should then appear in the bottom right box "Result"
- Save = when you finish for the day - press save and JSFiddle will create you a unique URL - write this down somewhere so next week you can begin where you left off :-)
As we're going to be doing some drawing today - the first important thing to do is to create ourselves a piece of paper. We can do that by using a technology called SVG. Copy the following code and paste it into the HTML file in repl.it.
<svg height="600" width="600"> </svg>
Now the most important part of the emoji is the "face" - so we can draw a circle on our piece of paper.
Paste the following code inside your paper, after
<svg height="600" width="600"> and before the
<circle cx="300" cy="300" r="200" fill="yellow"/>
The attributes mean :
cx= center x value (how far right)
cy= center y value (how far down)
r= radius (how big the circle is)
fill= what colour the shape will be
Next we might want to add a background - we're going to make a "polygon" - which is just a shape with multiple "points". Firstly we need to look at what those coordinates might be :
- top left =
- top right =
- bottom right =
- bottom left =
Next we can make a string of the coordinates to visit =
0,0 600,0 600,600 0,600
Finally, we can subsitute our points into the
<polygon points="0,0 600,0 600,600 0,600" fill="red"/>
But Wait You have to be careful where abouts you paste your polygon. The ordering in SVG matters very much, much like if you had cut all your shapes out of paper and started sticking them on your paper, they would overlap (or even hide) earlier shapes.
Our polygon needs to go before our emoji face.
You probably wanted a more specific colour than "yellow" or "red". Computers have many different ways to represent colours, websites tend to use a thing called "Hex Colours" and they look like this:
- black #000000
- white #ffff00
- yellow = #ffcc00
instead of the word "yellow" write "#ffcc00" and see what happens?
Google have a great list of colours and their hex codes - check it out at https://www.google.com/design/spec/style/color.html#color-ui-color-palette
Try and finish your emoji face - don't forget to add some eyes! We're going to be moving onto using gradients in the next worksheet, and then look at creating some harder shapes!