// canvas definition standard variables canvas = document.getElementById('canvasArea'); context=canvas.getContext("2d"); // a2.text variables var xPos = 75; var yPos = canvas.height/2; // a3. attributes context.font = "10pt Arial"; context.fillStyle = "black"; context.textAlign = "right"; context.strokeStyle = "hotpink"; context.lineWidth = 1; // a4. baseline context.beginPath(); context.moveTo(0,yPos); context.lineTo(canvas.width, yPos); context.stroke(); // a5. text baseline examples. context.textBaseline = "top"; context.fillText("|top", xPos*1, yPos); context.textBaseline = "hanging"; context.fillText("|hanging", xPos*2,yPos); context.textBaseline = "middle"; context.fillText("|middle", xPos*3,yPos); context.textBaseline = "alphabetic"; context.fillText("|alphabetic", xPos*4, yPos); context.textBaseline = "ideographic"; context.fillText("|ideographic",xPos*5,yPos); context.textBaseline = "bottom"; context.fillText("|bottom", xPos*6,yPos);