Added map context to scale simplification by map scale
Added distance to quadratic functions to vector
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import React, { useRef, useEffect, useState } from "react";
|
||||
import React, { useRef, useEffect, useState, useContext } from "react";
|
||||
import shortid from "shortid";
|
||||
|
||||
import { compare as comparePoints } from "../../helpers/vector2";
|
||||
|
||||
import {
|
||||
getBrushPositionForTool,
|
||||
getDefaultShapeData,
|
||||
@@ -13,6 +12,8 @@ import {
|
||||
getRelativePointerPosition,
|
||||
} from "../../helpers/drawing";
|
||||
|
||||
import MapInteractionContext from "../../contexts/MapInteractionContext";
|
||||
|
||||
function MapDrawing({
|
||||
width,
|
||||
height,
|
||||
@@ -36,6 +37,8 @@ function MapDrawing({
|
||||
selectedTool === "shape" ||
|
||||
selectedTool === "erase";
|
||||
|
||||
const { scaleRef } = useContext(MapInteractionContext);
|
||||
|
||||
// Reset pointer position when tool changes
|
||||
useEffect(() => {
|
||||
setPointerPosition({ x: -1, y: -1 });
|
||||
@@ -128,7 +131,8 @@ function MapDrawing({
|
||||
}
|
||||
const simplified = simplifyPoints(
|
||||
[...prevPoints, brushPosition],
|
||||
gridSize
|
||||
gridSize,
|
||||
scaleRef.current
|
||||
);
|
||||
return {
|
||||
...prevShape,
|
||||
|
||||
Reference in New Issue
Block a user