Added map context to scale simplification by map scale

Added distance to quadratic functions to vector
This commit is contained in:
Mitchell McCaffrey
2020-04-29 18:21:44 +10:00
parent 3e5a80e7d1
commit 9975f564fa
6 changed files with 170 additions and 48 deletions

View File

@@ -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,