html5 绘制集合图形
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<h2>绘制矩形</h2>
<canvas id="mo" width="400" height="280" style="border: 1px solid"></canvas>
<script type="text/javascript">
var canvas = document.getElementById("mo"); var ctx = canvas.getContext("2d"); ctx.shadowBlur = 5.6;//设置阴影的模糊度
ctx.shadowColor = "#111";//设置阴影的颜色
ctx.fillStyle = "#f22"; ctx.fillRect(30, 20, 120, 60); ctx.fillStyle = "#ff2"; ctx.fillRect(80, 60, 120, 60); ctx.fillStyle = "#333";
ctx.lineWidth = 10;
ctx.strokeStyle = "#6f3";
ctx.fillRect(20, 130, 120, 60); </script>
<h2>绘制文字</h2>
<canvas id="mc" width="800" height="280" style="border: 1px solid"></canvas>
<script type="text/javascript">
var canvas = document.getElementById("mc"); var ctx = canvas.getContext("2d");
ctx.shadowBlur = 8.6;//设置阴影的模糊度
ctx.shadowColor = "#555";//设置阴影的颜色 ctx.fillStyle = "#f22";
ctx.font = "italic 50px 隶书";
ctx.textBaseline = 'top';
ctx.fillText("百代繁华一朝都,谁非过客。", 0, 0); ctx.fillStyle = "#f0f";
ctx.font = "bold 45px 宋体"; ctx.fillText("千秋明月吹角寒,花是主人。", 0, 50);
</script>
<h2>绘制圆形</h2>
<canvas id="Canvas2" width="800" height="280" style="border: 1px solid"></canvas>
<script type="text/javascript">
var canvas = document.getElementById("Canvas2");
var ctx = canvas.getContext("2d");
for (var i = 0; i < 10; i++) {
ctx.beginPath();//开始定义路径
ctx.arc(i * 25, i * 25, (i + 1) * 8, 0, Math.PI * 2, true);
ctx.closePath();//关闭路径
ctx.fillStyle = 'rgba(255,0,255,' + (10 - i) * 0.1 + ')';
ctx.fill();
} </script>
<h2>LintTo</h2>
<canvas id="Canvas1" width="800" height="280" style="border: 1px solid" ></canvas>
<script type="text/javascript">
function createStar(context, n, dx, dy, size)
{
context.beginPath();
var dig = Math.PI / n * 4;
for (var i = 0; i < n; i++) {
var x = Math.sin(i * dig);
var y = Math.cos(i * dig);
context.lineTo(x * size + dx, y * size + dy);
}
context.closePath();
}
var canvans = document.getElementById("Canvas1");
var ctx = canvans.getContext('2d');
createStar(ctx, 3, 60, 60, 50);
ctx.fillStyle = "#556";
ctx.fill();
createStar(ctx, 5, 160, 60, 50);
ctx.fillStyle = "#156";
ctx.fill();
createStar(ctx,7, 260, 60, 50);
ctx.fillStyle = "#192";
ctx.fill();
createStar(ctx, 9,360, 60, 50);
ctx.fillStyle = "#345";
ctx.fill();
</script>
</body>
</html>
html5 绘制集合图形的更多相关文章
- 学习笔记:HTML5 Canvas绘制简单图形
HTML5 Canvas绘制简单图形 1.添加Canvas标签,添加id供js操作. <canvas id="mycanvas" height="700" ...
- [html5] 学习笔记-Canvas 绘制渐变图形与绘制变形图形
在 HTML5 中,使用 Canvas API 绘制图形的知识,可以对绘制图形进行处理,包含使用 Canvas API 绘制渐变图形,使用 Canvas API 的坐标轴变换处理功能绘制变形图形.其中 ...
- HTML5 Canvas ( 填充图形的绘制 ) closePath, fillStyle, fill
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 10 个超炫绘制图表图形的 Javascript 插件【转载+整理】
原文地址 现在,有很多在线绘制图表和图形(Charts and Graphs)的 JavaScript 插件,这些插件还都是免费,以及图表库.这些插件大量出现的原因是基于一个事实:人们不再依赖于 Fl ...
- Html5绘制饼图统计图
这里要介绍的是一个jQuery插件:jquery.easysector.js Html5提供了强大的绘图API,让我们能够使用javascript轻松绘制各种图形.本文将主要讲解使用HTML5绘制饼图 ...
- HTML5 Canvas核心技术图形动画与游戏开发(读书笔记)----第一章,基础知识
一,canvas元素 1 为了防止浏览器不支持canvas元素,我们设置“后备内容”(fallback content),下面紫色的字即为后备内容 <canvas id="canvas ...
- html5绘制折线图
html5绘制折线图详细代码 <html> <canvas id="a_canvas" width="1000" height="7 ...
- 最新最全的html5标签集合
最新最全的html5标签集合,按字母顺序排列的标签列表 4:指示在HTML4.01中定义了该元素 5:指示在HTML5中定义了该元素 标签 描述 <!--...--> 定义注释 <! ...
- HTML5 Canvas核心技术图形动画与游戏开发 ((美)David Geary) 中文PDF扫描版
<html5 canvas核心技术:图形.动画与游戏开发>是html5 canvas领域的标杆之作,也是迄今为止该领域内容最为全面和深入的著作之一,是公认的权威经典.amazon五星级超级 ...
随机推荐
- Android stagefright与opencore对比
[转载至其它博客] http://blog.csdn.net/djy1992/article/details/9339917 1引言 Android froyo版本多媒体引擎做了变动,新添加了st ...
- Why stackedit
马克飞象 这个小工具很不错.初初看上了他能够很好写Latex,然后能同步到Evernode.但有个问题,在ipad上面用evernote的App时,latex不能显示.可能是权限的问题. Stacke ...
- DB_Links创建际删除
创建 create database link gadata0008 connect to gadata0008 identified by "gold" using 'ORA11 ...
- 解决windows下Eclipse连接远程Hadoop报错
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.N ...
- Java代码整理
- C# 通过Devart连接Oracle(不需要客户端)
16年一月底回了四川,接下来两年就准备在四川工作了.哈哈,虽然收入比沿海城市少了很多,但离老家近些感觉还是很不错的哈,好了,废话不多说,直接上干货. 最近的项目需要用到C#连接Oracle,以前要么是 ...
- JAVA反射系列之Field,java.lang.reflect.Field使用获取方法
JAVA反射系列之Field,java.lang.reflect.Field使用获取方法. 转载https://my.oschina.net/u/1407116/blog/209383 摘要 ja ...
- TCP/IP详解之:ARP协议 和 RARP协议
ARP功能:从逻辑internet地址(IP地址)到对应的物理硬件地址(以太网地址)之间的转换 ARP工作原理: (1)首先每个主机都会在自己的ARP缓冲区中建立一个ARP列表,以表示IP和MAC间的 ...
- getchar()用法
getchar() .从缓冲区读走一个字符,相当于清除缓冲区 .前面的scanf()在读取输入时会在缓冲区中留下一个字符'\n'(输入完s[i]的值后按回车键所致),所以如果不在此加一个getchar ...
- QF——iOS沙盒机制
iOS沙盒机制: 什么是沙盒机制? 点击进入 点击进入 沙盒机制(SandBox)是一种安全体系,它规定了APP的所有文件数据都必须存储在这片区域.所有非代码文件的数据都保存在这片区域. 沙盒里有 ...