Fixes utils imports
This commit is contained in:
parent
035b98afbc
commit
82bd129e3a
83 changed files with 191 additions and 154 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { getSelectedIds } from 'utils/utils'
|
import { getSelectedIds } from 'utils'
|
||||||
|
|
||||||
interface PointerOptions {
|
interface PointerOptions {
|
||||||
id?: string
|
id?: string
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
getSelectedIds,
|
getSelectedIds,
|
||||||
getSelectedShapes,
|
getSelectedShapes,
|
||||||
isMobile,
|
isMobile,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import CenterHandle from './center-handle'
|
import CenterHandle from './center-handle'
|
||||||
import CornerHandle from './corner-handle'
|
import CornerHandle from './corner-handle'
|
||||||
import EdgeHandle from './edge-handle'
|
import EdgeHandle from './edge-handle'
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { useRef } from 'react'
|
||||||
import state, { useSelector } from 'state'
|
import state, { useSelector } from 'state'
|
||||||
import inputs from 'state/inputs'
|
import inputs from 'state/inputs'
|
||||||
import styled from 'styles'
|
import styled from 'styles'
|
||||||
import { deepCompareArrays, getPage } from 'utils/utils'
|
import { deepCompareArrays, getPage } from 'utils'
|
||||||
|
|
||||||
function handlePointerDown(e: React.PointerEvent<SVGRectElement>) {
|
function handlePointerDown(e: React.PointerEvent<SVGRectElement>) {
|
||||||
if (!inputs.canAccept(e.pointerId)) return
|
if (!inputs.canAccept(e.pointerId)) return
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { getShapeUtils } from 'state/shape-utils'
|
||||||
import { useRef } from 'react'
|
import { useRef } from 'react'
|
||||||
import { useSelector } from 'state'
|
import { useSelector } from 'state'
|
||||||
import styled from 'styles'
|
import styled from 'styles'
|
||||||
import { deepCompareArrays, getPage } from 'utils/utils'
|
import { deepCompareArrays, getPage } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
|
|
||||||
export default function Handles(): JSX.Element {
|
export default function Handles(): JSX.Element {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
deepCompareArrays,
|
deepCompareArrays,
|
||||||
getSelectedShapes,
|
getSelectedShapes,
|
||||||
isMobile,
|
isMobile,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import state, { useSelector } from 'state'
|
import state, { useSelector } from 'state'
|
||||||
import {
|
import {
|
||||||
AlignType,
|
AlignType,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { getShapeStyle } from 'state/shape-styles'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import React, { memo } from 'react'
|
import React, { memo } from 'react'
|
||||||
import { useSelector } from 'state'
|
import { useSelector } from 'state'
|
||||||
import { deepCompareArrays, getCurrentCamera, getPage } from 'utils/utils'
|
import { deepCompareArrays, getCurrentCamera, getPage } from 'utils'
|
||||||
import { DotCircle, Handle } from './misc'
|
import { DotCircle, Handle } from './misc'
|
||||||
|
|
||||||
export default function Defs(): JSX.Element {
|
export default function Defs(): JSX.Element {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { getShapeUtils } from 'state/shape-utils'
|
||||||
import { useSelector } from 'state'
|
import { useSelector } from 'state'
|
||||||
import { Bounds, PageState } from 'types'
|
import { Bounds, PageState } from 'types'
|
||||||
import { boundsCollide, boundsContain } from 'utils/bounds'
|
import { boundsCollide, boundsContain } from 'utils/bounds'
|
||||||
import { deepCompareArrays, getPage, getViewport } from 'utils/utils'
|
import { deepCompareArrays, getPage, getViewport } from 'utils'
|
||||||
import Shape from './shape'
|
import Shape from './shape'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import styled from 'styles'
|
import styled from 'styles'
|
||||||
import { useSelector } from 'state'
|
import { useSelector } from 'state'
|
||||||
import {
|
import { deepCompareArrays, getPage, getSelectedIds, setToArray } from 'utils'
|
||||||
deepCompareArrays,
|
|
||||||
getPage,
|
|
||||||
getSelectedIds,
|
|
||||||
setToArray,
|
|
||||||
} from 'utils/utils'
|
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import { memo } from 'react'
|
import { memo } from 'react'
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React, { useRef, memo, useEffect } from 'react'
|
||||||
import { useSelector } from 'state'
|
import { useSelector } from 'state'
|
||||||
import styled from 'styles'
|
import styled from 'styles'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import { getPage, getSelectedIds, isMobile } from 'utils/utils'
|
import { getPage, getSelectedIds, isMobile } from 'utils'
|
||||||
import { Shape as _Shape } from 'types'
|
import { Shape as _Shape } from 'types'
|
||||||
import useShapeEvents from 'hooks/useShapeEvents'
|
import useShapeEvents from 'hooks/useShapeEvents'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { X, Code } from 'react-feather'
|
||||||
import { IconButton } from 'components/shared'
|
import { IconButton } from 'components/shared'
|
||||||
import * as Panel from '../panel'
|
import * as Panel from '../panel'
|
||||||
import Control from './control'
|
import Control from './control'
|
||||||
import { deepCompareArrays } from 'utils/utils'
|
import { deepCompareArrays } from 'utils'
|
||||||
|
|
||||||
export default function ControlPanel(): JSX.Element {
|
export default function ControlPanel(): JSX.Element {
|
||||||
const rContainer = useRef<HTMLDivElement>(null)
|
const rContainer = useRef<HTMLDivElement>(null)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
getPage,
|
getPage,
|
||||||
getSelectedIds,
|
getSelectedIds,
|
||||||
setToArray,
|
setToArray,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import AlignDistribute from './align-distribute'
|
import AlignDistribute from './align-distribute'
|
||||||
import { MoveType } from 'types'
|
import { MoveType } from 'types'
|
||||||
import SizePicker from './size-picker'
|
import SizePicker from './size-picker'
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import state from 'state'
|
import state from 'state'
|
||||||
import storage from 'state/storage'
|
import storage from 'state/storage'
|
||||||
import { getCurrentCamera } from 'utils/utils'
|
import { getCurrentCamera } from 'utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the state's camera changes, update the transform of
|
* When the state's camera changes, update the transform of
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import state from 'state'
|
import state from 'state'
|
||||||
import { MoveType } from 'types'
|
import { MoveType } from 'types'
|
||||||
import { getKeyboardEventInfo, metaKey } from 'utils/utils'
|
import { getKeyboardEventInfo, metaKey } from 'utils'
|
||||||
|
|
||||||
export default function useKeyboardEvents() {
|
export default function useKeyboardEvents() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { getShapeUtils } from './shape-utils'
|
import { getShapeUtils } from './shape-utils'
|
||||||
import { Data, Shape } from 'types'
|
import { Data, Shape } from 'types'
|
||||||
import { getCommonBounds, getSelectedShapes } from 'utils/utils'
|
import { getCommonBounds, getSelectedShapes } from 'utils'
|
||||||
import state from './state'
|
import state from './state'
|
||||||
|
|
||||||
class Clipboard {
|
class Clipboard {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import CodeShape from './index'
|
import CodeShape from './index'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { ArrowShape, Decoration, ShapeStyles, ShapeType } from 'types'
|
import { ArrowShape, Decoration, ShapeStyles, ShapeType } from 'types'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
NumberCodeControl,
|
NumberCodeControl,
|
||||||
VectorCodeControl,
|
VectorCodeControl,
|
||||||
} from 'types'
|
} from 'types'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
|
|
||||||
export const controls: Record<string, any> = {}
|
export const controls: Record<string, any> = {}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import CodeShape from './index'
|
import CodeShape from './index'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { DotShape, ShapeStyles, ShapeType } from 'types'
|
import { DotShape, ShapeStyles, ShapeType } from 'types'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import CodeShape from './index'
|
import CodeShape from './index'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { DrawShape, ShapeType } from 'types'
|
import { DrawShape, ShapeType } from 'types'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import CodeShape from './index'
|
import CodeShape from './index'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { EllipseShape, ShapeStyles, ShapeType } from 'types'
|
import { EllipseShape, ShapeStyles, ShapeType } from 'types'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import Vec from 'utils/vec'
|
||||||
import { NumberControl, VectorControl, codeControls, controls } from './control'
|
import { NumberControl, VectorControl, codeControls, controls } from './control'
|
||||||
import { codeShapes } from './index'
|
import { codeShapes } from './index'
|
||||||
import { CodeControl, Data, Shape } from 'types'
|
import { CodeControl, Data, Shape } from 'types'
|
||||||
import { getPage } from 'utils/utils'
|
import { getPage } from 'utils'
|
||||||
|
|
||||||
const baseScope = {
|
const baseScope = {
|
||||||
Dot,
|
Dot,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import CodeShape from './index'
|
import CodeShape from './index'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { LineShape, ShapeStyles, ShapeType } from 'types'
|
import { LineShape, ShapeStyles, ShapeType } from 'types'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import CodeShape from './index'
|
import CodeShape from './index'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { PolylineShape, ShapeStyles, ShapeType } from 'types'
|
import { PolylineShape, ShapeStyles, ShapeType } from 'types'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import CodeShape from './index'
|
import CodeShape from './index'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { RayShape, ShapeStyles, ShapeType } from 'types'
|
import { RayShape, ShapeStyles, ShapeType } from 'types'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import CodeShape from './index'
|
import CodeShape from './index'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { RectangleShape, ShapeStyles, ShapeType } from 'types'
|
import { RectangleShape, ShapeStyles, ShapeType } from 'types'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
|
|
||||||
|
|
|
@ -1,51 +1,45 @@
|
||||||
import { Bounds } from 'types'
|
import { Bounds } from 'types'
|
||||||
import Vector, { Point } from './vector'
|
import { ease } from 'utils'
|
||||||
|
import vec from 'utils/vec'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Utils
|
* ## Utils
|
||||||
*/
|
*/
|
||||||
export default class Utils {
|
export default class Utils {
|
||||||
static vectorToPoint(point: number[] | Vector | undefined): number[] {
|
static pointsBetween(a: number[], b: number[], steps = 6): number[][] {
|
||||||
if (typeof point === 'undefined') {
|
return Array.from(Array(steps))
|
||||||
return [0, 0]
|
.map((_, i) => ease(i / steps))
|
||||||
}
|
.map((t) => [...vec.lrp(a, b, t), (1 - t) / 2])
|
||||||
|
|
||||||
if (point instanceof Vector) {
|
|
||||||
return [point.x, point.y]
|
|
||||||
}
|
|
||||||
return point
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getRayRayIntersection(
|
static getRayRayIntersection(
|
||||||
p0: Vector,
|
p0: number[],
|
||||||
n0: Vector,
|
n0: number[],
|
||||||
p1: Vector,
|
p1: number[],
|
||||||
n1: Vector
|
n1: number[]
|
||||||
): Vector {
|
): number[] {
|
||||||
const p0e = Vector.add(p0, n0),
|
const p0e = vec.add(p0, n0),
|
||||||
p1e = Vector.add(p1, n1),
|
p1e = vec.add(p1, n1),
|
||||||
m0 = (p0e.y - p0.y) / (p0e.x - p0.x),
|
m0 = (p0e[1] - p0[1]) / (p0e[0] - p0[0]),
|
||||||
m1 = (p1e.y - p1.y) / (p1e.x - p1.x),
|
m1 = (p1e[1] - p1[1]) / (p1e[0] - p1[0]),
|
||||||
b0 = p0.y - m0 * p0.x,
|
b0 = p0[1] - m0 * p0[0],
|
||||||
b1 = p1.y - m1 * p1.x,
|
b1 = p1[1] - m1 * p1[0],
|
||||||
x = (b1 - b0) / (m0 - m1),
|
x = (b1 - b0) / (m0 - m1),
|
||||||
y = m0 * x + b0
|
y = m0 * x + b0
|
||||||
|
|
||||||
return new Vector({ x, y })
|
return [x, y]
|
||||||
}
|
}
|
||||||
|
|
||||||
static getCircleTangentToPoint(
|
static getCircleTangentToPoint(
|
||||||
A: Point | Vector,
|
A: number[],
|
||||||
r0: number,
|
r0: number,
|
||||||
P: Point | Vector,
|
P: number[],
|
||||||
side: number
|
side: number
|
||||||
): Vector {
|
): number[] {
|
||||||
const v0 = Vector.cast(A)
|
const B = vec.lrp(A, P, 0.5),
|
||||||
const v1 = Vector.cast(P)
|
r1 = vec.dist(A, B),
|
||||||
const B = Vector.lrp(v0, v1, 0.5),
|
delta = vec.sub(B, A),
|
||||||
r1 = Vector.dist(v0, B),
|
d = vec.len(delta)
|
||||||
delta = Vector.sub(B, v0),
|
|
||||||
d = Vector.len(delta)
|
|
||||||
|
|
||||||
if (!(d <= r0 + r1 && d >= Math.abs(r0 - r1))) {
|
if (!(d <= r0 + r1 && d >= Math.abs(r0 - r1))) {
|
||||||
return
|
return
|
||||||
|
@ -53,21 +47,25 @@ export default class Utils {
|
||||||
|
|
||||||
const a = (r0 * r0 - r1 * r1 + d * d) / (2.0 * d),
|
const a = (r0 * r0 - r1 * r1 + d * d) / (2.0 * d),
|
||||||
n = 1 / d,
|
n = 1 / d,
|
||||||
p = Vector.add(v0, Vector.mul(delta, a * n)),
|
p = vec.add(A, vec.mul(delta, a * n)),
|
||||||
h = Math.sqrt(r0 * r0 - a * a),
|
h = Math.sqrt(r0 * r0 - a * a),
|
||||||
k = Vector.mul(Vector.per(delta), h * n)
|
k = vec.mul(vec.per(delta), h * n)
|
||||||
|
|
||||||
return side === 0 ? p.add(k) : p.sub(k)
|
return side === 0 ? vec.add(p, k) : vec.sub(p, k)
|
||||||
}
|
}
|
||||||
|
|
||||||
static shortAngleDist(a: number, b: number): number {
|
static shortAngleDist(a0: number, a1: number): number {
|
||||||
const max = Math.PI * 2
|
const max = Math.PI * 2
|
||||||
const da = (b - a) % max
|
const da = (a1 - a0) % max
|
||||||
return ((2 * da) % max) - da
|
return ((2 * da) % max) - da
|
||||||
}
|
}
|
||||||
|
|
||||||
static getSweep(C: Vector, A: Vector, B: Vector): number {
|
static angleDelta(a0: number, a1: number): number {
|
||||||
return Utils.shortAngleDist(Vector.ang(C, A), Vector.ang(C, B))
|
return this.shortAngleDist(a0, a1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSweep(C: number[], A: number[], B: number[]): number {
|
||||||
|
return this.angleDelta(vec.angle(C, A), vec.angle(C, B))
|
||||||
}
|
}
|
||||||
|
|
||||||
static bez1d(a: number, b: number, c: number, d: number, t: number): number {
|
static bez1d(a: number, b: number, c: number, d: number, t: number): number {
|
||||||
|
@ -80,10 +78,10 @@ export default class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getCubicBezierBounds(
|
static getCubicBezierBounds(
|
||||||
p0: Point | Vector,
|
p0: number[],
|
||||||
c0: Point | Vector,
|
c0: number[],
|
||||||
c1: Point | Vector,
|
c1: number[],
|
||||||
p1: Point | Vector
|
p1: number[]
|
||||||
): Bounds {
|
): Bounds {
|
||||||
// solve for x
|
// solve for x
|
||||||
let a = 3 * p1[0] - 9 * c1[0] + 9 * c0[0] - 3 * p0[0]
|
let a = 3 * p1[0] - 9 * c1[0] + 9 * c0[0] - 3 * p0[0]
|
||||||
|
|
|
@ -494,3 +494,49 @@ export default class Vector {
|
||||||
return Vector.dist(a, Vector.nearestPointOnLineSegment(a, p0, p1, clamp))
|
return Vector.dist(a, Vector.nearestPointOnLineSegment(a, p0, p1, clamp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Utils {
|
||||||
|
static getRayRayIntersection(
|
||||||
|
p0: Vector,
|
||||||
|
n0: Vector,
|
||||||
|
p1: Vector,
|
||||||
|
n1: Vector
|
||||||
|
): Vector {
|
||||||
|
const p0e = Vector.add(p0, n0),
|
||||||
|
p1e = Vector.add(p1, n1),
|
||||||
|
m0 = (p0e.y - p0.y) / (p0e.x - p0.x),
|
||||||
|
m1 = (p1e.y - p1.y) / (p1e.x - p1.x),
|
||||||
|
b0 = p0.y - m0 * p0.x,
|
||||||
|
b1 = p1.y - m1 * p1.x,
|
||||||
|
x = (b1 - b0) / (m0 - m1),
|
||||||
|
y = m0 * x + b0
|
||||||
|
|
||||||
|
return new Vector({ x, y })
|
||||||
|
}
|
||||||
|
|
||||||
|
static getCircleTangentToPoint(
|
||||||
|
A: Point | Vector,
|
||||||
|
r0: number,
|
||||||
|
P: Point | Vector,
|
||||||
|
side: number
|
||||||
|
): Vector {
|
||||||
|
const v0 = Vector.cast(A)
|
||||||
|
const v1 = Vector.cast(P)
|
||||||
|
const B = Vector.lrp(v0, v1, 0.5),
|
||||||
|
r1 = Vector.dist(v0, B),
|
||||||
|
delta = Vector.sub(B, v0),
|
||||||
|
d = Vector.len(delta)
|
||||||
|
|
||||||
|
if (!(d <= r0 + r1 && d >= Math.abs(r0 - r1))) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const a = (r0 * r0 - r1 * r1 + d * d) / (2.0 * d),
|
||||||
|
n = 1 / d,
|
||||||
|
p = Vector.add(v0, Vector.mul(delta, a * n)),
|
||||||
|
h = Math.sqrt(r0 * r0 - a * a),
|
||||||
|
k = Vector.mul(Vector.per(delta), h * n)
|
||||||
|
|
||||||
|
return side === 0 ? p.add(k) : p.sub(k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { AlignType, Data } from 'types'
|
import { AlignType, Data } from 'types'
|
||||||
import { getCommonBounds, getPage, getSelectedShapes } from 'utils/utils'
|
import { getCommonBounds, getPage, getSelectedShapes } from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default function alignCommand(data: Data, type: AlignType): void {
|
export default function alignCommand(data: Data, type: AlignType): void {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { getPage, getSelectedIds } from 'utils/utils'
|
import { getPage, getSelectedIds } from 'utils'
|
||||||
import { ArrowSnapshot } from 'state/sessions/arrow-session'
|
import { ArrowSnapshot } from 'state/sessions/arrow-session'
|
||||||
|
|
||||||
export default function arrowCommand(
|
export default function arrowCommand(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { getSelectedIds, setSelectedIds, setToArray } from 'utils/utils'
|
import { getSelectedIds, setSelectedIds, setToArray } from 'utils'
|
||||||
|
|
||||||
/* ------------------ Command Class ----------------- */
|
/* ------------------ Command Class ----------------- */
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data, Page, PageState } from 'types'
|
import { Data, Page, PageState } from 'types'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import storage from 'state/storage'
|
import storage from 'state/storage'
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
getPage,
|
getPage,
|
||||||
getSelectedShapes,
|
getSelectedShapes,
|
||||||
setSelectedIds,
|
setSelectedIds,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { DirectionSnapshot } from 'state/sessions/direction-session'
|
import { DirectionSnapshot } from 'state/sessions/direction-session'
|
||||||
import { Data, LineShape, RayShape } from 'types'
|
import { Data, LineShape, RayShape } from 'types'
|
||||||
import { getPage } from 'utils/utils'
|
import { getPage } from 'utils'
|
||||||
|
|
||||||
export default function directCommand(
|
export default function directCommand(
|
||||||
data: Data,
|
data: Data,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
getCommonBounds,
|
getCommonBounds,
|
||||||
getPage,
|
getPage,
|
||||||
getSelectedShapes,
|
getSelectedShapes,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default function distributeCommand(
|
export default function distributeCommand(
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data, PointerInfo } from 'types'
|
import { Data, PointerInfo } from 'types'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import { deepClone, getPage, getShape, updateParents } from 'utils/utils'
|
import { deepClone, getPage, getShape, updateParents } from 'utils'
|
||||||
|
|
||||||
export default function doublePointHandleCommand(
|
export default function doublePointHandleCommand(
|
||||||
data: Data,
|
data: Data,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data, DrawShape } from 'types'
|
import { Data, DrawShape } from 'types'
|
||||||
import { getPage, setSelectedIds } from 'utils/utils'
|
import { getPage, setSelectedIds } from 'utils'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
|
|
||||||
export default function drawCommand(data: Data, id: string): void {
|
export default function drawCommand(data: Data, id: string): void {
|
||||||
|
|
|
@ -6,8 +6,8 @@ import {
|
||||||
getPage,
|
getPage,
|
||||||
getSelectedShapes,
|
getSelectedShapes,
|
||||||
setSelectedIds,
|
setSelectedIds,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { getPage } from 'utils/utils'
|
import { getPage } from 'utils'
|
||||||
import { EditSnapshot } from 'state/sessions/edit-session'
|
import { EditSnapshot } from 'state/sessions/edit-session'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data, Shape } from 'types'
|
import { Data, Shape } from 'types'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { getPage, setSelectedIds } from 'utils/utils'
|
import { getPage, setSelectedIds } from 'utils'
|
||||||
|
|
||||||
export default function generateCommand(
|
export default function generateCommand(
|
||||||
data: Data,
|
data: Data,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
getSelectedShapes,
|
getSelectedShapes,
|
||||||
getShape,
|
getShape,
|
||||||
setSelectedIds,
|
setSelectedIds,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { createShape, getShapeUtils } from 'state/shape-utils'
|
import { createShape, getShapeUtils } from 'state/shape-utils'
|
||||||
import commands from '.'
|
import commands from '.'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { getPage } from 'utils/utils'
|
import { getPage } from 'utils'
|
||||||
import { HandleSnapshot } from 'state/sessions/handle-session'
|
import { HandleSnapshot } from 'state/sessions/handle-session'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
getSelectedIds,
|
getSelectedIds,
|
||||||
setToArray,
|
setToArray,
|
||||||
uniqueArray,
|
uniqueArray,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import storage from 'state/storage'
|
import storage from 'state/storage'
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
getPage,
|
getPage,
|
||||||
getSelectedIds,
|
getSelectedIds,
|
||||||
setToArray,
|
setToArray,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default function moveCommand(data: Data, type: MoveType): void {
|
export default function moveCommand(data: Data, type: MoveType): void {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data, Shape } from 'types'
|
import { Data, Shape } from 'types'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import { getPage, updateParents } from 'utils/utils'
|
import { getPage, updateParents } from 'utils'
|
||||||
|
|
||||||
// Used when changing the properties of one or more shapes,
|
// Used when changing the properties of one or more shapes,
|
||||||
// without changing selection or deleting any shapes.
|
// without changing selection or deleting any shapes.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { getPage, getSelectedShapes } from 'utils/utils'
|
import { getPage, getSelectedShapes } from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ import {
|
||||||
screenToWorld,
|
screenToWorld,
|
||||||
setSelectedIds,
|
setSelectedIds,
|
||||||
setToArray,
|
setToArray,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import state from 'state/state'
|
import state from 'state/state'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { getPage, getSelectedShapes, updateParents } from 'utils/utils'
|
import { getPage, getSelectedShapes, updateParents } from 'utils'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
getCommonBounds,
|
getCommonBounds,
|
||||||
getPage,
|
getPage,
|
||||||
getSelectedShapes,
|
getSelectedShapes,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { RotateSnapshot } from 'state/sessions/rotate-session'
|
import { RotateSnapshot } from 'state/sessions/rotate-session'
|
||||||
import { getPage } from 'utils/utils'
|
import { getPage } from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default function rotateCommand(
|
export default function rotateCommand(
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { StretchType, Data, Corner } from 'types'
|
import { StretchType, Data, Corner } from 'types'
|
||||||
import {
|
import { deepClone, getCommonBounds, getPage, getSelectedShapes } from 'utils'
|
||||||
deepClone,
|
|
||||||
getCommonBounds,
|
|
||||||
getPage,
|
|
||||||
getSelectedShapes,
|
|
||||||
} from 'utils/utils'
|
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default function stretchCommand(data: Data, type: StretchType): void {
|
export default function stretchCommand(data: Data, type: StretchType): void {
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data, ShapeStyles } from 'types'
|
import { Data, ShapeStyles } from 'types'
|
||||||
import {
|
import { getDocumentBranch, getPage, getSelectedIds, setToArray } from 'utils'
|
||||||
getDocumentBranch,
|
|
||||||
getPage,
|
|
||||||
getSelectedIds,
|
|
||||||
setToArray,
|
|
||||||
} from 'utils/utils'
|
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data, Shape } from 'types'
|
import { Data, Shape } from 'types'
|
||||||
import { getPage, getSelectedShapes } from 'utils/utils'
|
import { getPage, getSelectedShapes } from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import { PropsOfType } from 'types'
|
import { PropsOfType } from 'types'
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import history from '../history'
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { TransformSingleSnapshot } from 'state/sessions/transform-single-session'
|
import { TransformSingleSnapshot } from 'state/sessions/transform-single-session'
|
||||||
import { getPage, setSelectedIds, updateParents } from 'utils/utils'
|
import { getPage, setSelectedIds, updateParents } from 'utils'
|
||||||
|
|
||||||
export default function transformSingleCommand(
|
export default function transformSingleCommand(
|
||||||
data: Data,
|
data: Data,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data } from 'types'
|
import { Data } from 'types'
|
||||||
import { TransformSnapshot } from 'state/sessions/transform-session'
|
import { TransformSnapshot } from 'state/sessions/transform-session'
|
||||||
import { getPage, updateParents } from 'utils/utils'
|
import { getPage, updateParents } from 'utils'
|
||||||
|
|
||||||
export default function transformCommand(
|
export default function transformCommand(
|
||||||
data: Data,
|
data: Data,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
getPage,
|
getPage,
|
||||||
setSelectedIds,
|
setSelectedIds,
|
||||||
updateParents,
|
updateParents,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default function translateCommand(
|
export default function translateCommand(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Command from './command'
|
import Command from './command'
|
||||||
import history from '../history'
|
import history from '../history'
|
||||||
import { Data, ShapeType } from 'types'
|
import { Data, ShapeType } from 'types'
|
||||||
import { getPage, getSelectedShapes, setSelectedIds } from 'utils/utils'
|
import { getPage, getSelectedShapes, setSelectedIds } from 'utils'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
getSelectedIds,
|
getSelectedIds,
|
||||||
screenToWorld,
|
screenToWorld,
|
||||||
setToArray,
|
setToArray,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { freeze } from 'immer'
|
import { freeze } from 'immer'
|
||||||
import session from './session'
|
import session from './session'
|
||||||
import state from './state'
|
import state from './state'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { PointerInfo } from 'types'
|
import { PointerInfo } from 'types'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { isDarwin, getPoint } from 'utils/utils'
|
import { isDarwin, getPoint } from 'utils'
|
||||||
|
|
||||||
const DOUBLE_CLICK_DURATION = 250
|
const DOUBLE_CLICK_DURATION = 250
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
getSelectedIds,
|
getSelectedIds,
|
||||||
setToArray,
|
setToArray,
|
||||||
updateParents,
|
updateParents,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default class ArrowSession extends BaseSession {
|
export default class ArrowSession extends BaseSession {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
getTopParentId,
|
getTopParentId,
|
||||||
setSelectedIds,
|
setSelectedIds,
|
||||||
setToArray,
|
setToArray,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
|
|
||||||
export default class BrushSession extends BaseSession {
|
export default class BrushSession extends BaseSession {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import vec from 'utils/vec'
|
||||||
import BaseSession from './base-session'
|
import BaseSession from './base-session'
|
||||||
import commands from 'state/commands'
|
import commands from 'state/commands'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { getPage, getSelectedIds } from 'utils/utils'
|
import { getPage, getSelectedIds } from 'utils'
|
||||||
|
|
||||||
export default class DirectionSession extends BaseSession {
|
export default class DirectionSession extends BaseSession {
|
||||||
delta = [0, 0]
|
delta = [0, 0]
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { current } from 'immer'
|
||||||
import { Data, DrawShape } from 'types'
|
import { Data, DrawShape } from 'types'
|
||||||
import BaseSession from './base-session'
|
import BaseSession from './base-session'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
import { getPage, getShape, updateParents } from 'utils/utils'
|
import { getPage, getShape, updateParents } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import commands from 'state/commands'
|
import commands from 'state/commands'
|
||||||
export default class BrushSession extends BaseSession {
|
export default class BrushSession extends BaseSession {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Data, Shape } from 'types'
|
||||||
import BaseSession from './base-session'
|
import BaseSession from './base-session'
|
||||||
import commands from 'state/commands'
|
import commands from 'state/commands'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { getPage, getSelectedShapes, getShape } from 'utils/utils'
|
import { getPage, getSelectedShapes, getShape } from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default class EditSession extends BaseSession {
|
export default class EditSession extends BaseSession {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import vec from 'utils/vec'
|
||||||
import BaseSession from './base-session'
|
import BaseSession from './base-session'
|
||||||
import commands from 'state/commands'
|
import commands from 'state/commands'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { getPage } from 'utils/utils'
|
import { getPage } from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default class HandleSession extends BaseSession {
|
export default class HandleSession extends BaseSession {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
getDocumentBranch,
|
getDocumentBranch,
|
||||||
setToArray,
|
setToArray,
|
||||||
getSelectedIds,
|
getSelectedIds,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
const PI2 = Math.PI * 2
|
const PI2 = Math.PI * 2
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
getTransformedBoundingBox,
|
getTransformedBoundingBox,
|
||||||
setToArray,
|
setToArray,
|
||||||
updateParents,
|
updateParents,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
|
|
||||||
export default class TransformSession extends BaseSession {
|
export default class TransformSession extends BaseSession {
|
||||||
scaleX = 1
|
scaleX = 1
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
getShape,
|
getShape,
|
||||||
getSelectedShapes,
|
getSelectedShapes,
|
||||||
updateParents,
|
updateParents,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
|
|
||||||
export default class TransformSingleSession extends BaseSession {
|
export default class TransformSingleSession extends BaseSession {
|
||||||
transformType: Edge | Corner
|
transformType: Edge | Corner
|
||||||
|
|
|
@ -3,7 +3,7 @@ import vec from 'utils/vec'
|
||||||
import BaseSession from './base-session'
|
import BaseSession from './base-session'
|
||||||
import commands from 'state/commands'
|
import commands from 'state/commands'
|
||||||
import { current } from 'immer'
|
import { current } from 'immer'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import {
|
import {
|
||||||
getChildIndexAbove,
|
getChildIndexAbove,
|
||||||
getDocumentBranch,
|
getDocumentBranch,
|
||||||
|
@ -11,7 +11,7 @@ import {
|
||||||
getSelectedShapes,
|
getSelectedShapes,
|
||||||
setSelectedIds,
|
setSelectedIds,
|
||||||
updateParents,
|
updateParents,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { getShapeUtils } from 'state/shape-utils'
|
import { getShapeUtils } from 'state/shape-utils'
|
||||||
|
|
||||||
export default class TranslateSession extends BaseSession {
|
export default class TranslateSession extends BaseSession {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getArcLength, uniqueId } from 'utils/utils'
|
import { getArcLength, uniqueId } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import {
|
import {
|
||||||
getSvgPathFromStroke,
|
getSvgPathFromStroke,
|
||||||
|
@ -6,7 +6,7 @@ import {
|
||||||
getBoundsFromPoints,
|
getBoundsFromPoints,
|
||||||
translateBounds,
|
translateBounds,
|
||||||
pointsBetween,
|
pointsBetween,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import {
|
import {
|
||||||
ArrowShape,
|
ArrowShape,
|
||||||
DashStyle,
|
DashStyle,
|
||||||
|
@ -14,7 +14,7 @@ import {
|
||||||
ShapeHandle,
|
ShapeHandle,
|
||||||
ShapeType,
|
ShapeType,
|
||||||
} from 'types'
|
} from 'types'
|
||||||
import { circleFromThreePoints, isAngleBetween } from 'utils/utils'
|
import { circleFromThreePoints, isAngleBetween } from 'utils'
|
||||||
import { pointInBounds } from 'utils/hitTests'
|
import { pointInBounds } from 'utils/hitTests'
|
||||||
import {
|
import {
|
||||||
intersectArcBounds,
|
intersectArcBounds,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import { DotShape, ShapeType } from 'types'
|
import { DotShape, ShapeType } from 'types'
|
||||||
import { boundsContained } from 'utils/bounds'
|
import { boundsContained } from 'utils/bounds'
|
||||||
import { intersectCircleBounds } from 'utils/intersections'
|
import { intersectCircleBounds } from 'utils/intersections'
|
||||||
import { translateBounds } from 'utils/utils'
|
import { translateBounds } from 'utils'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
import { registerShapeUtils } from './register'
|
import { registerShapeUtils } from './register'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { DashStyle, DrawShape, ShapeStyles, ShapeType } from 'types'
|
import { DashStyle, DrawShape, ShapeStyles, ShapeType } from 'types'
|
||||||
import { intersectPolylineBounds } from 'utils/intersections'
|
import { intersectPolylineBounds } from 'utils/intersections'
|
||||||
|
@ -9,7 +9,7 @@ import {
|
||||||
getBoundsFromPoints,
|
getBoundsFromPoints,
|
||||||
getSvgPathFromStroke,
|
getSvgPathFromStroke,
|
||||||
translateBounds,
|
translateBounds,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { defaultStyle, getShapeStyle } from 'state/shape-styles'
|
import { defaultStyle, getShapeStyle } from 'state/shape-styles'
|
||||||
import { registerShapeUtils } from './register'
|
import { registerShapeUtils } from './register'
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {
|
||||||
getSvgPathFromStroke,
|
getSvgPathFromStroke,
|
||||||
rng,
|
rng,
|
||||||
translateBounds,
|
translateBounds,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { defaultStyle, getShapeStyle } from 'state/shape-styles'
|
import { defaultStyle, getShapeStyle } from 'state/shape-styles'
|
||||||
import getStroke from 'perfect-freehand'
|
import getStroke from 'perfect-freehand'
|
||||||
import { registerShapeUtils } from './register'
|
import { registerShapeUtils } from './register'
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { GroupShape, ShapeType } from 'types'
|
import { GroupShape, ShapeType } from 'types'
|
||||||
import { getShapeUtils } from './index'
|
import { getShapeUtils } from './index'
|
||||||
import { getCommonBounds, translateBounds } from 'utils/utils'
|
import { getCommonBounds, translateBounds } from 'utils'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
import styled from 'styles'
|
import styled from 'styles'
|
||||||
import { registerShapeUtils } from './register'
|
import { registerShapeUtils } from './register'
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { LineShape, ShapeType } from 'types'
|
import { LineShape, ShapeType } from 'types'
|
||||||
import { boundsContained } from 'utils/bounds'
|
import { boundsContained } from 'utils/bounds'
|
||||||
import { intersectCircleBounds } from 'utils/intersections'
|
import { intersectCircleBounds } from 'utils/intersections'
|
||||||
import { ThinLine } from 'components/canvas/misc'
|
import { ThinLine } from 'components/canvas/misc'
|
||||||
import { translateBounds } from 'utils/utils'
|
import { translateBounds } from 'utils'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
import { registerShapeUtils } from './register'
|
import { registerShapeUtils } from './register'
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { PolylineShape, ShapeType } from 'types'
|
import { PolylineShape, ShapeType } from 'types'
|
||||||
import { intersectPolylineBounds } from 'utils/intersections'
|
import { intersectPolylineBounds } from 'utils/intersections'
|
||||||
import { boundsContainPolygon } from 'utils/bounds'
|
import { boundsContainPolygon } from 'utils/bounds'
|
||||||
import { getBoundsFromPoints, translateBounds } from 'utils/utils'
|
import { getBoundsFromPoints, translateBounds } from 'utils'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
import { registerShapeUtils } from './register'
|
import { registerShapeUtils } from './register'
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { RayShape, ShapeType } from 'types'
|
import { RayShape, ShapeType } from 'types'
|
||||||
import { boundsContained } from 'utils/bounds'
|
import { boundsContained } from 'utils/bounds'
|
||||||
import { intersectCircleBounds } from 'utils/intersections'
|
import { intersectCircleBounds } from 'utils/intersections'
|
||||||
import { ThinLine } from 'components/canvas/misc'
|
import { ThinLine } from 'components/canvas/misc'
|
||||||
import { translateBounds } from 'utils/utils'
|
import { translateBounds } from 'utils'
|
||||||
import { defaultStyle } from 'state/shape-styles'
|
import { defaultStyle } from 'state/shape-styles'
|
||||||
import { registerShapeUtils } from './register'
|
import { registerShapeUtils } from './register'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { DashStyle, RectangleShape, ShapeType } from 'types'
|
import { DashStyle, RectangleShape, ShapeType } from 'types'
|
||||||
import {
|
import {
|
||||||
|
@ -7,7 +7,7 @@ import {
|
||||||
rng,
|
rng,
|
||||||
shuffleArr,
|
shuffleArr,
|
||||||
pointsBetween,
|
pointsBetween,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import { defaultStyle, getShapeStyle } from 'state/shape-styles'
|
import { defaultStyle, getShapeStyle } from 'state/shape-styles'
|
||||||
import getStroke from 'perfect-freehand'
|
import getStroke from 'perfect-freehand'
|
||||||
import { registerShapeUtils } from './register'
|
import { registerShapeUtils } from './register'
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import { Shape, ShapeUtility } from 'types'
|
import { Shape, ShapeUtility } from 'types'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import {
|
import { getBoundsCenter, getBoundsFromPoints, getRotatedCorners } from 'utils'
|
||||||
getBoundsCenter,
|
|
||||||
getBoundsFromPoints,
|
|
||||||
getRotatedCorners,
|
|
||||||
} from 'utils/utils'
|
|
||||||
import { boundsCollidePolygon, boundsContainPolygon } from 'utils/bounds'
|
import { boundsCollidePolygon, boundsContainPolygon } from 'utils/bounds'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { pointInBounds } from 'utils/hitTests'
|
import { pointInBounds } from 'utils/hitTests'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { uniqueId, isMobile } from 'utils/utils'
|
import { uniqueId, isMobile } from 'utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { TextShape, ShapeType, FontSize } from 'types'
|
import { TextShape, ShapeType, FontSize } from 'types'
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import {
|
||||||
getPageState,
|
getPageState,
|
||||||
setToArray,
|
setToArray,
|
||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
} from 'utils/utils'
|
} from 'utils'
|
||||||
import {
|
import {
|
||||||
Data,
|
Data,
|
||||||
PointerInfo,
|
PointerInfo,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Data, PageState, TLDocument } from 'types'
|
import { Data, PageState, TLDocument } from 'types'
|
||||||
import { decompress, compress, setToArray } from 'utils/utils'
|
import { decompress, compress, setToArray } from 'utils'
|
||||||
import state from './state'
|
import state from './state'
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId } from 'utils'
|
||||||
import * as idb from 'idb-keyval'
|
import * as idb from 'idb-keyval'
|
||||||
|
|
||||||
const CURRENT_VERSION = 'code_slate_0.0.8'
|
const CURRENT_VERSION = 'code_slate_0.0.8'
|
||||||
|
|
11
types.ts
11
types.ts
|
@ -355,6 +355,17 @@ export enum DistributeType {
|
||||||
Vertical,
|
Vertical,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BezierCurveSegment {
|
||||||
|
start: number[]
|
||||||
|
tangentStart: number[]
|
||||||
|
normalStart: number[]
|
||||||
|
pressureStart: number
|
||||||
|
end: number[]
|
||||||
|
tangentEnd: number[]
|
||||||
|
normalEnd: number[]
|
||||||
|
pressureEnd: number
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------- */
|
/* -------------------------------------------------- */
|
||||||
/* Code Editor */
|
/* Code Editor */
|
||||||
/* -------------------------------------------------- */
|
/* -------------------------------------------------- */
|
||||||
|
|
1
utils/index.ts
Normal file
1
utils/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from './utils'
|
|
@ -1,5 +1,5 @@
|
||||||
// Some helpers for drawing SVGs.
|
// Some helpers for drawing SVGs.
|
||||||
import { getSweep } from 'utils/utils'
|
import { getSweep } from 'utils'
|
||||||
|
|
||||||
// General
|
// General
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue