Revert "Feature: Multi Point Arrows (#338)" (#634)

This reverts commit 16263e942b.
This commit is contained in:
David Luzar 2020-01-31 18:56:55 +01:00 committed by GitHub
parent 16263e942b
commit 3d2e59bfed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 130 additions and 789 deletions

View file

@ -7,7 +7,6 @@ import {
} from "../element/bounds";
import { RoughCanvas } from "roughjs/bin/canvas";
import { Drawable } from "roughjs/bin/core";
import { Point } from "roughjs/bin/geometry";
import { RoughSVG } from "roughjs/bin/svg";
import { RoughGenerator } from "roughjs/bin/generator";
import { SVG_NS } from "../utils";
@ -90,23 +89,18 @@ function generateElement(
);
break;
case "arrow": {
const [x2, y2, x3, y3, x4, y4] = getArrowPoints(element);
const [x1, y1, x2, y2, x3, y3, x4, y4] = getArrowPoints(element);
const options = {
stroke: element.strokeColor,
strokeWidth: element.strokeWidth,
roughness: element.roughness,
seed: element.seed,
};
// points array can be empty in the beginning, so it is important to add
// initial position to it
const points: Point[] = element.points.length
? element.points
: [[0, 0]];
element.shape = [
// \
generator.line(x3, y3, x2, y2, options),
// -----
generator.curve(points, options),
generator.line(x1, y1, x2, y2, options),
// /
generator.line(x4, y4, x2, y2, options),
];
@ -175,6 +169,7 @@ export function renderElement(
context.fillStyle = fillStyle;
context.font = font;
context.globalAlpha = 1;
break;
} else {
throw new Error("Unimplemented type " + element.type);
}

View file

@ -76,7 +76,10 @@ export function renderScene(
element.y + sceneState.scrollY,
);
renderElement(element, rc, context);
context.resetTransform();
context.translate(
-element.x - sceneState.scrollX,
-element.y - sceneState.scrollY,
);
});
if (renderSelection) {
@ -104,11 +107,9 @@ export function renderScene(
if (selectedElements.length === 1 && selectedElements[0].type !== "text") {
const handlers = handlerRectangles(selectedElements[0], sceneState);
Object.values(handlers)
.filter(handler => handler !== undefined)
.forEach(handler => {
context.strokeRect(handler[0], handler[1], handler[2], handler[3]);
});
Object.values(handlers).forEach(handler => {
context.strokeRect(handler[0], handler[1], handler[2], handler[3]);
});
}
}
@ -148,20 +149,11 @@ function isVisibleElement(
canvasHeight: number,
) {
let [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
if (element.type !== "arrow") {
x1 += scrollX;
y1 += scrollY;
x2 += scrollX;
y2 += scrollY;
return x2 >= 0 && x1 <= canvasWidth && y2 >= 0 && y1 <= canvasHeight;
} else {
return (
x2 + scrollX >= 0 &&
x1 + scrollX <= canvasWidth &&
y2 + scrollY >= 0 &&
y1 + scrollY <= canvasHeight
);
}
x1 += scrollX;
y1 += scrollY;
x2 += scrollX;
y2 += scrollY;
return x2 >= 0 && x1 <= canvasWidth && y2 >= 0 && y1 <= canvasHeight;
}
// This should be only called for exporting purposes