Created
October 21, 2010 15:37
-
-
Save fillano/638711 to your computer and use it in GitHub Desktop.
簡單的文字繪製示範
This file contains 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
<!DOCTYPE html> | |
<html lang="zh-TW"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf8"> | |
<style> | |
div { | |
background: #AACCEE; | |
border: solid 1px #336699; | |
margin: 10px; | |
padding: 5px; | |
border-radius: 5px; | |
display: inline-block; | |
text-align: center | |
} | |
canvas { | |
cursor: pointer; | |
} | |
</style> | |
<script src="js/jquery-1.4.2.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
var ctx = $('#canvas')[0].getContext('2d'); | |
var top = 50; | |
$('#paste').bind('click', function(){ | |
ctx.fillText($('#test').val(), 50, top); | |
top += 20; | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="container"><canvas id="canvas" width="640" height="480"></canvas></div> | |
<input id="test"><input type="button" id="paste" value="貼上"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment