Class: Pixel

SuperMap.Pixel

This class represents a screen coordinate, in x and y coordinates (pixel).

new SuperMap.Pixel(x, y, mode)

Pixel.js, line 3
Name Type Default Description
x number 0.0 optional

The x coordinate.

y number 0.0 optional

The y coordinate.

mode SuperMap.Pixel.Mode SuperMap.Pixel.Mode.LeftTop optional

Coordinate mode.

Example
//Create a single object
var pixcel = new SuperMap.Pixel(100,50);

//Created by size
 var size = new SuperMap.Size(21,25);
 var offset = new SuperMap.Pixel(-(size.w/2), -size.h);

Members

SuperMap.Pixel.Modestring

mode.

Coordinate mode: top-left, top-right, button-left, button-right.

Default Value:
SuperMap.Pixel.Mode.LeftTop

xnumber

he x coordinate.

Default Value:
0.0

ynumber

The y coordinate.

Default Value:
0.0

Methods

add(x, y){SuperMap.Pixel}

Pixel.js, line 124

Based on the original pixel coordinates, the x value is added to the passed x parameter, and the y value is added to the passed y parameter.

Name Type Description
x number

x value.

y number

y value.

Returns:
Type Description
SuperMap.Pixel Returns a new pixel object that is added by the current pixel and the passed x,y.
Example
var pixcel = new SuperMap.Pixel(100,50);
//pixcel2 is a new object
var pixcel2 = pixcel.add(20,30);

clone(){SuperMap.Pixel}

Pixel.js, line 74

Return a clone of this pixel object.

Returns:
Type Description
SuperMap.Pixel Return a new pixel object with the same x, y coordinates.
Example
var pixcel = new SuperMap.Pixel(100,50);
var pixcel2 = pixcel.clone();

destroy()

Pixel.js, line 163

Destroy the object. All properties of the object will be null after it is destroyed.

Example
var pixcel = new SuperMap.Pixel(100,50);
pixcel.destroy();

distanceTo(px){float}

Pixel.js, line 106

Returns the distance of the two pixel points.

Name Type Description
px SuperMap.Pixel

A pixel that is used to calculate.

Returns:
Type Description
float The distance between the incoming pixel and the current pixel.
Example
var pixcel = new SuperMap.Pixel(100,50);
var pixcel2 = new SuperMap.Pixel(110,30);
var distance = pixcel.distanceTo(pixcel2);

equals(px){boolean}

Pixel.js, line 86

Determine whether one pixel is equivalent to another.

Name Type Description
px SuperMap.Pixel

The pixel object to be compared.

Returns:
Type Description
boolean The point passed in as parameter is equal to this. Note that if px passed in is null, returns false.
Example
var pixcel = new SuperMap.Pixel(100,50);
var pixcel2 = new SuperMap.Pixel(100,50);
var isEquals = pixcel.equals(pixcel2);

offset(px){SuperMap.Pixel}

Pixel.js, line 143

Make offset to the coordinate according to the SuperMap.Pixel passed in.

Name Type Description
px SuperMap.Pixel

The passed in SuperMap.Pixel object.

Returns:
Type Description
SuperMap.Pixel Returns a new pixel that is obtained by adding the x,y value of the current pixel object to the x,y value of the incoming Pixel object.
Example
var pixcel = new SuperMap.Pixel(100,50);
var pixcel2 = new SuperMap.Pixel(130,20);
//pixcel3 is a new object
var pixcel3 = pixcel.offset(pixcel2);

toString(){string}

Pixel.js, line 60

Return the string format of this object.

Returns:
Type Description
string For example: "x=200.4,y=242.2".
Example
var pixcel = new SuperMap.Pixel(100,50);
var str = pixcel.toString();