Skip to content
Closed

test #3651

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/features/cseMachine/CseMachineConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const Config = Object.freeze({
MaxExportWidth: 20000,
MaxExportHeight: 12000,

MinTerminalSegmentLength: 30,
// Canvas background color
BgColor: '#2c3e50',
PrintBgColor: '#fff',
Expand Down
9 changes: 6 additions & 3 deletions src/features/cseMachine/components/arrows/ArrowFromText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@ export class ArrowFromText extends GenericArrow<Text, Value> {
const to = this.target;
if (!to) return [];

const terminalSegmentLength = Math.max(Config.ArrowHeadSize, Config.MinTerminalSegmentLength);
const verticalTerminalOffset = Math.max(Config.DataUnitHeight / 3, terminalSegmentLength);

const steps: StepsArray = [(x, y) => [x + from.width(), y + from.height() / 2]];

if (to.x() < from.x()) {
if (to instanceof ArrayValue) {
steps.push((x, y) => [x + Config.TextMargin, y]);
steps.push((x, y) => [x, to.y() - Config.DataUnitHeight / 3]);
steps.push((x, y) => [x, to.y() - verticalTerminalOffset]);
steps.push((x, y) => [to.x() + Config.DataUnitWidth / 2, y]);
steps.push((x, y) => [x, to.y()]);
} else {
steps.push((x, y) => [x + Config.TextMargin, y]);
steps.push((x, y) => [x, y - from.height() / 2 - Config.TextMargin]);
steps.push((x, y) => [to.x() + to.width() + Config.ArrowHeadSize, y]);
steps.push((x, y) => [to.x() + to.width() + terminalSegmentLength, y]);
steps.push((x, y) => [x, to.y()]);
steps.push((x, y) => [x - Config.ArrowHeadSize, y]);
steps.push((x, y) => [x - terminalSegmentLength, y]);
}
} else {
steps.push((x, y) => [
Expand Down
Loading