Merge pull request #9416 from fredj/circle_rotate
Implement rotate and translate functions for circle geometry
This commit is contained in:
@@ -5,6 +5,8 @@ import {createOrUpdate, forEachCorner, intersects} from '../extent.js';
|
||||
import GeometryType from './GeometryType.js';
|
||||
import SimpleGeometry from './SimpleGeometry.js';
|
||||
import {deflateCoordinate} from './flat/deflate.js';
|
||||
import {rotate, translate} from './flat/transform.js';
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -212,6 +214,29 @@ class Circle extends SimpleGeometry {
|
||||
this.flatCoordinates[this.stride] = this.flatCoordinates[0] + radius;
|
||||
this.changed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @api
|
||||
*/
|
||||
rotate(angle, anchor) {
|
||||
const center = this.getCenter();
|
||||
const stride = this.getStride();
|
||||
this.setCenter(rotate(center, 0, center.length, stride, angle, anchor, center));
|
||||
this.changed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @api
|
||||
*/
|
||||
translate(deltaX, deltaY) {
|
||||
const center = this.getCenter();
|
||||
const stride = this.getStride();
|
||||
this.setCenter(translate(center, 0, center.length, stride, deltaX, deltaY, center));
|
||||
this.changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user