70-480 Flashcards
When to use Article over Section or Div
Use section when the content requires a heading and the it makes sense together,
Use Article same as section but also when the content makes sense alone without anything else
Use a Div in all other cases when you dont need to group things based on a header etc
name all new 11 HTML 5 elements
article aside figcaption footer header hgroup mark nav progress section
how to know if an element has child nodes
document. hasChildNodes()
document. childNodes()
document. firstChild()
document. lastChild()
how to create an element and remove
document.createElement('article") var someElement = document.getElementById('someDiv') someElement.removeNode(true);
how to add a video to html what attributes can you add
attributes
src
autoplay - plays after loaded
controls - just include and it will add play control for user
height/width (height=”400”)
loop - add and will loop
poster - when the video is not playing will use the image argument is location
how do you add multiple formats for the video element and set a default message if none are supported by browser
do not add src to video
as a child element of video add
to add a message that it failed
<p> this is not supported></p>
what are the methods on a video element how to use them
methods are play(), pause(), volume, currentTime
how does an audio element work
The exact same as a video element
what is a canvas element and how to draw to it
a canvas element is used to draw graphic UI elements on a screen.
In javascript get the canvas element draw to it by getting the context from it
canvas. getContext(‘2d’);
canvas. fillRect(x,y, width, height)
How to make an element full screen size
Best in javascript
somelement.width = window.innerWidth
Methods to draw basic shapes on a canvas
Line - someCanvas.beginPath(), then someCanvas.moveTo( x , y)
then someCanvas.lineTo(x , y) - how many pixel it will move to not where it ends
then someCanvas.stroke() actually draws the line
can add css canvas.strokeStyle = “#FFFFFF”
to change a rectangle color
canvas.fillStyle = “rgb(0,0,0)
circle
canvas.arc(x , y , radians or size, start angle *0 or where to start drawing, end angle or how long to go on for Math.PI * 2, draw counter clock wise = false)
always start with beginstroke, made some shape then stroke
using canvas how do you do text
two steps,
define the font and then do stroke
someCanvas.font = “30px Arial”;
someCanvas.strokeText(‘someText’, X , Y); or fillTetxt
how to do gradient in shape
1.first you want to define the gradient there are two types, linear and radial
someCanvas.createLinearGradient( xBegin, yBegin, xEnd, yEnd)
someCanvas.createRadialGradient( xBegin yBegin rBegin, etc)
- add colour stops
between 0 and 1.
someGradient.addColorStop( 0, “blue); - fill the style with the new gradient obj
someShape.fillStyle(someGradient);
someShape.fillStroke(someGradient);
how to do animations in canvas
want to run requestAnimationFrame() over and over and clear the canvas by running clearRect(side of canvas);
redraw objects
in canvas how to make a curve
three options
moveTo(x1, y1)
quadradicCurveTo(x2, y2, x3, y3)
moveTo(x1, y1)
bezierCurveTo(x2, y2, x3, y3, x4, y4)