mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: disable canvas smoothing (antialiasing) for right-angled elements (#6186)Co-authored-by: Ignacio Cuadra <67276174+ignacio-cuadra@users.noreply.github.com>
* feat: disable canvas smoothing for text and other types * disable smoothing for all right-angled elements * Update src/renderer/renderElement.ts Co-authored-by: Ignacio Cuadra <67276174+ignacio-cuadra@users.noreply.github.com> * Update src/renderer/renderElement.ts Co-authored-by: Ignacio Cuadra <67276174+ignacio-cuadra@users.noreply.github.com> * fix lint * always enable smoothing while zooming --------- Co-authored-by: Ignacio Cuadra <67276174+ignacio-cuadra@users.noreply.github.com>
This commit is contained in:
parent
a9c5bdb878
commit
4414069617
2 changed files with 39 additions and 1 deletions
12
src/math.ts
12
src/math.ts
|
@ -459,3 +459,15 @@ export const mapIntervalToBezierT = (
|
|||
export const arePointsEqual = (p1: Point, p2: Point) => {
|
||||
return p1[0] === p2[0] && p1[1] === p2[1];
|
||||
};
|
||||
|
||||
export const isRightAngle = (angle: number) => {
|
||||
// if our angles were mathematically accurate, we could just check
|
||||
//
|
||||
// angle % (Math.PI / 2) === 0
|
||||
//
|
||||
// but since we're in floating point land, we need to round.
|
||||
//
|
||||
// Below, after dividing by Math.PI, a multiple of 0.5 indicates a right
|
||||
// angle, which we can check with modulo after rounding.
|
||||
return Math.round((angle / Math.PI) * 10000) % 5000 === 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue