import Path from 'zrender/src/graphic/Path'; /** 指向箭头坐标*/ export function arrow(modelX, modelY, length, radius) { return [ [modelX - length, modelY], [modelX - length + radius / 1.5, modelY - radius / 1.2], [modelX - length + radius / 1.5, modelY - radius / 3], [modelX + length, modelY - radius / 3], [modelX + length, modelY + radius / 3], [modelX - length + radius / 1.5, modelY + radius / 3], [modelX - length + radius / 1.5, modelY + radius / 1.2] ]; } /** 指向三角形坐标*/ export function triangular(modelX, modelY, drict, radius) { return [ [modelX, modelY], [modelX - drict * (radius + 2), modelY - radius], [modelX - drict * (radius + 2), modelY + radius] ]; } /** 屏蔽门手电筒*/ export function flashlight(modelX, modelY, drict, width, height, offsetx, offsety, beyond) { return [ [modelX + drict * (offsetx), modelY + drict * offsety - (height + beyond) / 2], [modelX + drict * (offsetx + beyond), modelY + drict * offsety - height / 2], [modelX + drict * (offsetx + beyond + width), modelY + drict * offsety - height / 2], [modelX + drict * (offsetx + beyond + width), modelY + drict * offsety + height / 2], [modelX + drict * (offsetx + beyond), modelY + drict * offsety + height / 2], [modelX + drict * (offsetx), modelY + drict * offsety + (height + beyond) / 2] ]; } /** 区段限速体带方向*/ export function limitArrows(modelX, modelY, drict, radius) { return [ [modelX + drict * radius, modelY - radius], [modelX + drict * radius, modelY + radius], [modelX - drict * radius, modelY + radius], [modelX - drict * radius * 1.8, modelY], [modelX - drict * radius, modelY - radius] ]; } /** 区段折返标记*/ export function turnbackArrows(modelX, modelY, drict, width, height) { return [ [modelX - drict * (width - 1), modelY + height], [modelX + drict * width / 2, modelY + height], [modelX + drict * width / 2, modelY - height], [modelX - drict * (width - 3), modelY - height] ]; } export const Ugraph = Path.extend({ type: 'ugraph', shape: { points: null, counterclockwise: true }, style: { stroke: '#000', fill: null }, buildPath: function (ctx, shape) { var points = shape.points; var r = Math.abs(points[1][1] - points[2][1]) / 2; var x = Math.abs(points[1][0] + points[2][0]) / 2; var y = Math.abs(points[1][1] + points[2][1]) / 2; ctx.moveTo(points[0][0], points[0][1]); ctx.lineTo(points[1][0], points[1][1]); shape.counterclockwise && ctx.arc(x, y, r, Math.PI / 2, Math.PI * 3 / 2, false); shape.counterclockwise || ctx.arc(x, y, r, Math.PI / 2, -Math.PI / 2, true); ctx.moveTo(points[2][0], points[2][1]); ctx.lineTo(points[3][0], points[3][1]); ctx.closePath(); points = shape.points; r = Math.abs(points[1][1] - points[2][1]) / 2; x = Math.abs(points[1][0] + points[2][0]) / 2; y = Math.abs(points[1][1] + points[2][1]) / 2; ctx.moveTo(points[0][0], points[0][1]); ctx.lineTo(points[1][0], points[1][1]); shape.counterclockwise && ctx.arc(x, y, r, Math.PI / 2, Math.PI * 3 / 2, false); shape.counterclockwise || ctx.arc(x, y, r, Math.PI / 2, -Math.PI / 2, true); ctx.moveTo(points[2][0], points[2][1]); ctx.lineTo(points[3][0], points[3][1]); ctx.closePath(); } });