<!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 绘制集合图形的更多相关文章

  1. 学习笔记:HTML5 Canvas绘制简单图形

    HTML5 Canvas绘制简单图形 1.添加Canvas标签,添加id供js操作. <canvas id="mycanvas" height="700" ...

  2. [html5] 学习笔记-Canvas 绘制渐变图形与绘制变形图形

    在 HTML5 中,使用 Canvas API 绘制图形的知识,可以对绘制图形进行处理,包含使用 Canvas API 绘制渐变图形,使用 Canvas API 的坐标轴变换处理功能绘制变形图形.其中 ...

  3. HTML5 Canvas ( 填充图形的绘制 ) closePath, fillStyle, fill

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. 10 个超炫绘制图表图形的 Javascript 插件【转载+整理】

    原文地址 现在,有很多在线绘制图表和图形(Charts and Graphs)的 JavaScript 插件,这些插件还都是免费,以及图表库.这些插件大量出现的原因是基于一个事实:人们不再依赖于 Fl ...

  5. Html5绘制饼图统计图

    这里要介绍的是一个jQuery插件:jquery.easysector.js Html5提供了强大的绘图API,让我们能够使用javascript轻松绘制各种图形.本文将主要讲解使用HTML5绘制饼图 ...

  6. HTML5 Canvas核心技术图形动画与游戏开发(读书笔记)----第一章,基础知识

    一,canvas元素 1 为了防止浏览器不支持canvas元素,我们设置“后备内容”(fallback content),下面紫色的字即为后备内容 <canvas id="canvas ...

  7. html5绘制折线图

    html5绘制折线图详细代码 <html> <canvas id="a_canvas" width="1000" height="7 ...

  8. 最新最全的html5标签集合

    最新最全的html5标签集合,按字母顺序排列的标签列表 4:指示在HTML4.01中定义了该元素 5:指示在HTML5中定义了该元素 标签 描述 <!--...--> 定义注释 <! ...

  9. HTML5 Canvas核心技术图形动画与游戏开发 ((美)David Geary) 中文PDF扫描版​

    <html5 canvas核心技术:图形.动画与游戏开发>是html5 canvas领域的标杆之作,也是迄今为止该领域内容最为全面和深入的著作之一,是公认的权威经典.amazon五星级超级 ...

随机推荐

  1. 浅析document.createDocumentFragment()与js效率

    对于循环批量操作页面的DOM有很大帮助!利用文档碎片处理,然后一次性append,并且使用原生的javascript语句操作 document.createDocumentFragment()说白了就 ...

  2. C++ dynamic_cast实现原理

    dynamic_cast是一个操作符,其用法不再赘述.查看汇编码可以发现实际调用的是这个函数__RTDynamicCast,其内部实现如下: rtti.h: #pragma once extern & ...

  3. c# xml操作类

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Xm ...

  4. 大型项目使用Automake/Autoconf完成编译配置

    http://www.cnblogs.com/xf-linux-arm-java-android/p/3590770.htmlhttp://blog.csdn.net/zengraoli/articl ...

  5. js计算时间差,包括计算,天,时,分,秒

    收集两个计算时间差的计算方法代码片段: var date1=new Date(); //开始时间 var date2=new Date(); //结束时间 var date3=date2.getTim ...

  6. Euro Efficiency(完全背包)

    Euro Efficiency Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) Tot ...

  7. C语言中的回调函数

    C语言中通过函数指针实现回调函数(Callback Function) ====== 首先使用typedef定义回调函数类型 ======  typedef void (*event_cb_t)(co ...

  8. 【玩转Ubuntu】02. Ubuntu上搭建Android开发环境

    一. 基本环境搭建 1.官网http://developer.android.com/sdk/index.html ,下载adt-bundle-linux-x86_64-20130729.zip 2. ...

  9. java 解析json的问题

    本文转载自http://chriszz.sinaapp.com/?p=392 Json就是Javascript notation,可以替代XML,用做数据交互. Json的两种基本表示形式,可以用自动 ...

  10. C#根据汉字生成拼音首字母全称

    static void Main(string[] args) { string s = GetChineseSpell("周杰伦"); Console.WriteLine(s.T ...