Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate

Issue 25808002: Move Rectangle and Point into dart:math. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 7 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
8 $!MEMBERS 8 $!MEMBERS
9 9
10 /** 10 /**
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 * If the image is larger than canvas 61 * If the image is larger than canvas
62 * will allow, the image will be clipped to fit the available space. 62 * will allow, the image will be clipped to fit the available space.
63 * 63 *
64 * CanvasElement canvas = new CanvasElement(width: 600, height: 600); 64 * CanvasElement canvas = new CanvasElement(width: 600, height: 600);
65 * CanvasRenderingContext2D ctx = canvas.context2D; 65 * CanvasRenderingContext2D ctx = canvas.context2D;
66 * ImageElement img = document.query('img'); 66 * ImageElement img = document.query('img');
67 * img.width = 100; 67 * img.width = 100;
68 * img.height = 100; 68 * img.height = 100;
69 * 69 *
70 * // Scale the image to 20x20. 70 * // Scale the image to 20x20.
71 * ctx.drawImageToRect(img, new Rect(50, 50, 20, 20)); 71 * ctx.drawImageToRect(img, new Rectangle(50, 50, 20, 20));
72 * 72 *
73 * VideoElement video = document.query('video'); 73 * VideoElement video = document.query('video');
74 * video.width = 100; 74 * video.width = 100;
75 * video.height = 100; 75 * video.height = 100;
76 * // Take the middle 20x20 pixels from the video and stretch them. 76 * // Take the middle 20x20 pixels from the video and stretch them.
77 * ctx.drawImageToRect(video, new Rect(50, 50, 100, 100), 77 * ctx.drawImageToRect(video, new Rectangle(50, 50, 100, 100),
78 * sourceRect: new Rect(40, 40, 20, 20)); 78 * sourceRect: new Rectangle(40, 40, 20, 20));
79 * 79 *
80 * // Draw the top 100x20 pixels from the otherCanvas. 80 * // Draw the top 100x20 pixels from the otherCanvas.
81 * CanvasElement otherCanvas = document.query('canvas'); 81 * CanvasElement otherCanvas = document.query('canvas');
82 * ctx.drawImageToRect(otherCanvas, new Rect(0, 0, 100, 20), 82 * ctx.drawImageToRect(otherCanvas, new Rectangle(0, 0, 100, 20),
83 * sourceRect: new Rect(0, 0, 100, 20)); 83 * sourceRect: new Rectangle(0, 0, 100, 20));
84 * 84 *
85 * See also: 85 * See also:
86 * 86 *
87 * * [CanvasImageSource] for more information on what data is retrieved 87 * * [CanvasImageSource] for more information on what data is retrieved
88 * from [source]. 88 * from [source].
89 * * [drawImage](http://www.whatwg.org/specs/web-apps/current-work/multipage /the-canvas-element.html#dom-context-2d-drawimage) 89 * * [drawImage](http://www.whatwg.org/specs/web-apps/current-work/multipage /the-canvas-element.html#dom-context-2d-drawimage)
90 * from the WHATWG. 90 * from the WHATWG.
91 */ 91 */
92 @DomName('CanvasRenderingContext2D.drawImage') 92 @DomName('CanvasRenderingContext2D.drawImage')
93 void drawImageToRect(CanvasImageSource source, Rect destRect, 93 void drawImageToRect(CanvasImageSource source, Rectangle destRect,
94 {Rect sourceRect}) { 94 {Rectangle sourceRect}) {
95 $if DART2JS 95 $if DART2JS
96 if (sourceRect == null) { 96 if (sourceRect == null) {
97 drawImageScaled(source, 97 drawImageScaled(source,
98 destRect.left, 98 destRect.left,
99 destRect.top, 99 destRect.top,
100 destRect.width, 100 destRect.width,
101 destRect.height); 101 destRect.height);
102 } else { 102 } else {
103 drawImageScaledFromSource(source, 103 drawImageScaledFromSource(source,
104 sourceRect.left, 104 sourceRect.left,
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 @DomName('CanvasRenderingContext2D.lineDashOffset') 260 @DomName('CanvasRenderingContext2D.lineDashOffset')
261 void set lineDashOffset(num value) => JS('void', 261 void set lineDashOffset(num value) => JS('void',
262 'typeof #.lineDashOffset != "undefined" ? #.lineDashOffset = # : ' 262 'typeof #.lineDashOffset != "undefined" ? #.lineDashOffset = # : '
263 '#.webkitLineDashOffset = #', this, this, value, this, value); 263 '#.webkitLineDashOffset = #', this, this, value, this, value);
264 $else 264 $else
265 // TODO(amouravski): Add Dartium native methods for drawImage once we figure 265 // TODO(amouravski): Add Dartium native methods for drawImage once we figure
266 // out how to not break native bindings. 266 // out how to not break native bindings.
267 $endif 267 $endif
268 } 268 }
269 269
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698