- 浏览: 796905 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (651)
- Java (39)
- Java 初学者小问题 (66)
- 设计模式 (7)
- 项目管理 (3)
- 数据库 (1)
- 算法 (2)
- Java practices (6)
- Effective Java2读书笔记 (78)
- Linux (2)
- programming ruby 读书笔记 (5)
- Core Java Ninth Edition Volume I 读书笔记 (15)
- Pro Git 读书笔记 (12)
- Git (3)
- Maven in Action 读书笔记 (20)
- Web (12)
- 非技术类书籍 (11)
- 电影 (40)
- Web Cache (1)
- jquery (0)
- 历史 (4)
- Dive Into HTML5 读书笔记 (13)
- 三国演义小学毕业考 (79)
- 高效能人士的7个习惯 读书笔记 (12)
- Java Performance 读书笔记 (3)
- Protocol Buffer 学习笔记 (6)
- Mongo DB 学习笔记 (7)
- Morphia 学习笔记 (7)
- Algorithms -- Princeton 学习笔记 (13)
- String研究 (10)
- Hadoop: The Definitive Guide 读书笔记 (3)
- Java与模式读书笔记 (5)
- Date研究 (3)
- The Roman Empire 听课笔记 (4)
- Algorithms -- Standford 学习笔记 (16)
- Core Java Ninth Edition Volume II 读书笔记 (9)
- Thinking in Java 4th Edition 读书笔记 (21)
- Node : Up and Running 学习笔记 (5)
- Eloquent Javascript (8)
- Smashing Node.js 读书笔记 (1)
- Algorithms II -- Standford 学习笔记 (19)
- Algorithm II -- Princeton 学习笔记 (14)
- 网络安全 (2)
- Javascript (4)
- 正则表达式 (1)
- JAVA 7/8 (15)
- JVM (10)
- NodeJS (1)
- 鸟哥的linux私房菜读书笔记 (14)
- Web Service (1)
- The art of programming (9)
- Introduction to Algorithm 读书笔记 (4)
- Java 源码阅读 (0)
- Spring in Action 读书笔记 (2)
- Java Network Programming 读书笔记 (2)
最新评论
-
心存高远:
谢谢作者分享,刚好看到这里不太明白,现在茅塞顿开。不过runt ...
关于 Maven的传递依赖的理解 -
sxlkk:
851228082 写道甚至在某次技术会议现场遇到《Maven ...
关于 Maven的传递依赖的理解 -
851228082:
851228082 写道a----compile----b-- ...
第五章 坐标和依赖 -
851228082:
a----compile----b-----provided- ...
第五章 坐标和依赖 -
851228082:
甚至在某次技术会议现场遇到《Maven in action》的 ...
关于 Maven的传递依赖的理解
1. HTML 5 defines the <canvas> element as “a resolution-dependent bitmap canvas which can be used for rendering graphs, game graphics, or other visual images on the fly.” A canvas is a rectangle in your page where you can use JavaScript to draw anything you want.
2. Every canvas has a drawing context , where all the drawing methods and properties are defined. You call its getContext() method to get the context object, you must pass the string "2d " to the getContext() method. Each drawing context remembers its own properties as long as the page is open, unless you do something to reset it. Individual vendors have experimented with their own three-dimensional canvas API s, but none of them have been standardized. The HTML5 specification notes, “A future version of this specification will probably define a 3d context.”
3. There’s a whole group of properties and methods devoted to drawing rectangles:
a) The fillStyle property can be a CSS color, a pattern, or a gradient. The default fillStyle is solid black, but you can set it to whatever you like.
b) fillRect(x, y, width, height) draws a rectangle filled with the current fill style.
c) The strokeStyle property is like fillStyle — it can be a CSS color, a pattern, or a gradient.
d) strokeRect(x, y, width, height) draws an rectangle with the current stroke style. strokeRect doesn’t fill in the middle; it just draws the edges.
e) clearRect(x, y, width, height) clears the pixels in the specified rectangle.
4. Setting the width or height of a <canvas> element will erase its contents and reset all the properties of its drawing context to their default values. You don’t even need to change the width; you can simply set it to its current value.
5. The canvas is a two-dimensional grid. The coordinate (0, 0) is at the upper-left corner of the canvas. Along the X-axis, values increase towards the right edge of the canvas. Along the Y-axis, values increase towards the bottom edge of the canvas.
6. Each canvas has a path. Defining the path is like drawing with a pencil. To draw straight lines in pencil, you use the following two methods:
a) moveTo(x, y) moves the pencil to the specified starting point.
b) lineTo(x, y) draws a line to the specified ending point.
c) T hese are “pencil” methods — you can call them as often as you like, but you won’t see anything on the canvas until you call one of the “ink” methods.
7. stroke() is one of the “ink” methods. It takes the complex path you defined with all those moveTo() and lineTo() calls, and actually draws it on the canvas. The strokeStyle controls the color of the lines.
8. To draw a line that is only one pixel wide, you need to shift the coordinates by 0.5 perpendicular to the line's direction. For example, if you try to draw a line from (1, 0) to (1, 3) , the browser will draw a line covering 0.5 screen pixels on either side of x=1. The screen can’t display half a pixel, so it expands the line to cover a total of two pixels:
A line from (1,0) to (1,3) is drawn 2 pixels wide But, if you try to draw a line from (1.5, 0) to (1.5, 3) , the browser will draw a line covering 0.5 screen pixels on either side of x=1.5, which results in a true 1-pixel-wide line:
A line from (1.5,0) to (1.5,3) is draw 1 pixel wide
9. To start a new path, you can invoke context.beginPath() . The fillStyle and strokeStyle don’t get reset when you start a new path.
10. You can also draw text on a canvas. Unlike text on the surrounding web page, there is no box model. That means none of the familiar CSS layout techniques are available. The following font attributes are available on the drawing context:
a) font can be anything you would put in a CSS font rule. That includes font style, font variant, font weight, font size, line height, and font family.
b) textAlign controls text alignment. It is similar (but not identical) to a CSS text-align rule. Possible values are start , end , left , right , and center .
c) textBaseline controls where the text is drawn relative to the starting point. Possible values are top , hanging , middle , alphabetic , ideographic , or bottom .
11. The HTML5 specification explains the different text baselines:
The top of the em square is roughly at the top of the glyphs in a font, the hanging baseline is where some glyphs like आ are anchored, the middle is half-way between the top of the em square and the bottom of the em square, the alphabetic baseline is where characters like Á , ÿ , f , and Ω are anchored, the ideographic baseline is where glyphs like 私 and 達 are anchored, and the bottom of the em square is roughly at the bottom of the glyphs in a font. The top and bottom of the bounding box can be far from these baselines, due to glyphs extending far outside the em square.
12. Text drawn inside the canvas inherits the font size and style of the <canvas> element itself, but you can override this by setting the font property on the drawing context. The fillText() method draws the actual text.
13. Like every other HTML element on your page, the <canvas> element itself has a computed font size based on your page’s CSS rules. If you set the context.font property to a relative font size like 1.5em or 150%, your browser multiplies this by the computed font size of the <canvas> element itself.
14. A gradient is a smooth transition between two or more colors. The canvas drawing context supports two types of gradients:
a) createLinearGradient(x0, y0, x1, y1) paints along a line from (x0, y0) to (x1, y1) .
b) createRadialGradient(x0, y0, r0, x1, y1, r1) paints along a cone between two circles. The first three parameters represent the start circle, with origin (x0, y0) and radius r0. The last three parameters represent the end circle, with origin (x1, y1) and radius r1.
15. Once we have a gradient object, we can define the gradient’s colors. A gradient has two or more color stops. Color stops can be anywhere along the gradient. To add a color stop, you need to specify its position along the gradient. Gradient positions can be anywhere between 0 to 1:
my_gradient.addColorStop(0, "black"); my_gradient.addColorStop(1, "white");
16. Defining a gradient doesn’t draw anything on the canvas. It’s just an object tucked away in memory somewhere. To draw a gradient, you set your fillStyle to the gradient and draw a shape, like a rectangle or a line.
17. The canvas drawing context defines a drawImage() method for drawing an image on a canvas. The method can take three, five, or nine arguments:
a) drawImage(image, dx, dy) takes an image and draws it on the canvas. The given coordinates (dx, dy) will be the upper-left corner of the image.
b) drawImage(image, dx, dy, dw, dh) takes an image, scales it to a width of dw and a height of dh, and draws it on the canvas at coordinates (dx, dy) .
c) drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) takes an image, clips it to the rectangle (sx, sy, sw, sh) , scales it to dimensions (dw, dh) , and draws it on the canvas at coordinates (dx, dy) .
18. To draw an image on a canvas, you need an image. The image can be an existing <img> element, or you can create an Image() object with JavaScript. Either way, you need to ensure that the image is fully loaded before you can draw it on the canvas. If you’re using an existing <img> element, you can safely draw it on the canvas during the window.onload event. If you’re creating the image object entirely in JavaScript, you can safely draw the image on the canvas during the Image.onload event.
19. Explorercanvas (excanvas.js ) is an open source, Apache-licensed JavaScript library that implements the canvas API in Internet Explorer.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Dive Into HTML5</title> <!--[if lt IE 9]> <script src="excanvas.js"></script> <![endif]--> </head> <body> ... </body> </html>
There are a few limitations:
a) G radients can only be linear. Radial gradients are not supported.
b) Patterns must be repeating in both directions.
c) Clipping regions are not supported.
d) N on-uniform scaling does not correctly scale strokes.
e) It’s slow.
20. Mouse events are implemented differently in just about every browser:
function getCursorPosition(e) { var x; var y; if (e.pageX != undefined && e.pageY != undefined) { x = e.pageX; y = e.pageY; } else { x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; }
21. The arc() method takes a center point (x, y) , a radius, a start and end angle (in radians), and a direction flag (false for clockwise, true for counter-clockwise).
发表评论
-
《Dive into HTML5》 读后感
2012-06-20 07:57 1516读这本书的起因是参加了2012年的Qcon,对其中某个 ... -
Manipulating History for Fun & Profit
2012-06-20 07:29 10591. The HTML5 history AP ... -
“Distributed,”“Extensibility,”& Other Fancy Words
2012-06-15 15:54 8971. Microdata annotates t ... -
A Form of Madness
2012-06-11 10:41 9721. Placeholder text is d ... -
Let’s Take This Offline
2012-06-09 23:32 9401. An offline web app ... -
A Place To Put Your Stuff
2012-06-09 17:55 9371. Cookies have three po ... -
You Are Here (And So Is Everybody Else)
2012-06-09 16:06 11181. Geolocation is the ar ... -
Video in a Flash (Without That Other Thing)
2012-06-08 15:46 11241. HTML5 defines a standard wa ... -
What Does It All Mean?
2012-06-03 19:23 10871. In Activating Browse ... -
Detecting HTML5 Features
2012-05-24 19:05 10791. There are four basic ... -
A Quite Biased History of HTML5
2012-05-23 20:02 10881. “content type” or “MIM ... -
Introduction: Five Things You Should Know About HTML5
2012-05-22 15:23 10141. HTML5 is a collectio ...
相关推荐
Let's Encrypt是国外一个公共的免费SSL项目,由 Linux 基金会托管,由Mozilla、思科、Akamai、IdenTrust和EFF等组织发起,靠谱! 3、Let's Encrypt安装部署简单、方便,目前Cpanel、Oneinstack等面板都已经集成了...
在本节PEP小学英语四年级上册第四单元A部分的"Let's learn"和"Let's do"中,我们关注的主题是“我的家”(My Home),旨在帮助学生学习和掌握与家居环境相关的词汇和表达。这个单元通过Miss Cheng带大家参观Amy的家...
人教版小学英语四年级上册_Unit6_Meet_My_Family_A_Let's_talk.ppt 本资源是人教版小学英语四年级上册的第六单元相关的课件,标题为"Meet My Family A Let's talk",主要内容围绕家庭成员和家庭介绍展开。 知识点...
【标题】:“A Let's learn&Let's chant课件.ppt” 这是一份针对小学阶段英语教学的课件,主题为“Unit 3 Weather Part A Let’s learn & Let's chant”。该课件旨在帮助学生学习与天气相关的词汇,并通过歌曲和...
"Let's go Ruby" 这个标题暗示我们将深入探索 Ruby 这种编程语言。Ruby 是一种面向对象的、动态类型的编程语言,以其简洁、优雅的语法和强大的元编程能力著称。它由日本的松本行弘(Yukihiro Matsumoto)在1990年代...
Let's Encrypt Windows认证客户端。 Let's Encrypt是国外一个公共的免费SSL项目,由 Linux 基金会托管,由Mozilla、思科、Akamai、IdenTrust和EFF等组织发起。 Let's Encrypt证书有效期三个月,每三个月需要续签证书...
2015新版PEP五年级英语上册_Unit_4_A_Let's_learn.ppt
小学教案
python视频教程大全_Let's python从入门到精通系列视频教程, Python,是一种面向对象的解释性的计算机程序设计语言,也是一种功能强大而完善的通用型语言,已经具有十多年的发展历史,成熟且稳定。 如果你想走进...
小学教案
- 例如:讨论天气:“It’s a nice day, isn’t it?”(天气不错,对吧?) - 或者谈论个人喜好:“You love baseball games, don’t you?”(你喜欢棒球比赛,对吧?) ### 3. 语法练习 #### 3.1 选择题 1. We ...
《Let's_AutoIt》自由天空AU3零起步教程PDF加书签,这份教程旨在为初学者提供一个全面且深入的AutoIt编程入门指南。AutoIt是一种轻量级的脚本语言,专为Windows环境下的自动化任务而设计,它允许用户创建能够控制和...
PEP英语三年级上Unit 2 Colours A Let's learn教案.doc
Let's Encrypt 证书申请 SSL证书 SSL 详细说明如何申请Let's Encrypt证书
【Pep小学英语五年级下册unit4A let’s learn 教学设计】是一份针对小学五年级学生的英语教学计划,旨在帮助学生掌握特定的动词短语及其-ing形式,以及相关的日常交流句型。这份教学设计注重听力、口语、阅读和写作...
pep小学五年级英语上Unit3BLet's_talk课件.pptx
A let's learn 学案
中文名称:Canopus Let's Edit 2视频编缉软件(版本2.03汉化版) 英文名称:Canopus Let's Edit 2.03 别名:康能普斯Let's Edit 2视频编缉软件(版本2.03汉化版) 版本:2.03汉化版 发行时间:2004年 制作发行:...
【标题】:“新版PEP1三年级上册unit2 B let's learn课件.ppt”主要探讨了关于颜色(Colours)的教学内容,是小学英语课程的一个重要单元。在这个课件中,教师会引导学生学习并掌握不同颜色的英语表达,并通过互动...