author | Pierre-Yves David <pierre-yves.david@fb.com> |
Tue, 28 Oct 2014 15:44:23 +0100 | |
changeset 23221 | cadc9a723d60 |
parent 21189 | 2a74c5af892f |
permissions | -rw-r--r-- |
21189
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
1 |
// Copyright 2006 Google Inc. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
2 |
// |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
4 |
// you may not use this file except in compliance with the License. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
5 |
// You may obtain a copy of the License at |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
6 |
// |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0 |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
8 |
// |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
9 |
// Unless required by applicable law or agreed to in writing, software |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
12 |
// See the License for the specific language governing permissions and |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
13 |
// limitations under the License. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
14 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
15 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
16 |
// Known Issues: |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
17 |
// |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
18 |
// * Patterns are not implemented. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
19 |
// * Radial gradient are not implemented. The VML version of these look very |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
20 |
// different from the canvas one. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
21 |
// * Clipping paths are not implemented. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
22 |
// * Coordsize. The width and height attribute have higher priority than the |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
23 |
// width and height style values which isn't correct. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
24 |
// * Painting mode isn't implemented. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
25 |
// * Canvas width/height should is using content-box by default. IE in |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
26 |
// Quirks mode will draw the canvas using border-box. Either change your |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
27 |
// doctype to HTML5 |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
28 |
// (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype) |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
29 |
// or use Box Sizing Behavior from WebFX |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
30 |
// (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html) |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
31 |
// * Non uniform scaling does not correctly scale strokes. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
32 |
// * Optimize. There is always room for speed improvements. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
33 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
34 |
// Only add this code if we do not already have a canvas implementation |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
35 |
if (!document.createElement('canvas').getContext) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
36 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
37 |
(function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
38 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
39 |
// alias some functions to make (compiled) code shorter |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
40 |
var m = Math; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
41 |
var mr = m.round; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
42 |
var ms = m.sin; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
43 |
var mc = m.cos; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
44 |
var abs = m.abs; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
45 |
var sqrt = m.sqrt; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
46 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
47 |
// this is used for sub pixel precision |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
48 |
var Z = 10; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
49 |
var Z2 = Z / 2; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
50 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
51 |
/** |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
52 |
* This funtion is assigned to the <canvas> elements as element.getContext(). |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
53 |
* @this {HTMLElement} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
54 |
* @return {CanvasRenderingContext2D_} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
55 |
*/ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
56 |
function getContext() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
57 |
return this.context_ || |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
58 |
(this.context_ = new CanvasRenderingContext2D_(this)); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
59 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
60 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
61 |
var slice = Array.prototype.slice; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
62 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
63 |
/** |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
64 |
* Binds a function to an object. The returned function will always use the |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
65 |
* passed in {@code obj} as {@code this}. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
66 |
* |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
67 |
* Example: |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
68 |
* |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
69 |
* g = bind(f, obj, a, b) |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
70 |
* g(c, d) // will do f.call(obj, a, b, c, d) |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
71 |
* |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
72 |
* @param {Function} f The function to bind the object to |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
73 |
* @param {Object} obj The object that should act as this when the function |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
74 |
* is called |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
75 |
* @param {*} var_args Rest arguments that will be used as the initial |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
76 |
* arguments when the function is called |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
77 |
* @return {Function} A new function that has bound this |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
78 |
*/ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
79 |
function bind(f, obj, var_args) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
80 |
var a = slice.call(arguments, 2); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
81 |
return function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
82 |
return f.apply(obj, a.concat(slice.call(arguments))); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
83 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
84 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
85 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
86 |
var G_vmlCanvasManager_ = { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
87 |
init: function(opt_doc) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
88 |
if (/MSIE/.test(navigator.userAgent) && !window.opera) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
89 |
var doc = opt_doc || document; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
90 |
// Create a dummy element so that IE will allow canvas elements to be |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
91 |
// recognized. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
92 |
doc.createElement('canvas'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
93 |
doc.attachEvent('onreadystatechange', bind(this.init_, this, doc)); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
94 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
95 |
}, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
96 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
97 |
init_: function(doc) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
98 |
// create xmlns |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
99 |
if (!doc.namespaces['g_vml_']) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
100 |
doc.namespaces.add('g_vml_', 'urn:schemas-microsoft-com:vml', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
101 |
'#default#VML'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
102 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
103 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
104 |
if (!doc.namespaces['g_o_']) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
105 |
doc.namespaces.add('g_o_', 'urn:schemas-microsoft-com:office:office', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
106 |
'#default#VML'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
107 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
108 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
109 |
// Setup default CSS. Only add one style sheet per document |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
110 |
if (!doc.styleSheets['ex_canvas_']) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
111 |
var ss = doc.createStyleSheet(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
112 |
ss.owningElement.id = 'ex_canvas_'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
113 |
ss.cssText = 'canvas{display:inline-block;overflow:hidden;' + |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
114 |
// default size is 300x150 in Gecko and Opera |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
115 |
'text-align:left;width:300px;height:150px}' + |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
116 |
'g_vml_\\:*{behavior:url(#default#VML)}' + |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
117 |
'g_o_\\:*{behavior:url(#default#VML)}'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
118 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
119 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
120 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
121 |
// find all canvas elements |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
122 |
var els = doc.getElementsByTagName('canvas'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
123 |
for (var i = 0; i < els.length; i++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
124 |
this.initElement(els[i]); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
125 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
126 |
}, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
127 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
128 |
/** |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
129 |
* Public initializes a canvas element so that it can be used as canvas |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
130 |
* element from now on. This is called automatically before the page is |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
131 |
* loaded but if you are creating elements using createElement you need to |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
132 |
* make sure this is called on the element. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
133 |
* @param {HTMLElement} el The canvas element to initialize. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
134 |
* @return {HTMLElement} the element that was created. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
135 |
*/ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
136 |
initElement: function(el) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
137 |
if (!el.getContext) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
138 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
139 |
el.getContext = getContext; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
140 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
141 |
// Remove fallback content. There is no way to hide text nodes so we |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
142 |
// just remove all childNodes. We could hide all elements and remove |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
143 |
// text nodes but who really cares about the fallback content. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
144 |
el.innerHTML = ''; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
145 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
146 |
// do not use inline function because that will leak memory |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
147 |
el.attachEvent('onpropertychange', onPropertyChange); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
148 |
el.attachEvent('onresize', onResize); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
149 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
150 |
var attrs = el.attributes; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
151 |
if (attrs.width && attrs.width.specified) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
152 |
// TODO: use runtimeStyle and coordsize |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
153 |
// el.getContext().setWidth_(attrs.width.nodeValue); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
154 |
el.style.width = attrs.width.nodeValue + 'px'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
155 |
} else { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
156 |
el.width = el.clientWidth; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
157 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
158 |
if (attrs.height && attrs.height.specified) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
159 |
// TODO: use runtimeStyle and coordsize |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
160 |
// el.getContext().setHeight_(attrs.height.nodeValue); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
161 |
el.style.height = attrs.height.nodeValue + 'px'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
162 |
} else { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
163 |
el.height = el.clientHeight; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
164 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
165 |
//el.getContext().setCoordsize_() |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
166 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
167 |
return el; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
168 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
169 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
170 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
171 |
function onPropertyChange(e) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
172 |
var el = e.srcElement; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
173 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
174 |
switch (e.propertyName) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
175 |
case 'width': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
176 |
el.style.width = el.attributes.width.nodeValue + 'px'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
177 |
el.getContext().clearRect(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
178 |
break; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
179 |
case 'height': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
180 |
el.style.height = el.attributes.height.nodeValue + 'px'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
181 |
el.getContext().clearRect(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
182 |
break; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
183 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
184 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
185 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
186 |
function onResize(e) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
187 |
var el = e.srcElement; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
188 |
if (el.firstChild) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
189 |
el.firstChild.style.width = el.clientWidth + 'px'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
190 |
el.firstChild.style.height = el.clientHeight + 'px'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
191 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
192 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
193 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
194 |
G_vmlCanvasManager_.init(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
195 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
196 |
// precompute "00" to "FF" |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
197 |
var dec2hex = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
198 |
for (var i = 0; i < 16; i++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
199 |
for (var j = 0; j < 16; j++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
200 |
dec2hex[i * 16 + j] = i.toString(16) + j.toString(16); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
201 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
202 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
203 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
204 |
function createMatrixIdentity() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
205 |
return [ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
206 |
[1, 0, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
207 |
[0, 1, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
208 |
[0, 0, 1] |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
209 |
]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
210 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
211 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
212 |
function matrixMultiply(m1, m2) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
213 |
var result = createMatrixIdentity(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
214 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
215 |
for (var x = 0; x < 3; x++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
216 |
for (var y = 0; y < 3; y++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
217 |
var sum = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
218 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
219 |
for (var z = 0; z < 3; z++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
220 |
sum += m1[x][z] * m2[z][y]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
221 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
222 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
223 |
result[x][y] = sum; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
224 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
225 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
226 |
return result; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
227 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
228 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
229 |
function copyState(o1, o2) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
230 |
o2.fillStyle = o1.fillStyle; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
231 |
o2.lineCap = o1.lineCap; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
232 |
o2.lineJoin = o1.lineJoin; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
233 |
o2.lineWidth = o1.lineWidth; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
234 |
o2.miterLimit = o1.miterLimit; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
235 |
o2.shadowBlur = o1.shadowBlur; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
236 |
o2.shadowColor = o1.shadowColor; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
237 |
o2.shadowOffsetX = o1.shadowOffsetX; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
238 |
o2.shadowOffsetY = o1.shadowOffsetY; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
239 |
o2.strokeStyle = o1.strokeStyle; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
240 |
o2.globalAlpha = o1.globalAlpha; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
241 |
o2.arcScaleX_ = o1.arcScaleX_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
242 |
o2.arcScaleY_ = o1.arcScaleY_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
243 |
o2.lineScale_ = o1.lineScale_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
244 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
245 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
246 |
function processStyle(styleString) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
247 |
var str, alpha = 1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
248 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
249 |
styleString = String(styleString); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
250 |
if (styleString.substring(0, 3) == 'rgb') { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
251 |
var start = styleString.indexOf('(', 3); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
252 |
var end = styleString.indexOf(')', start + 1); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
253 |
var guts = styleString.substring(start + 1, end).split(','); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
254 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
255 |
str = '#'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
256 |
for (var i = 0; i < 3; i++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
257 |
str += dec2hex[Number(guts[i])]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
258 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
259 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
260 |
if (guts.length == 4 && styleString.substr(3, 1) == 'a') { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
261 |
alpha = guts[3]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
262 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
263 |
} else { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
264 |
str = styleString; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
265 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
266 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
267 |
return {color: str, alpha: alpha}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
268 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
269 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
270 |
function processLineCap(lineCap) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
271 |
switch (lineCap) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
272 |
case 'butt': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
273 |
return 'flat'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
274 |
case 'round': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
275 |
return 'round'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
276 |
case 'square': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
277 |
default: |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
278 |
return 'square'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
279 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
280 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
281 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
282 |
/** |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
283 |
* This class implements CanvasRenderingContext2D interface as described by |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
284 |
* the WHATWG. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
285 |
* @param {HTMLElement} surfaceElement The element that the 2D context should |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
286 |
* be associated with |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
287 |
*/ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
288 |
function CanvasRenderingContext2D_(surfaceElement) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
289 |
this.m_ = createMatrixIdentity(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
290 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
291 |
this.mStack_ = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
292 |
this.aStack_ = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
293 |
this.currentPath_ = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
294 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
295 |
// Canvas context properties |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
296 |
this.strokeStyle = '#000'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
297 |
this.fillStyle = '#000'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
298 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
299 |
this.lineWidth = 1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
300 |
this.lineJoin = 'miter'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
301 |
this.lineCap = 'butt'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
302 |
this.miterLimit = Z * 1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
303 |
this.globalAlpha = 1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
304 |
this.canvas = surfaceElement; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
305 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
306 |
var el = surfaceElement.ownerDocument.createElement('div'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
307 |
el.style.width = surfaceElement.clientWidth + 'px'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
308 |
el.style.height = surfaceElement.clientHeight + 'px'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
309 |
el.style.overflow = 'hidden'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
310 |
el.style.position = 'absolute'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
311 |
surfaceElement.appendChild(el); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
312 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
313 |
this.element_ = el; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
314 |
this.arcScaleX_ = 1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
315 |
this.arcScaleY_ = 1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
316 |
this.lineScale_ = 1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
317 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
318 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
319 |
var contextPrototype = CanvasRenderingContext2D_.prototype; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
320 |
contextPrototype.clearRect = function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
321 |
this.element_.innerHTML = ''; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
322 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
323 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
324 |
contextPrototype.beginPath = function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
325 |
// TODO: Branch current matrix so that save/restore has no effect |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
326 |
// as per safari docs. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
327 |
this.currentPath_ = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
328 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
329 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
330 |
contextPrototype.moveTo = function(aX, aY) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
331 |
var p = this.getCoords_(aX, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
332 |
this.currentPath_.push({type: 'moveTo', x: p.x, y: p.y}); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
333 |
this.currentX_ = p.x; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
334 |
this.currentY_ = p.y; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
335 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
336 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
337 |
contextPrototype.lineTo = function(aX, aY) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
338 |
var p = this.getCoords_(aX, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
339 |
this.currentPath_.push({type: 'lineTo', x: p.x, y: p.y}); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
340 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
341 |
this.currentX_ = p.x; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
342 |
this.currentY_ = p.y; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
343 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
344 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
345 |
contextPrototype.bezierCurveTo = function(aCP1x, aCP1y, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
346 |
aCP2x, aCP2y, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
347 |
aX, aY) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
348 |
var p = this.getCoords_(aX, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
349 |
var cp1 = this.getCoords_(aCP1x, aCP1y); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
350 |
var cp2 = this.getCoords_(aCP2x, aCP2y); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
351 |
bezierCurveTo(this, cp1, cp2, p); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
352 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
353 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
354 |
// Helper function that takes the already fixed cordinates. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
355 |
function bezierCurveTo(self, cp1, cp2, p) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
356 |
self.currentPath_.push({ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
357 |
type: 'bezierCurveTo', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
358 |
cp1x: cp1.x, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
359 |
cp1y: cp1.y, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
360 |
cp2x: cp2.x, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
361 |
cp2y: cp2.y, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
362 |
x: p.x, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
363 |
y: p.y |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
364 |
}); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
365 |
self.currentX_ = p.x; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
366 |
self.currentY_ = p.y; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
367 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
368 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
369 |
contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
370 |
// the following is lifted almost directly from |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
371 |
// http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
372 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
373 |
var cp = this.getCoords_(aCPx, aCPy); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
374 |
var p = this.getCoords_(aX, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
375 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
376 |
var cp1 = { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
377 |
x: this.currentX_ + 2.0 / 3.0 * (cp.x - this.currentX_), |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
378 |
y: this.currentY_ + 2.0 / 3.0 * (cp.y - this.currentY_) |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
379 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
380 |
var cp2 = { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
381 |
x: cp1.x + (p.x - this.currentX_) / 3.0, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
382 |
y: cp1.y + (p.y - this.currentY_) / 3.0 |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
383 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
384 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
385 |
bezierCurveTo(this, cp1, cp2, p); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
386 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
387 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
388 |
contextPrototype.arc = function(aX, aY, aRadius, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
389 |
aStartAngle, aEndAngle, aClockwise) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
390 |
aRadius *= Z; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
391 |
var arcType = aClockwise ? 'at' : 'wa'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
392 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
393 |
var xStart = aX + mc(aStartAngle) * aRadius - Z2; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
394 |
var yStart = aY + ms(aStartAngle) * aRadius - Z2; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
395 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
396 |
var xEnd = aX + mc(aEndAngle) * aRadius - Z2; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
397 |
var yEnd = aY + ms(aEndAngle) * aRadius - Z2; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
398 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
399 |
// IE won't render arches drawn counter clockwise if xStart == xEnd. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
400 |
if (xStart == xEnd && !aClockwise) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
401 |
xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
402 |
// that can be represented in binary |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
403 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
404 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
405 |
var p = this.getCoords_(aX, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
406 |
var pStart = this.getCoords_(xStart, yStart); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
407 |
var pEnd = this.getCoords_(xEnd, yEnd); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
408 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
409 |
this.currentPath_.push({type: arcType, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
410 |
x: p.x, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
411 |
y: p.y, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
412 |
radius: aRadius, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
413 |
xStart: pStart.x, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
414 |
yStart: pStart.y, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
415 |
xEnd: pEnd.x, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
416 |
yEnd: pEnd.y}); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
417 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
418 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
419 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
420 |
contextPrototype.rect = function(aX, aY, aWidth, aHeight) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
421 |
this.moveTo(aX, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
422 |
this.lineTo(aX + aWidth, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
423 |
this.lineTo(aX + aWidth, aY + aHeight); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
424 |
this.lineTo(aX, aY + aHeight); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
425 |
this.closePath(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
426 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
427 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
428 |
contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
429 |
var oldPath = this.currentPath_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
430 |
this.beginPath(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
431 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
432 |
this.moveTo(aX, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
433 |
this.lineTo(aX + aWidth, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
434 |
this.lineTo(aX + aWidth, aY + aHeight); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
435 |
this.lineTo(aX, aY + aHeight); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
436 |
this.closePath(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
437 |
this.stroke(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
438 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
439 |
this.currentPath_ = oldPath; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
440 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
441 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
442 |
contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
443 |
var oldPath = this.currentPath_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
444 |
this.beginPath(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
445 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
446 |
this.moveTo(aX, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
447 |
this.lineTo(aX + aWidth, aY); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
448 |
this.lineTo(aX + aWidth, aY + aHeight); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
449 |
this.lineTo(aX, aY + aHeight); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
450 |
this.closePath(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
451 |
this.fill(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
452 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
453 |
this.currentPath_ = oldPath; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
454 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
455 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
456 |
contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
457 |
var gradient = new CanvasGradient_('gradient'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
458 |
gradient.x0_ = aX0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
459 |
gradient.y0_ = aY0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
460 |
gradient.x1_ = aX1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
461 |
gradient.y1_ = aY1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
462 |
return gradient; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
463 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
464 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
465 |
contextPrototype.createRadialGradient = function(aX0, aY0, aR0, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
466 |
aX1, aY1, aR1) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
467 |
var gradient = new CanvasGradient_('gradientradial'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
468 |
gradient.x0_ = aX0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
469 |
gradient.y0_ = aY0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
470 |
gradient.r0_ = aR0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
471 |
gradient.x1_ = aX1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
472 |
gradient.y1_ = aY1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
473 |
gradient.r1_ = aR1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
474 |
return gradient; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
475 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
476 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
477 |
contextPrototype.drawImage = function(image, var_args) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
478 |
var dx, dy, dw, dh, sx, sy, sw, sh; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
479 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
480 |
// to find the original width we overide the width and height |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
481 |
var oldRuntimeWidth = image.runtimeStyle.width; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
482 |
var oldRuntimeHeight = image.runtimeStyle.height; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
483 |
image.runtimeStyle.width = 'auto'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
484 |
image.runtimeStyle.height = 'auto'; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
485 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
486 |
// get the original size |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
487 |
var w = image.width; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
488 |
var h = image.height; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
489 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
490 |
// and remove overides |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
491 |
image.runtimeStyle.width = oldRuntimeWidth; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
492 |
image.runtimeStyle.height = oldRuntimeHeight; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
493 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
494 |
if (arguments.length == 3) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
495 |
dx = arguments[1]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
496 |
dy = arguments[2]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
497 |
sx = sy = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
498 |
sw = dw = w; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
499 |
sh = dh = h; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
500 |
} else if (arguments.length == 5) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
501 |
dx = arguments[1]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
502 |
dy = arguments[2]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
503 |
dw = arguments[3]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
504 |
dh = arguments[4]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
505 |
sx = sy = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
506 |
sw = w; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
507 |
sh = h; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
508 |
} else if (arguments.length == 9) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
509 |
sx = arguments[1]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
510 |
sy = arguments[2]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
511 |
sw = arguments[3]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
512 |
sh = arguments[4]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
513 |
dx = arguments[5]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
514 |
dy = arguments[6]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
515 |
dw = arguments[7]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
516 |
dh = arguments[8]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
517 |
} else { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
518 |
throw Error('Invalid number of arguments'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
519 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
520 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
521 |
var d = this.getCoords_(dx, dy); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
522 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
523 |
var w2 = sw / 2; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
524 |
var h2 = sh / 2; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
525 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
526 |
var vmlStr = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
527 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
528 |
var W = 10; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
529 |
var H = 10; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
530 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
531 |
// For some reason that I've now forgotten, using divs didn't work |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
532 |
vmlStr.push(' <g_vml_:group', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
533 |
' coordsize="', Z * W, ',', Z * H, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
534 |
' coordorigin="0,0"' , |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
535 |
' style="width:', W, 'px;height:', H, 'px;position:absolute;'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
536 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
537 |
// If filters are necessary (rotation exists), create them |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
538 |
// filters are bog-slow, so only create them if abbsolutely necessary |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
539 |
// The following check doesn't account for skews (which don't exist |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
540 |
// in the canvas spec (yet) anyway. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
541 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
542 |
if (this.m_[0][0] != 1 || this.m_[0][1]) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
543 |
var filter = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
544 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
545 |
// Note the 12/21 reversal |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
546 |
filter.push('M11=', this.m_[0][0], ',', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
547 |
'M12=', this.m_[1][0], ',', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
548 |
'M21=', this.m_[0][1], ',', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
549 |
'M22=', this.m_[1][1], ',', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
550 |
'Dx=', mr(d.x / Z), ',', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
551 |
'Dy=', mr(d.y / Z), ''); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
552 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
553 |
// Bounding box calculation (need to minimize displayed area so that |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
554 |
// filters don't waste time on unused pixels. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
555 |
var max = d; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
556 |
var c2 = this.getCoords_(dx + dw, dy); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
557 |
var c3 = this.getCoords_(dx, dy + dh); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
558 |
var c4 = this.getCoords_(dx + dw, dy + dh); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
559 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
560 |
max.x = m.max(max.x, c2.x, c3.x, c4.x); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
561 |
max.y = m.max(max.y, c2.y, c3.y, c4.y); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
562 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
563 |
vmlStr.push('padding:0 ', mr(max.x / Z), 'px ', mr(max.y / Z), |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
564 |
'px 0;filter:progid:DXImageTransform.Microsoft.Matrix(', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
565 |
filter.join(''), ", sizingmethod='clip');") |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
566 |
} else { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
567 |
vmlStr.push('top:', mr(d.y / Z), 'px;left:', mr(d.x / Z), 'px;'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
568 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
569 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
570 |
vmlStr.push(' ">' , |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
571 |
'<g_vml_:image src="', image.src, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
572 |
' style="width:', Z * dw, 'px;', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
573 |
' height:', Z * dh, 'px;"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
574 |
' cropleft="', sx / w, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
575 |
' croptop="', sy / h, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
576 |
' cropright="', (w - sx - sw) / w, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
577 |
' cropbottom="', (h - sy - sh) / h, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
578 |
' />', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
579 |
'</g_vml_:group>'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
580 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
581 |
this.element_.insertAdjacentHTML('BeforeEnd', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
582 |
vmlStr.join('')); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
583 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
584 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
585 |
contextPrototype.stroke = function(aFill) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
586 |
var lineStr = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
587 |
var lineOpen = false; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
588 |
var a = processStyle(aFill ? this.fillStyle : this.strokeStyle); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
589 |
var color = a.color; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
590 |
var opacity = a.alpha * this.globalAlpha; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
591 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
592 |
var W = 10; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
593 |
var H = 10; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
594 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
595 |
lineStr.push('<g_vml_:shape', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
596 |
' filled="', !!aFill, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
597 |
' style="position:absolute;width:', W, 'px;height:', H, 'px;"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
598 |
' coordorigin="0 0" coordsize="', Z * W, ' ', Z * H, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
599 |
' stroked="', !aFill, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
600 |
' path="'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
601 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
602 |
var newSeq = false; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
603 |
var min = {x: null, y: null}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
604 |
var max = {x: null, y: null}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
605 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
606 |
for (var i = 0; i < this.currentPath_.length; i++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
607 |
var p = this.currentPath_[i]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
608 |
var c; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
609 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
610 |
switch (p.type) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
611 |
case 'moveTo': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
612 |
c = p; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
613 |
lineStr.push(' m ', mr(p.x), ',', mr(p.y)); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
614 |
break; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
615 |
case 'lineTo': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
616 |
lineStr.push(' l ', mr(p.x), ',', mr(p.y)); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
617 |
break; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
618 |
case 'close': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
619 |
lineStr.push(' x '); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
620 |
p = null; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
621 |
break; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
622 |
case 'bezierCurveTo': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
623 |
lineStr.push(' c ', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
624 |
mr(p.cp1x), ',', mr(p.cp1y), ',', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
625 |
mr(p.cp2x), ',', mr(p.cp2y), ',', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
626 |
mr(p.x), ',', mr(p.y)); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
627 |
break; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
628 |
case 'at': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
629 |
case 'wa': |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
630 |
lineStr.push(' ', p.type, ' ', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
631 |
mr(p.x - this.arcScaleX_ * p.radius), ',', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
632 |
mr(p.y - this.arcScaleY_ * p.radius), ' ', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
633 |
mr(p.x + this.arcScaleX_ * p.radius), ',', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
634 |
mr(p.y + this.arcScaleY_ * p.radius), ' ', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
635 |
mr(p.xStart), ',', mr(p.yStart), ' ', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
636 |
mr(p.xEnd), ',', mr(p.yEnd)); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
637 |
break; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
638 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
639 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
640 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
641 |
// TODO: Following is broken for curves due to |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
642 |
// move to proper paths. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
643 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
644 |
// Figure out dimensions so we can do gradient fills |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
645 |
// properly |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
646 |
if (p) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
647 |
if (min.x == null || p.x < min.x) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
648 |
min.x = p.x; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
649 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
650 |
if (max.x == null || p.x > max.x) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
651 |
max.x = p.x; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
652 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
653 |
if (min.y == null || p.y < min.y) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
654 |
min.y = p.y; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
655 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
656 |
if (max.y == null || p.y > max.y) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
657 |
max.y = p.y; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
658 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
659 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
660 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
661 |
lineStr.push(' ">'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
662 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
663 |
if (!aFill) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
664 |
var lineWidth = this.lineScale_ * this.lineWidth; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
665 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
666 |
// VML cannot correctly render a line if the width is less than 1px. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
667 |
// In that case, we dilute the color to make the line look thinner. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
668 |
if (lineWidth < 1) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
669 |
opacity *= lineWidth; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
670 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
671 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
672 |
lineStr.push( |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
673 |
'<g_vml_:stroke', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
674 |
' opacity="', opacity, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
675 |
' joinstyle="', this.lineJoin, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
676 |
' miterlimit="', this.miterLimit, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
677 |
' endcap="', processLineCap(this.lineCap), '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
678 |
' weight="', lineWidth, 'px"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
679 |
' color="', color, '" />' |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
680 |
); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
681 |
} else if (typeof this.fillStyle == 'object') { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
682 |
var fillStyle = this.fillStyle; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
683 |
var angle = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
684 |
var focus = {x: 0, y: 0}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
685 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
686 |
// additional offset |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
687 |
var shift = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
688 |
// scale factor for offset |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
689 |
var expansion = 1; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
690 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
691 |
if (fillStyle.type_ == 'gradient') { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
692 |
var x0 = fillStyle.x0_ / this.arcScaleX_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
693 |
var y0 = fillStyle.y0_ / this.arcScaleY_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
694 |
var x1 = fillStyle.x1_ / this.arcScaleX_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
695 |
var y1 = fillStyle.y1_ / this.arcScaleY_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
696 |
var p0 = this.getCoords_(x0, y0); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
697 |
var p1 = this.getCoords_(x1, y1); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
698 |
var dx = p1.x - p0.x; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
699 |
var dy = p1.y - p0.y; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
700 |
angle = Math.atan2(dx, dy) * 180 / Math.PI; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
701 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
702 |
// The angle should be a non-negative number. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
703 |
if (angle < 0) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
704 |
angle += 360; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
705 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
706 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
707 |
// Very small angles produce an unexpected result because they are |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
708 |
// converted to a scientific notation string. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
709 |
if (angle < 1e-6) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
710 |
angle = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
711 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
712 |
} else { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
713 |
var p0 = this.getCoords_(fillStyle.x0_, fillStyle.y0_); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
714 |
var width = max.x - min.x; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
715 |
var height = max.y - min.y; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
716 |
focus = { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
717 |
x: (p0.x - min.x) / width, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
718 |
y: (p0.y - min.y) / height |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
719 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
720 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
721 |
width /= this.arcScaleX_ * Z; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
722 |
height /= this.arcScaleY_ * Z; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
723 |
var dimension = m.max(width, height); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
724 |
shift = 2 * fillStyle.r0_ / dimension; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
725 |
expansion = 2 * fillStyle.r1_ / dimension - shift; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
726 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
727 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
728 |
// We need to sort the color stops in ascending order by offset, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
729 |
// otherwise IE won't interpret it correctly. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
730 |
var stops = fillStyle.colors_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
731 |
stops.sort(function(cs1, cs2) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
732 |
return cs1.offset - cs2.offset; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
733 |
}); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
734 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
735 |
var length = stops.length; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
736 |
var color1 = stops[0].color; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
737 |
var color2 = stops[length - 1].color; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
738 |
var opacity1 = stops[0].alpha * this.globalAlpha; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
739 |
var opacity2 = stops[length - 1].alpha * this.globalAlpha; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
740 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
741 |
var colors = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
742 |
for (var i = 0; i < length; i++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
743 |
var stop = stops[i]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
744 |
colors.push(stop.offset * expansion + shift + ' ' + stop.color); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
745 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
746 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
747 |
// When colors attribute is used, the meanings of opacity and o:opacity2 |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
748 |
// are reversed. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
749 |
lineStr.push('<g_vml_:fill type="', fillStyle.type_, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
750 |
' method="none" focus="100%"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
751 |
' color="', color1, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
752 |
' color2="', color2, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
753 |
' colors="', colors.join(','), '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
754 |
' opacity="', opacity2, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
755 |
' g_o_:opacity2="', opacity1, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
756 |
' angle="', angle, '"', |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
757 |
' focusposition="', focus.x, ',', focus.y, '" />'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
758 |
} else { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
759 |
lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
760 |
'" />'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
761 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
762 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
763 |
lineStr.push('</g_vml_:shape>'); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
764 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
765 |
this.element_.insertAdjacentHTML('beforeEnd', lineStr.join('')); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
766 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
767 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
768 |
contextPrototype.fill = function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
769 |
this.stroke(true); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
770 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
771 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
772 |
contextPrototype.closePath = function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
773 |
this.currentPath_.push({type: 'close'}); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
774 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
775 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
776 |
/** |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
777 |
* @private |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
778 |
*/ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
779 |
contextPrototype.getCoords_ = function(aX, aY) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
780 |
var m = this.m_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
781 |
return { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
782 |
x: Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
783 |
y: Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2 |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
784 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
785 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
786 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
787 |
contextPrototype.save = function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
788 |
var o = {}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
789 |
copyState(this, o); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
790 |
this.aStack_.push(o); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
791 |
this.mStack_.push(this.m_); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
792 |
this.m_ = matrixMultiply(createMatrixIdentity(), this.m_); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
793 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
794 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
795 |
contextPrototype.restore = function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
796 |
copyState(this.aStack_.pop(), this); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
797 |
this.m_ = this.mStack_.pop(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
798 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
799 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
800 |
function matrixIsFinite(m) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
801 |
for (var j = 0; j < 3; j++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
802 |
for (var k = 0; k < 2; k++) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
803 |
if (!isFinite(m[j][k]) || isNaN(m[j][k])) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
804 |
return false; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
805 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
806 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
807 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
808 |
return true; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
809 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
810 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
811 |
function setM(ctx, m, updateLineScale) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
812 |
if (!matrixIsFinite(m)) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
813 |
return; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
814 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
815 |
ctx.m_ = m; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
816 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
817 |
if (updateLineScale) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
818 |
// Get the line scale. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
819 |
// Determinant of this.m_ means how much the area is enlarged by the |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
820 |
// transformation. So its square root can be used as a scale factor |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
821 |
// for width. |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
822 |
var det = m[0][0] * m[1][1] - m[0][1] * m[1][0]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
823 |
ctx.lineScale_ = sqrt(abs(det)); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
824 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
825 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
826 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
827 |
contextPrototype.translate = function(aX, aY) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
828 |
var m1 = [ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
829 |
[1, 0, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
830 |
[0, 1, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
831 |
[aX, aY, 1] |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
832 |
]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
833 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
834 |
setM(this, matrixMultiply(m1, this.m_), false); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
835 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
836 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
837 |
contextPrototype.rotate = function(aRot) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
838 |
var c = mc(aRot); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
839 |
var s = ms(aRot); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
840 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
841 |
var m1 = [ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
842 |
[c, s, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
843 |
[-s, c, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
844 |
[0, 0, 1] |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
845 |
]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
846 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
847 |
setM(this, matrixMultiply(m1, this.m_), false); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
848 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
849 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
850 |
contextPrototype.scale = function(aX, aY) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
851 |
this.arcScaleX_ *= aX; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
852 |
this.arcScaleY_ *= aY; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
853 |
var m1 = [ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
854 |
[aX, 0, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
855 |
[0, aY, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
856 |
[0, 0, 1] |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
857 |
]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
858 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
859 |
setM(this, matrixMultiply(m1, this.m_), true); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
860 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
861 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
862 |
contextPrototype.transform = function(m11, m12, m21, m22, dx, dy) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
863 |
var m1 = [ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
864 |
[m11, m12, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
865 |
[m21, m22, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
866 |
[dx, dy, 1] |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
867 |
]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
868 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
869 |
setM(this, matrixMultiply(m1, this.m_), true); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
870 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
871 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
872 |
contextPrototype.setTransform = function(m11, m12, m21, m22, dx, dy) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
873 |
var m = [ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
874 |
[m11, m12, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
875 |
[m21, m22, 0], |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
876 |
[dx, dy, 1] |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
877 |
]; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
878 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
879 |
setM(this, m, true); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
880 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
881 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
882 |
/******** STUBS ********/ |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
883 |
contextPrototype.clip = function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
884 |
// TODO: Implement |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
885 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
886 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
887 |
contextPrototype.arcTo = function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
888 |
// TODO: Implement |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
889 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
890 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
891 |
contextPrototype.createPattern = function() { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
892 |
return new CanvasPattern_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
893 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
894 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
895 |
// Gradient / Pattern Stubs |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
896 |
function CanvasGradient_(aType) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
897 |
this.type_ = aType; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
898 |
this.x0_ = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
899 |
this.y0_ = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
900 |
this.r0_ = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
901 |
this.x1_ = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
902 |
this.y1_ = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
903 |
this.r1_ = 0; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
904 |
this.colors_ = []; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
905 |
} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
906 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
907 |
CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) { |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
908 |
aColor = processStyle(aColor); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
909 |
this.colors_.push({offset: aOffset, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
910 |
color: aColor.color, |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
911 |
alpha: aColor.alpha}); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
912 |
}; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
913 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
914 |
function CanvasPattern_() {} |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
915 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
916 |
// set up externs |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
917 |
G_vmlCanvasManager = G_vmlCanvasManager_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
918 |
CanvasRenderingContext2D = CanvasRenderingContext2D_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
919 |
CanvasGradient = CanvasGradient_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
920 |
CanvasPattern = CanvasPattern_; |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
921 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
922 |
})(); |
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
923 |
|
2a74c5af892f
hgweb: replace excanvas.js with a newer version
Javi Merino <cibervicho@gmail.com>
parents:
9999
diff
changeset
|
924 |
} // if |