canvas教程

canvas学习(二)

字号+ 作者:H5之家 来源:H5之家 2015-10-17 14:58 我要评论( )

html文件:

html文件:

<!DOCTYPE html> <html> <head> <title>A simple canvas Example</title> <style> body{ background: #dddddd; } #canvas { margin: 10px; padding: 10px; background: #ffffff; border: thin inset #aaaaaa; width:800px; height:300px; } </style> </head> <body> <canvas id = 'canvas' width = '600' height = '300'> Canvas not supported </canvas> <script src = 'example.js'></script> </body> </html>

example.js

var canvas = document.getElementById('canvas'), context = canvas.getContext('2d'); context.font = '18px Arial'; context.fillStyle = 'cornflowerblue'; context.strokeStyle = 'green'; context.fillText('Hello Canvas1',canvas.width/2 - 111, canvas.height/2 + 15); context.font = '38px Arial'; context.strokeStyle = 'yellow'; context.strokeText('Hello Canvas22',canvas.width/2 - 150, canvas.height/2 + 150);

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • html5canvas核心技术图形、动画与游戏开发源码

    html5canvas核心技术图形、动画与游戏开发源码

    2017-05-02 17:42

  • 打印html5中Canvas的方法

    打印html5中Canvas的方法

    2017-05-01 15:03

  • HTML5+Canvas调用手机拍照功能实现图片上传(下)

    HTML5+Canvas调用手机拍照功能实现图片上传(下)

    2017-04-30 17:00

  • 学习慕课网canvas倒计时实例笔记

    学习慕课网canvas倒计时实例笔记

    2017-04-30 14:01

网友点评
<