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的更多相关文章

  1. [Javascript] Drawing Paths - Lines and Rectangles

    <!DOCTYPE html> <html> <head> <meta name="description" content=" ...

  2. JavaScript Learning Paths(ES5/ES6/ES-Next)

    JavaScript Learning Paths(ES5/ES6/ES-Next) JavaScript Expert refs https://developer.mozilla.org/en-U ...

  3. [Javascript] Drawing Styles on HTML5 Canvas

    window.onload = function() { var canvas = document.getElementById("canvas"), context = can ...

  4. 【Javascript】js图形编辑器库介绍

    10个JavaScript库绘制自己的图表 jopen 2015-04-06 18:18:38 • 发布 摘要:10个JavaScript库绘制自己的图表 JointJS JointJS is a J ...

  5. HTML5资料

    1 Canvas教程 <canvas>是一个新的用于通过脚本(通常是JavaScript)绘图的HTML元素.例如,他可以用于绘图.制作图片的组合或者简单的动画(当然并不那么简单).It ...

  6. leaflet地图库

    an open-source JavaScript libraryfor mobile-friendly interactive maps Overview Tutorials Docs Downlo ...

  7. GDI+ Tutorial for Beginners

    原文 GDI+ Tutorial for Beginners GDI+ is next evolution of GDI. Using GDI objects in earlier versions ...

  8. IGeometryCollection Interface

    Come from ArcGIS Online IGeometryCollection Interface Provides access to members that can be used fo ...

  9. HTML <canvas> 学习笔记

    Professional JavaScript for Web Developers    P552 Basic Usage The <canvas> element requires a ...

随机推荐

  1. UVALive 3211 Now or later

    每架飞机有早晚起降两种方式,给定n架飞机两种方式的起落时间,为每架飞机安排起落时间(早或晚),使得所有飞机起降时间按照早到晚的顺序之间的间隔时间最小值尽量大. 分析: 最小时间尽量大应该采用二分的方法 ...

  2. ASP.NET MVC 入门1、简介

    什么是MVC模式 MVC(Model-View-Controller,模型-视图-控制器模式)用于表示一种软件架构模式.它把软件系统分为三个基本部分:模型(Model),视图(View)和控制器(Co ...

  3. [unity菜鸟] 修改发布成web后的logo

    1. 原始效果  (tip:在4.x的书中有介绍) 2. 打开.html文件原始代码如下 <script type='text/javascript' src='jquery.min.js'&g ...

  4. ANDROID_MARS学习笔记_S01原始版_023_MP3PLAYER003_播放mp3

    一.简介 1.在onListItemClick中实现点击条目时,跳转到PlayerActivity,mp3info通过Intent传给PlayerActivity 2.PlayerActivity通过 ...

  5. 【HDOJ】1033 Edge

    题目英文太多,简单翻译了一下:1. For products that are wrapped in small packings it is necessary that the sheet of ...

  6. 关于数组和List之间相互转换的方法

    1.List转换成为数组:返回数组的运行时类型.如果列表能放入指定的数组.否则,将根据指定数组.如果指定的数组的元素比列表的多),那么会将存储列表元素的数组. 返回:包含列表元素的list.add(& ...

  7. gif压缩

    保存选择颜色值小点会小很多

  8. 一步步写STM32 OS【四】OS基本框架

    一.上篇回顾 上一篇文章中,我们完成了两个任务使用PendSV实现了互相切换的功能,下面我们接着其思路往下做.这次我们完成OS基本框架,即实现一个非抢占式(已经调度的进程执行完成,然后根据优先级调度等 ...

  9. FZU2224 An exciting GCD problem 区间gcd预处理+树状数组

    分析:(别人写的) 对于所有(l, r)区间,固定右区间,所有(li, r)一共最多只会有log个不同的gcd值, 可以nlogn预处理出所有不同的gcd区间,这样区间是nlogn个,然后对于询问离线 ...

  10. 分割函数和根据Id串返回名字

    需求:函数传入一个字符串参数 例如  123-456 将这个字符串123-456拆成两个值 123   456,在通过两个值分别查出数据(例如 张三  李四),拼接成     张三-李四 --声明变量 ...