Adds code editing and shape generation
This commit is contained in:
parent
afa8f53dff
commit
1a01c47835
34 changed files with 1298 additions and 237 deletions
|
@ -2,16 +2,22 @@ import { Shape } from "types"
|
|||
import * as vec from "utils/vec"
|
||||
import { getShapeUtils } from "lib/shapes"
|
||||
|
||||
export const codeShapes = new Set<CodeShape<Shape>>([])
|
||||
|
||||
/**
|
||||
* A base class for code shapes. Note that creating a shape adds it to the
|
||||
* shape map, while deleting it removes it from the collected shapes set
|
||||
*/
|
||||
export default class CodeShape<T extends Shape> {
|
||||
private _shape: T
|
||||
|
||||
constructor(props: T) {
|
||||
this._shape = props
|
||||
shapeMap.add(this)
|
||||
codeShapes.add(this)
|
||||
}
|
||||
|
||||
destroy() {
|
||||
shapeMap.delete(this)
|
||||
codeShapes.delete(this)
|
||||
}
|
||||
|
||||
moveTo(point: number[]) {
|
||||
|
@ -50,5 +56,3 @@ export default class CodeShape<T extends Shape> {
|
|||
return this.shape.rotation
|
||||
}
|
||||
}
|
||||
|
||||
export const shapeMap = new Set<CodeShape<Shape>>([])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue