[Javascript] Drawing Paths - Curves and Arcs
window.onload = function() {
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d");
context.beginPath();
context.moveTo(0,300);
for(var x = 1; x < 300; x++){
var y = 300 + Math.sin(x * 0.02) *100;
context.lineTo(x,y);
}
context.stroke();
};

quadraticCurveTo() & bezierCurveTo():

window.onload = function() {
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d");
var p0 = {
x: Math.random() * 600,
y: Math.random() * 600
};
var p1 = {
x: Math.random() * 600,
y: Math.random() * 600
};
var p2 = {
x: Math.random() * 600,
y: Math.random() * 600
};
context.beginPath();
context.moveTo(p0.x, p0.y);
context.quadraticCurveTo(p1.x, p1.y, p2.x, p2.y);
context.stroke();
context.closePath();
drawPoint(p0);
drawPoint(p1);
drawPoint(p2);
function drawPoint(p) {
context.fillRect(p.x - 4, p.y - 4, 8, 8);
}
};

window.onload = function() {
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d");
var p0 = {
x: Math.random() * 600,
y: Math.random() * 600
};
var p1 = {
x: Math.random() * 600,
y: Math.random() * 600
};
var p2 = {
x: Math.random() * 600,
y: Math.random() * 600
};
var p3 = {
x: Math.random() * 600,
y: Math.random() * 600
};
context.beginPath();
context.moveTo(p0.x, p0.y);
context.bezierCurveTo( p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);
context.stroke();
context.closePath();
drawPoint(p0);
drawPoint(p1);
drawPoint(p2);
drawPoint(p3);
function drawPoint(p) {
context.fillRect(p.x - 4, p.y - 4, 8, 8);
}
};


window.onload = function() {
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d");
context.beginPath();
context.arc(200,200,100,0,2);
context.stroke();
context.closePath();
context.beginPath();
context.arc(400,400,100,0,2, true);
context.stroke();
context.closePath();
};

window.onload = function() {
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d");
context.beginPath();
context.arc(300,300,100,0, Math.PI * 2);
context.stroke();
context.closePath();
};

[Javascript] Drawing Paths - Curves and Arcs的更多相关文章
- [Javascript] Drawing Paths - Lines and Rectangles
<!DOCTYPE html> <html> <head> <meta name="description" content=" ...
- JavaScript Learning Paths(ES5/ES6/ES-Next)
JavaScript Learning Paths(ES5/ES6/ES-Next) JavaScript Expert refs https://developer.mozilla.org/en-U ...
- [Javascript] Drawing Styles on HTML5 Canvas
window.onload = function() { var canvas = document.getElementById("canvas"), context = can ...
- 【Javascript】js图形编辑器库介绍
10个JavaScript库绘制自己的图表 jopen 2015-04-06 18:18:38 • 发布 摘要:10个JavaScript库绘制自己的图表 JointJS JointJS is a J ...
- HTML5资料
1 Canvas教程 <canvas>是一个新的用于通过脚本(通常是JavaScript)绘图的HTML元素.例如,他可以用于绘图.制作图片的组合或者简单的动画(当然并不那么简单).It ...
- leaflet地图库
an open-source JavaScript libraryfor mobile-friendly interactive maps Overview Tutorials Docs Downlo ...
- GDI+ Tutorial for Beginners
原文 GDI+ Tutorial for Beginners GDI+ is next evolution of GDI. Using GDI objects in earlier versions ...
- IGeometryCollection Interface
Come from ArcGIS Online IGeometryCollection Interface Provides access to members that can be used fo ...
- HTML <canvas> 学习笔记
Professional JavaScript for Web Developers P552 Basic Usage The <canvas> element requires a ...
随机推荐
- Linux伙伴系统1
(一)--伙伴系统的概述 Linux内核内存管理的一项重要工作就是如何在频繁申请释放内存的情况下,避免碎片的产生.Linux采用伙伴系统解决外部碎片的问题,采用slab解决内部碎片的问题,在这里我们先 ...
- java1.8的几大新特性(二)
七.Date APIJava 8 在包java.time下包含了一组全新的时间日期API.新的日期API和开源的Joda-Time库差不多,但又不完全一样,下面的例子展示了这组新API里最重要的一些部 ...
- 手势识别官方教程(8)拦截触摸事件,得到触摸的属性如速度,距离等,控制view展开
onInterceptTouchEvent可在onTouchEvent()前拦截触摸事件, ViewConfiguration得到触摸的属性如速度,距离等, TouchDelegate控制view展开 ...
- Good vs Evil
Good vs Evil Description Middle Earth is about to go to war. The forces of good will have many battl ...
- hdu4666Hyperspace
http://acm.hdu.edu.cn/showproblem.php?pid=4666 先看一个求曼哈顿的帖子http://www.cnblogs.com/lmnx/articles/24797 ...
- windows下的BT服务器搭建方案
BT下载可以说是目前网络上最流行的P2P文件共享方式了.BT服务器相比于FTP服务器有许多优势,其中最重要的一点就是BT服务器不受服务器带宽和连接到服务器用户数量的限制,能够提供高速的下载服务.今天, ...
- [liu yanling]软件测试的分类
按测试的对象或范围分类: 单元测试.文档测试.系统测试等. 按测试目的分类: 功能测试.回归测试.性能测试.可靠性测试.安全性测试和兼容性测试 等. 根据测试过程中被测软件是否被执行: 分为静态测试 ...
- asp.net mvc3+EF4.1项目实战
ASP.NET身份验证机制membership入门——配置篇(1) http://www.cnblogs.com/xlb2000/archive/2010/05/10/1729076.html 1.添 ...
- FCLK PCLK HCLK
一.对clock的基本认识 1 s3c2410的clock & power management模块包含三个部分:clock control.usb control.power control ...
- HDU 1166 敌兵布阵 线段树区间求和 更改
水 #include<iostream> #include<string> #include<algorithm> #include<cstdlib> ...