Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let lineCoords = [100, 100, 300, 100];
- let angle = Math.atan2(lineCoords[3] - lineCoords[1], lineCoords[2] - lineCoords[0]);
- let headlen = 15;
- let points = [
- {
- x: lineCoords[0],
- y: lineCoords[1]
- },
- {
- x: lineCoords[2],
- y: lineCoords[3]
- },
- {
- x: lineCoords[2] - (headlen) * Math.cos(angle - Math.PI / 2),
- y: lineCoords[3] - (headlen) * Math.sin(angle - Math.PI / 2),
- },
- {
- x: lineCoords[2] + (headlen * 2) * Math.cos(angle),
- y: lineCoords[3] + (headlen * 2) * Math.sin(angle)
- },
- {
- x: lineCoords[2] - (headlen) * Math.cos(angle + Math.PI / 2),
- y: lineCoords[3] - (headlen) * Math.sin(angle + Math.PI / 2),
- },
- {
- x: lineCoords[2],
- y: lineCoords[3]
- },
- {
- x: lineCoords[0],
- y: lineCoords[1]
- }
- ];
- pp = new fabric.Polyline(points, {
- strokeWidth: 15,
- stroke: 'green',
- fill: 'red',
- noScaleCache: false,
- objectCaching: false,
- statefullCache: false,
- centeredScaling: false,
- lockScalingFlip: true,
- cacheKey: `group-${Date.now()}`,
- diff_mb: 0,
- diff_mt: 0,
- _name: 'graphics', cornerStyle: 'graphic',
- transparentCorners: false,
- cornerColor: '#249acf',
- cornerStrokeColor: '#ffffff',
- borderColor: '#ffffff',
- cornerSize: 13,
- borderDashArray: [2, 4],
- rotatingPointOffset: 23,
- lockSkewingX: true,
- lockSkewingY: true,
- _type: 'Line',
- _controlsVisibility: { mb: true, mtr: true },
- centeredScaling: true,
- padding: 15,
- customParams: { editComponent: "ArrowSettings", editProps: null }
- })
- _LIB.app.fabricCanvas.add(pp);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement