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; } 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; } export function createBoundingRect(view) { const rect = view.getBoundingRect().clone(); 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; } export function calculateDCenter(viewRect, offsetX) { var dx = offsetX - viewRect.width / 2 - viewRect.x; var dy = 0; return { dx: dx, dy: dy }; } export function deviceFactory(type, elem, showConfig) { return {...deviceRender[type], ...elem, ...showConfig}; }