Sg 2.9
Size
Packages RSS
About
News
Gallery
Scripts
Tutorials
Download
Reference
Forum
Users
License
Twitter

Constructors

    Parameters:
  • width: Number — optional
  • height: Number — optional

Creates a Size object with the given value for both width and height.

    Parameters:
  • size: Number — The width and height of the Size

Creates a Size object using the x and y coordinates of the given Point object.

Sample code:

var point = new Point(50, 50);
var size = new Size(point);
print(size.width); // 50
print(size.height); // 50

Creates a Size object using the width and height of the given Size object.

    Parameters:
  • size: Size

Operators

Returns the addition of the width and height of the supplied size to the size as a new size. The object itself is not modified!

Sample code:

var firstSize = new Size(8, 10);
var secondSize = new Size(2, 5);
var result = firstSize + secondSize;
print(result); // { width: 10.0, height: 15.0 }

Returns the addition of the supplied value to the width and height of the size as a new size. The object itself is not modified!

Sample code:

var point = new Size(10, 20);
var result = size + 5;
print(result); // { width: 15.0, height: 25.0 }
    Returns:
  • Size — the addition of the size and the value as a new size

Returns the subtraction of the width and height of the supplied size from the size as a new size. The object itself is not modified!

Sample code:

var firstSize = new Size(8, 10);
var secondSize = new Size(2, 5);
var result = firstSize - secondSize;
print(result); // { width: 6.0, height: 5.0 }

Returns the subtraction of the supplied value from the width and height of the size as a new size. The object itself is not modified!

Sample code:

var point = new Size(10, 20);
var result = size - 5;
print(result); // { width: 5.0, height: 15.0 }
    Returns:
  • Size — the subtraction of the value from the size as a new size

Returns the multiplication of the width and height of the supplied size with the size as a new size. The object itself is not modified!

Sample code:

var firstSize = new Size(8, 10);
var secondSize = new Size(2, 5);
var result = firstSize * secondSize;
print(result); // { width: 16.0, height: 50.0 }

Returns the multiplication of the supplied value with the width and height of the size as a new size. The object itself is not modified!

Sample code:

var point = new Size(10, 20);
var result = size * 2;
print(result); // { width: 20.0, height: 40.0 }
    Returns:
  • Size — the multiplication of the size by the value as a new size

Returns the division of the width and height of the supplied size by the size as a new size. The object itself is not modified!

Sample code:

var firstSize = new Size(8, 10);
var secondSize = new Size(2, 5);
var result = firstSize / secondSize;
print(result); // { width: 4.0, height: 2.0 }

Returns the division of the supplied value by the width and height of the size as a new size. The object itself is not modified!

Sample code:

var point = new Size(10, 20);
var result = size / 2;
print(result); // { width: 5.0, height: 10.0 }
    Returns:
  • Size — the division of the size by the value as a new size

The modulo operator returns the integer remainders of dividing the size by the supplied size as a new size.

Sample code:

var size = new Size(12, 6);
print(size % new Size(5, 2)); // {width: 2, height: 0}
    Returns:
  • Size — the integer remainders of dividing the sizes by each other as a new size

The modulo operator returns the integer remainders of dividing the size by the supplied value as a new size.

Sample code:

var size = new Size(12, 6);
print(size % 5); // {width: 2, height: 1}
    Returns:
  • Size — the integer remainders of dividing the size by the value as a new size

Checks whether the width and height of the size are equal to those of the supplied size.

Sample code:

var size = new Size(5, 10);
print(size == new Size(5, 10)); // true
print(size == new Size(1, 1)); // false
print(size != new Size(1, 1)); // true
    Returns:
  • Boolean

Properties

The width of the size.

    Returns:
  • Number

The height of the size.

    Returns:
  • Number

Functions

Returns a copy of the size. This is useful as the following code only generates a flat copy:

var size2 = new Size();
var size2 = size1;
size2.x = 1; // also changes size1.x
var size2 = size1.clone();
size2.x = 1; // doesn't change size1.x
    Returns:
  • Size — the cloned size object

Math Functions

Returns a new size with rounded width and height values. The object itself is not modified!

Sample code:

var size = new Size(10.2, 10.9);
var roundSize = size.round();
print(roundSize); // { width: 10.0, height: 11.0 }

Returns a new size with the nearest greater non-fractional values to the specified width and height values. The object itself is not modified!

Sample code:

var size = new Size(10.2, 10.9);
var ceilSize = size.ceil();
print(ceilSize); // { width: 11.0, height: 11.0 }

Returns a new size with the nearest smaller non-fractional values to the specified width and height values. The object itself is not modified!

Sample code:

var size = new Size(10.2, 10.9);
var floorSize = size.floor();
print(floorSize); // { width: 10.0, height: 10.0 }

Returns a new size with the absolute values of the specified width and height values. The object itself is not modified!

Sample code:

var size = new Size(-5, 10);
var absSize = size.abs();
print(absSize); // { width: 5.0, height: 10.0 }

Static Functions

Returns a new size object with the smallest width and height of the supplied sizes.

Sample code:

var size1 = new Size(10, 100);
var size2 = new Size(200, 5);
var minSize = Size.min(size1, size2);
print(minSize); // { width: 10.0, height: 5.0 }
    Returns:
  • Size — The newly created size object

Returns a new size object with the largest width and height of the supplied sizes.

Sample code:

var size1 = new Size(10, 100);
var size2 = new Size(200, 5);
var maxSize = Size.max(size1, size2);
print(maxSize); // { width: 200.0, height: 100.0 }
    Returns:
  • Size — The newly created size object

Returns a size object with random width and height values between 0 and 1.

Sample code:

var maxSize = new Size(100, 100);
var randomSize = Size.random();
var size = maxSize * randomSize;

AltStyle によって変換されたページ (->オリジナル) /