Html Interaction Flashcards
JS: let Var = document.getElementById(“”);
Takes a string that corresponds to to an HTML id attribute
JS: VAR.innerText = “”
Can be used to reassign content of an element (VAR) along side use of document.get…
JS: document.querySelectorAll(“”)
Can be used to select ALL of a certain that match a selector string
Omit the ‘All’ to use on just the first/only selector
JS: .addEventListener(‘EVENT’, Function);
Events can be ‘click’ , ‘keydown’, ‘scroll’ to start with.
JS: let ctx = canvas.getContext(‘2d’);
Setting up a canvas element with a 2d drawing context. Assigning to the variable means less typing when using additional methods/properties further in
JS: ctx.fillStyle = …
to create a solid 2d object fill “colour”
JS: ctx.fillRect(10, 10, 200, 200)
To create a filled rectangle/square.
(Start x, start y, length x, length y)
JS: ctx.linewidth = int
outline width for canvas.getContext
JS: ctx.strokeStyle = ‘colour’
Colour of outline for canvas.getContext
JS: ctx.strokeRect(10, 10, 200, 100)
create a rectangle/square outline
JS: ctx.fillStyle = ‘color’
ctx.beginPath;
ctx.moveTo(x, y);
ctx.lineTo(x, y);
ctx.fill()
Draw and fill a shape by Path
JS: ctx.arc(centreX , centreY, radius, start * [rad], Math.PI*2, true/false)
Draw a circle.
Use after .beginPath()
true = counterclockwise