Remove usage of scale for symbols + Remove shenanigans with multipliers

This commit is contained in:
Eric NGUYEN 2023-02-23 10:57:27 +01:00
parent a476017d99
commit 1c8cebf0f5
4 changed files with 25 additions and 85 deletions

View file

@ -1,6 +1,6 @@
import '../Selector.scss';
import * as React from 'react';
import { SYMBOL_MARGIN } from '../../../../utils/default';
import { DIMENSION_MARGIN, SYMBOL_MARGIN } from '../../../../utils/default';
import { type ISymbolModel } from '../../../../Interfaces/ISymbolModel';
import { Selector } from '../Selector/Selector';
import { TransformX, TransformY } from '../../../../utils/svg';
@ -9,7 +9,6 @@ import { PositionReference } from '../../../../Enums/PositionReference';
interface ISelectorSymbolProps {
symbols: Map<string, ISymbolModel>
selected?: ISymbolModel
scale?: number
}
export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
@ -20,45 +19,17 @@ export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
);
}
const scale = (props.scale ?? 1);
let x, y: number;
const scaledHeight = props.selected.height / scale;
const scaledWidth = props.selected.width / scale;
const scaledHeight = props.selected.height;
const scaledWidth = props.selected.width;
if (props.selected.isVertical) {
x = (-SYMBOL_MARGIN - props.selected.width) / scale;
y = TransformY(props.selected.offset, props.selected.height * 2, props.selected.config.PositionReference);
switch (props.selected.config.PositionReference) {
case PositionReference.CenterLeft:
case PositionReference.CenterCenter:
case PositionReference.CenterRight:
y -= scaledHeight / 2;
break;
case PositionReference.BottomLeft:
case PositionReference.BottomCenter:
case PositionReference.BottomRight:
y -= scaledHeight;
break;
}
x = -DIMENSION_MARGIN;
y = props.selected.offset;
} else {
x = TransformX(props.selected.offset, props.selected.width * 2, props.selected.config.PositionReference);
switch (props.selected.config.PositionReference) {
case PositionReference.TopCenter:
case PositionReference.CenterCenter:
case PositionReference.BottomCenter:
x -= scaledWidth / 2;
break;
case PositionReference.TopRight:
case PositionReference.CenterRight:
case PositionReference.BottomRight:
x -= scaledWidth;
break;
}
y = (-SYMBOL_MARGIN - props.selected.height) / scale;
x = props.selected.offset;
y = -DIMENSION_MARGIN;
}
return (
@ -68,7 +39,7 @@ export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
y={y}
width={scaledWidth}
height={scaledHeight}
scale={scale}
scale={1}
/>
);
}