2019-11-29 12:51:58 +08:00
|
|
|
import * as matrix from 'zrender/src/core/matrix';
|
|
|
|
import deviceRender from '../constant/deviceRender';
|
|
|
|
|
|
|
|
export function createTransform(opts) {
|
|
|
|
let transform = matrix.create();
|
|
|
|
transform = matrix.scale(matrix.create(), transform, [opts.scaleRate, opts.scaleRate]);
|
|
|
|
transform = matrix.translate(matrix.create(), transform, [-opts.offsetX, -opts.offsetY]);
|
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
2020-07-06 17:02:13 +08:00
|
|
|
export function createTransform1(opts) {
|
|
|
|
let transform = matrix.create();
|
|
|
|
transform = matrix.scale(matrix.create(), transform, [opts.scaleRateX, opts.scaleRateY]);
|
|
|
|
transform = matrix.translate(matrix.create(), transform, [-opts.offsetX, -opts.offsetY]);
|
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
2019-11-29 12:51:58 +08:00
|
|
|
export function createBoundingRect(view) {
|
2019-12-18 09:49:44 +08:00
|
|
|
const rect = view.getBoundingRect().clone();
|
2019-11-29 12:51:58 +08:00
|
|
|
const scale = view.scale[0];
|
|
|
|
const offsetX = view.position[0];
|
|
|
|
const offsetY = view.position[1];
|
|
|
|
rect.x = rect.x * scale + offsetX;
|
|
|
|
rect.y = rect.y * scale + offsetY;
|
|
|
|
rect.width = rect.width * scale;
|
|
|
|
rect.height = rect.height * scale;
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2021-02-18 10:18:51 +08:00
|
|
|
export function calculateDCenter(viewRect, offsetX) {
|
2021-04-13 18:09:37 +08:00
|
|
|
var dx = offsetX - viewRect.width / 2 - viewRect.x;
|
2019-11-29 12:51:58 +08:00
|
|
|
var dy = 0;
|
|
|
|
return { dx: dx, dy: dy };
|
|
|
|
}
|
|
|
|
|
2020-03-11 10:53:09 +08:00
|
|
|
export function deviceFactory(type, elem, showConfig) {
|
|
|
|
return {...deviceRender[type], ...elem, ...showConfig};
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|