3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
8 <link rel="import" href="/base/rect.html">
12 tv.exportTo('cc', function() {
20 Region.fromArray = function(array) {
21 if (array.length % 4 != 0)
22 throw new Error('Array must consist be a multiple of 4 in length');
25 for (var i = 0; i < array.length; i += 4) {
26 r.rects.push(tv.Rect.fromXYWH(array[i], array[i + 1],
27 array[i + 2], array[i + 3]));
33 * @return {Region} If array is undefined, returns an empty region. Otherwise
34 * returns Region.fromArray(array).
36 Region.fromArrayOrUndefined = function(array) {
37 if (array === undefined)
39 return Region.fromArray(array);
43 __proto__: Region.prototype,
45 rectIntersects: function(r) {
46 for (var i = 0; i < this.rects.length; i++) {
47 if (this.rects[i].intersects(r))
53 addRect: function(r) {