Created
October 29, 2014 02:39
-
-
Save JimmyJune/5b862cda10cf72f2a9c3 to your computer and use it in GitHub Desktop.
//todo:get line height is still wrong
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function drawTextBG(ctx, txt, font, x, y) { | |
| ctx.save(); | |
| ctx.font = font; | |
| ctx.textBaseline = 'top'; | |
| ctx.fillStyle = '#f50'; | |
| var width = ctx.measureText(txt).width; | |
| ctx.fillRect(x, y, width, parseInt(font, 10)); | |
| ctx.fillStyle = '#000'; | |
| ctx.fillText(txt, x, y); | |
| ctx.restore(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment