new Pixel(x, y, mode)
Usage
// 浏览器
<script type="text/javascript" src="https://iclient.supermap.io/dist/openlayers/iclient-ol.js"></script>
<script>
  new ol.supermap.Pixel(x, y, mode);
  
  // 弃用的写法
  new SuperMap.Pixel(x, y, mode);
</script>
// ES6 Import
import { Pixel } from '@supermapgis/iclient-ol';
new Pixel(x, y, mode);
        
        
        
            common/commontypes/Pixel.js, line 5
        
        
    | Name | Type | Default | Description | 
|---|---|---|---|
| x | number | 0.0 | 可选 x 坐标。 | 
| y | number | 0.0 | 可选 y 坐标。 | 
| mode | Pixel.Mode | Pixel.Mode.LeftTop | 可选 坐标模式。 | 
Example
//单独创建一个对象
var pixcel = new Pixel(100,50);
//依据 size 创建
 var size = new Size(21,25);
 var offset = new Pixel(-(size.w/2), -size.h);Members
- 
    (static, readonly) Modestring
- 
    
    模式。 Properties:Name Type Default Description LeftTopstring lefttop 左上模式。 RightTopstring righttop 右上模式。 RightBottomstring rightbottom 右下模式。 LeftBottomstring leftbottom 左下模式。 
- 
    modePixel.Mode
- 
    
    坐标模式,有左上、右上、右下、左下这几种模式,分别表示相对于左上角、右上角、右下角、左下角的坐标。 - Default Value: Pixel.Mode.LeftTop
 
xnumber
x 坐标。
- Default Value: 0.0
ynumber
y 坐标。
- Default Value: 0.0
Methods
- 
    add(x, y){Pixel}common/commontypes/Pixel.js, line 105
- 
    
    在原来像素坐标基础上,x 值加上传入的 x 参数,y 值加上传入的 y 参数。 Name Type Description xnumber 传入的 x 值。 ynumber 传入的 y 值。 Returns:Type Description Pixel 新的 pixel 对象,该 pixel 是由当前的 pixel 与传入的 x,y 相加得到。 Examplevar pixcel = new Pixel(100,50); //pixcel2是新的对象 var pixcel2 = pixcel.add(20,30);
- 
    clone(){Pixel}common/commontypes/Pixel.js, line 59
- 
    
    克隆当前的 pixel 对象。 Returns:Type Description Pixel 新的与当前 pixel 对象有相同 x、y 坐标的 pixel 对象。 Examplevar pixcel = new Pixel(100,50); var pixcel2 = pixcel.clone();
- 
    destroy()common/commontypes/Pixel.js, line 144
- 
    
    销毁此对象。销毁后此对象的所有属性为 null,而不是初始值。 Examplevar pixcel = new Pixel(100,50); pixcel.destroy();
- 
    distanceTo(px){number}common/commontypes/Pixel.js, line 90
- 
    
    返回两个 pixel 的距离。 Name Type Description pxPixel 需要计算的 pixel。 Returns:Type Description number 作为参数传入的像素与当前像素点的距离。 Examplevar pixcel = new Pixel(100,50); var pixcel2 = new Pixel(110,30); var distance = pixcel.distanceTo(pixcel2);
- 
    equals(px){boolean}common/commontypes/Pixel.js, line 71
- 
    
    比较两 pixel 是否相等。 Name Type Description pxPixel 用于比较相等的 pixel 对象。 Returns:Type Description boolean 如果传入的像素点和当前像素点相同返回 true,如果不同或传入参数为 NULL 则返回 false。 Examplevar pixcel = new Pixel(100,50); var pixcel2 = new Pixel(100,50); var isEquals = pixcel.equals(pixcel2);
- 
    offset(px){Pixel}common/commontypes/Pixel.js, line 124
- 
    
    通过传入的 Pixel 参数对原屏幕坐标进行偏移。 Name Type Description pxPixel 传入的 Pixel 对象。 Returns:Type Description Pixel 新的 pixel,该 pixel 是由当前的 pixel 对象的 x,y 值与传入的 Pixel 对象的 x,y 值相加得到。 Examplevar pixcel = new Pixel(100,50); var pixcel2 = new Pixel(130,20); //pixcel3 是新的对象 var pixcel3 = pixcel.offset(pixcel2);
- 
    toString(){string}common/commontypes/Pixel.js, line 45
- 
    
    返回此对象的字符串形式。 Returns:Type Description string 例如: "x=200.4,y=242.2" Examplevar pixcel = new Pixel(100,50); var str = pixcel.toString();