<!DOCTYPE html>
<html>
<head>
<meta name="description" content="HTML5 Canvas Graphics and Animation Video 1" />
<meta charset="utf-8">
<title>HTML5 Canvas Graphics and Animation</title>
</head>
<body>
<canvas id="canvas" width="600" height="600"></canvas>
<script src="app.js"></script>
</body>
</html>
/**
* Created by Answer1215 on 3/19/2015.
*/
window.onload = function() { //var canvas = $("#canvas")[0];
//var canvas = document.getElmenetByTagName("canvas")[0];
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d");
canvas.width = 400;
canvas.height = 700; //context.fillRect(10, 10, 100, 200);
/**/
context.beginPath();
context.moveTo(100,100); //without draw any line;
context.lineTo(300, 100);
context.lineTo(300, 200);
context.lineTo(100, 200);
context.lineTo(100, 100); context.closePath();
context.stroke(); //context.fill(); //fill() will also close the path for you
//so if you use fill(), you don't need closePath(); but in case you forgot
//to close the path later, just remember to close it every times.
/**/ /**/
context.rect(100,100,100,300); //make a rect and stroke it
context.stroke(); context.fillRect(100,100,100,300); //fill rect
context.strokeRect(100,100,100,300); //draw rect
context.clearRect(100,100,100,300); //clean the canvas*/
};

[Javascript] Drawing Paths - Lines and Rectangles的更多相关文章

  1. [Javascript] Drawing Paths - Curves and Arcs

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

  2. Java基础之在窗口中绘图——绘制直线和矩形(Sketcher 2 drawing lines and rectangles)

    控制台程序. import javax.swing.JComponent; import java.util.*; import java.awt.*; import java.awt.geom.*; ...

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

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

  4. [Javascript] Drawing Styles on HTML5 Canvas

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

  5. 【转】Multithreaded Python Tutorial with the “Threadworms” Demo

    The code for this tutorial can be downloaded here: threadworms.py or from GitHub. This code works wi ...

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

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

  7. direct2d: antialiasing and drawing a line with a 1 pixel stroke

    http://xboxforums.create.msdn.com/forums/t/61448.aspx I'm currently porting a number of custom MFC C ...

  8. JavaScript In OA Framework

    原文地址:JavaScript In OA Framework (需FQ) “To be or not to be…… is the question…..!” The famous soliloqu ...

  9. HTML5资料

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

随机推荐

  1. MongoDB实战指南(一):大数据与云计算

    1.1 什么大数据 具体来说,大数据技术涉及到数据的创造,存储,获取和分析,大数据的主要特点有下面几个: 数据量大.一个典型的PC机载2000年前后其存储空间可能有10GB,今天facebook一天增 ...

  2. RxJava开发精要6 – Observables组合

    原文出自<RxJava Essentials> 原文作者 : Ivan Morgillo 译文出自 : 开发技术前线 www.devtf.cn 转载声明: 本译文已授权开发者头条享有独家转 ...

  3. 转:HTTP请求(GET、POST和soap区别)和响应

    一直对Http请求和SOAP请求不是太理解,只是知道SOAP是基于Http的,并且增加了很多XML标签,SOAP经常用在WebService中,比如在C#中创建一个WebService,然后在客户端生 ...

  4. Python标准库之urllib,urllib2

    urllib模块提供了一些高级接口,用于编写需要与HTTP服务器交互的客户端.典型的应用程序包括从网页抓取数据.自动化.代理.网页爬虫等. 在Python 2中,urllib功能分散在几个不同的库模块 ...

  5. Android开发之BroadcastReceiver的使用

    1.静态注册. 在manifest中注册. <receiver android:name="com.exce.learnbroadcastreceiver.MyReceiver&quo ...

  6. hdu4669Mutiples on a circle

    http://acm.hdu.edu.cn/showproblem.php?pid=4669 这题各种错误都来了一遍  预处理一下第一个数作为尾数与相邻前面的数组成的数的余数  然后再与后面的结合求余 ...

  7. ☀【JS】eval

    避免使用 eval <!doctype html> <html lang="zh-CN"> <head> <meta charset=&q ...

  8. 了解SQL Server锁争用:NOLOCK 和 ROWLOCK 的秘密

    关系型数据库,如SQL Server,使用锁来避免多用户修改数据时的并发冲突.当一组数据被某个用户锁定时,除非第一个用户结束修改并释放锁,否则其他用户就无法修改该组数据. 有些数据库,包括SQL Se ...

  9. FZU 2233 ~APTX4869 贪心+并查集

    分析:http://blog.csdn.net/chenzhenyu123456/article/details/51308460 #include <cstdio> #include & ...

  10. C#父类对象和子类对象之间的转化

    1. 子类到父类 Chinese c = new Chinese(); Person p1 = c;  //从变量c看是一个中国人,所以可以把人的标签贴上去 2. 父类到子类 Chinese c2 = ...