OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 // Namespace object for the utilities. | 6 // Namespace object for the utilities. |
7 function ImageUtil() {} | 7 function ImageUtil() {} |
8 | 8 |
9 /** | 9 /** |
10 * Performance trace. | 10 * Performance trace. |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 context.fillRect(rect.left, rect.top, rect.width, rect.height); | 295 context.fillRect(rect.left, rect.top, rect.width, rect.height); |
296 }; | 296 }; |
297 | 297 |
298 /** | 298 /** |
299 * Fills the space between the two rectangles. | 299 * Fills the space between the two rectangles. |
300 * @param {CanvasRenderingContext2D} context Context to draw. | 300 * @param {CanvasRenderingContext2D} context Context to draw. |
301 * @param {Rect} inner Inner rectangle. | 301 * @param {Rect} inner Inner rectangle. |
302 * @param {Rect} outer Outer rectangle. | 302 * @param {Rect} outer Outer rectangle. |
303 */ | 303 */ |
304 Rect.fillBetween = function(context, inner, outer) { | 304 Rect.fillBetween = function(context, inner, outer) { |
305 var inner_right = inner.left + inner.width; | 305 var innerRight = inner.left + inner.width; |
306 var inner_bottom = inner.top + inner.height; | 306 var innerBottom = inner.top + inner.height; |
307 var outer_right = outer.left + outer.width; | 307 var outerRight = outer.left + outer.width; |
308 var outer_bottom = outer.top + outer.height; | 308 var outerBottom = outer.top + outer.height; |
309 if (inner.top > outer.top) { | 309 if (inner.top > outer.top) { |
310 context.fillRect( | 310 context.fillRect( |
311 outer.left, outer.top, outer.width, inner.top - outer.top); | 311 outer.left, outer.top, outer.width, inner.top - outer.top); |
312 } | 312 } |
313 if (inner.left > outer.left) { | 313 if (inner.left > outer.left) { |
314 context.fillRect( | 314 context.fillRect( |
315 outer.left, inner.top, inner.left - outer.left, inner.height); | 315 outer.left, inner.top, inner.left - outer.left, inner.height); |
316 } | 316 } |
317 if (inner.width < outer_right) { | 317 if (inner.width < outerRight) { |
318 context.fillRect( | 318 context.fillRect( |
319 inner_right, inner.top, outer_right - inner_right, inner.height); | 319 innerRight, inner.top, outerRight - innerRight, inner.height); |
320 } | 320 } |
321 if (inner.height < outer_bottom) { | 321 if (inner.height < outerBottom) { |
322 context.fillRect( | 322 context.fillRect( |
323 outer.left, inner_bottom, outer.width, outer_bottom - inner_bottom); | 323 outer.left, innerBottom, outer.width, outerBottom - innerBottom); |
324 } | 324 } |
325 }; | 325 }; |
326 | 326 |
327 /** | 327 /** |
328 * Circle class. | 328 * Circle class. |
329 * @param {number} x X coordinate of circle center. | 329 * @param {number} x X coordinate of circle center. |
330 * @param {number} y Y coordinate of circle center. | 330 * @param {number} y Y coordinate of circle center. |
331 * @param {number} r Radius. | 331 * @param {number} r Radius. |
332 * @constructor | 332 * @constructor |
333 */ | 333 */ |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 * @return {string} Full name. | 669 * @return {string} Full name. |
670 */ | 670 */ |
671 ImageUtil.getMetricName = function(name) { | 671 ImageUtil.getMetricName = function(name) { |
672 return 'PhotoEditor.' + name; | 672 return 'PhotoEditor.' + name; |
673 }; | 673 }; |
674 | 674 |
675 /** | 675 /** |
676 * Used for metrics reporting, keep in sync with the histogram description. | 676 * Used for metrics reporting, keep in sync with the histogram description. |
677 */ | 677 */ |
678 ImageUtil.FILE_TYPES = ['jpg', 'png', 'gif', 'bmp', 'webp']; | 678 ImageUtil.FILE_TYPES = ['jpg', 'png', 'gif', 'bmp', 'webp']; |
OLD | NEW |