HTML 5 canvas music symbols examples |
Symbol and code | |
Original whole note image
|
Canvas rendered whole note
|
Download file
Line 2 : "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Line 3 : <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> Line 4 : <head> Line 5 : <title>Mobilefish.com - Whole note HTML 5 canvas example</title> Line 6 : Line 7 : <!-- Line 8 : Music symbol whole note v. 1.0 Line 9 : Author: Robert Lie Line 10 : www.mobilefish.com Line 11 : Line 12 : This file is public domain. You can use it for any purpose without restriction. Line 13 : I do not guarantee that it is correct, so use it at your own risk. Line 14 : If you use it for something interesting, I'd appreciate hearing about it. Line 15 : If you find any bugs or make any improvements, I'd appreciate hearing about those too. Line 16 : It would also be nice if my name and URL were left in the comments. But none of that is required. Line 17 : Line 18 : Requires: File excanvas.compiled.js Line 19 : HTML5 Canvas for Internet Explorer Line 20 : See: http://code.google.com/p/explorercanvas/ Line 21 : --> Line 22 : Line 23 : <!--[if IE]> Line 24 : <script type="text/javascript" src="scripts/excanvas.compiled.js"></script> Line 25 : <![endif]--> Line 26 : <script type="text/javascript"> Line 27 : Line 28 : Line 29 : function drawShape(){ Line 30 : var canvas = document.getElementById('cssxCoordinates'); Line 31 : if (canvas.getContext){ Line 32 : var ctx = canvas.getContext('2d'); Line 33 : Line 34 : //Apply scale factor to resize this music symbol to correct dimensions compared to 1/2 note. Line 35 : //ctx.scale(0.946,0.946); Line 36 : Line 37 : ctx.beginPath(); Line 38 : ctx.moveTo(12,75); Line 39 : ctx.quadraticCurveTo(5,55,14,36); Line 40 : ctx.quadraticCurveTo(29,16,54,11); Line 41 : ctx.quadraticCurveTo(73,5,92,8); Line 42 : ctx.quadraticCurveTo(122,12,147,29); Line 43 : ctx.quadraticCurveTo(163,41,169,63); Line 44 : ctx.quadraticCurveTo(170,70,170,78); Line 45 : ctx.quadraticCurveTo(163,98,145,107); Line 46 : ctx.quadraticCurveTo(123,118,98,118); Line 47 : ctx.quadraticCurveTo(73,118,50,108); Line 48 : ctx.quadraticCurveTo(25,98,12,75); Line 49 : ctx.fill(); Line 50 : Line 51 : ctx.fillStyle = "white"; Line 52 : ctx.beginPath(); Line 53 : ctx.moveTo(60,82); Line 54 : ctx.quadraticCurveTo(57,74,51,52); Line 55 : ctx.quadraticCurveTo(46,18,81,15); Line 56 : ctx.quadraticCurveTo(111,18,120,46); Line 57 : ctx.quadraticCurveTo(123,58,128,77); Line 58 : ctx.quadraticCurveTo(130,107,100,110); Line 59 : ctx.quadraticCurveTo(71,110,60,82); Line 60 : ctx.fill(); Line 61 : Line 62 : } else { Line 63 : alert('You need Firefox 1.5+, Google Chrome 8.0+, Internet Explorer 8.0+ or Safari 4.0+ to see the example.'); Line 64 : } Line 65 : } Line 66 : </script> Line 67 : </head> Line 68 : <body onload="drawShape();"> Line 69 : <h1>Whole note</h1> Line 70 : <canvas id="cssxCoordinates" width="179" height="127"></canvas> Line 71 : </body> Line 72 : </html> |