refactor offset to displacement
This commit is contained in:
committed by
Andreas Hocevar
parent
4c7f52c8a4
commit
78378f0253
@@ -20,7 +20,7 @@ import ImageStyle from './Image.js';
|
||||
* @property {number} [radius1] Outer radius of a star.
|
||||
* @property {number} [radius2] Inner radius of a star.
|
||||
* @property {number} [angle=0] Shape's angle in radians. A value of 0 will have one of the shape's point facing up.
|
||||
* @property {Array<number>} [offset=[0,0]] Offset of the shape
|
||||
* @property {Array<number>} [displacement=[0,0]] Offset of the shape
|
||||
* @property {import("./Stroke.js").default} [stroke] Stroke style.
|
||||
* @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).
|
||||
* @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view.
|
||||
@@ -63,7 +63,7 @@ class RegularShape extends ImageStyle {
|
||||
rotateWithView: rotateWithView,
|
||||
rotation: options.rotation !== undefined ? options.rotation : 0,
|
||||
scale: 1,
|
||||
offset: options.offset !== undefined ? options.offset : [0, 0]
|
||||
displacement: options.displacement !== undefined ? options.displacement : [0, 0]
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -163,7 +163,7 @@ class RegularShape extends ImageStyle {
|
||||
stroke: this.getStroke() ? this.getStroke().clone() : undefined,
|
||||
rotation: this.getRotation(),
|
||||
rotateWithView: this.getRotateWithView(),
|
||||
offset: this.getOffset().slice()
|
||||
displacement: this.getDisplacement().slice()
|
||||
});
|
||||
style.setOpacity(this.getOpacity());
|
||||
style.setScale(this.getScale());
|
||||
@@ -356,12 +356,13 @@ class RegularShape extends ImageStyle {
|
||||
// canvas.width and height are rounded to the closest integer
|
||||
size = this.canvas_.width;
|
||||
const imageSize = size;
|
||||
const displacement = this.getDisplacement();
|
||||
|
||||
this.draw_(renderOptions, context, 0, 0);
|
||||
|
||||
this.createHitDetectionCanvas_(renderOptions);
|
||||
|
||||
this.anchor_ = [size / 2 - this.offset_[0], size / 2 + this.offset_[1]];
|
||||
this.anchor_ = [size / 2 - displacement[0], size / 2 + displacement[1]];
|
||||
this.size_ = [size, size];
|
||||
this.imageSize_ = [imageSize, imageSize];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user