HTML 5 canvas music symbols examples |
Symbol and code | |
Original 1/4 rest
|
Canvas rendered 1/4 rest
|
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 - 1/4 rest HTML 5 canvas example</title> Line 6 : Line 7 : <!-- Line 8 : Music symbol 1/4 rest 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 : var x = 20; Line 34 : var y = 20; Line 35 : Line 36 : drawRest4(ctx,x,y); Line 37 : Line 38 : } else { Line 39 : alert('You need Firefox 1.5+, Google Chrome 8.0+, Internet Explorer 8.0+ or Safari 4.0+ to see the example.'); Line 40 : } Line 41 : } Line 42 : Line 43 : function drawRest4(ctx,x,y){ Line 44 : Line 45 : var x_offset_rest = 17; Line 46 : var y_offset_rest = 19; Line 47 : Line 48 : var x_corner = x - x_offset_rest; Line 49 : var y_corner = y - y_offset_rest; Line 50 : Line 51 : ctx.save(); Line 52 : Line 53 : ctx.translate(x_corner,y_corner); Line 54 : Line 55 : ctx.beginPath(); Line 56 : ctx.moveTo(61,19); Line 57 : Line 58 : ctx.quadraticCurveTo(64,19,67,19); Line 59 : ctx.quadraticCurveTo(94,68,116,110); Line 60 : ctx.quadraticCurveTo(128,135,115,145); Line 61 : ctx.quadraticCurveTo(47,195,83,252); Line 62 : ctx.quadraticCurveTo(100,277,121,308); Line 63 : ctx.quadraticCurveTo(118,309,117,310); Line 64 : ctx.quadraticCurveTo(100,292,81,286); Line 65 : ctx.quadraticCurveTo(44,276,46,315); Line 66 : ctx.quadraticCurveTo(49,335,59,352); Line 67 : ctx.quadraticCurveTo(59,354,59,358); Line 68 : ctx.quadraticCurveTo(40,335,26,309); Line 69 : ctx.quadraticCurveTo(15,289,18,266); Line 70 : ctx.quadraticCurveTo(21,245,45,248); Line 71 : ctx.quadraticCurveTo(69,252,86,266); Line 72 : ctx.quadraticCurveTo(57,231,35,191); Line 73 : ctx.quadraticCurveTo(16,147,50,118); Line 74 : ctx.quadraticCurveTo(85,89,72,46); Line 75 : ctx.quadraticCurveTo(67,33,61,19); Line 76 : Line 77 : ctx.fill(); Line 78 : ctx.restore(); Line 79 : Line 80 : } Line 81 : </script> Line 82 : </head> Line 83 : <body onload="drawShape();"> Line 84 : <h1>1/4 rest</h1> Line 85 : <canvas id="cssxCoordinates" width="140" height="375"></canvas> Line 86 : </body> Line 87 : </html> |