Extract element functions into modules (#207)
This commit is contained in:
40
src/element/newElement.ts
Normal file
40
src/element/newElement.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { RoughCanvas } from "roughjs/bin/canvas";
|
||||
|
||||
import { SceneState } from "../scene/types";
|
||||
import { randomSeed } from "../random";
|
||||
|
||||
export function newElement(
|
||||
type: string,
|
||||
x: number,
|
||||
y: number,
|
||||
strokeColor: string,
|
||||
backgroundColor: string,
|
||||
fillStyle: string,
|
||||
strokeWidth: number,
|
||||
roughness: number,
|
||||
opacity: number,
|
||||
width = 0,
|
||||
height = 0
|
||||
) {
|
||||
const element = {
|
||||
type: type,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
isSelected: false,
|
||||
strokeColor: strokeColor,
|
||||
backgroundColor: backgroundColor,
|
||||
fillStyle: fillStyle,
|
||||
strokeWidth: strokeWidth,
|
||||
roughness: roughness,
|
||||
opacity: opacity,
|
||||
seed: randomSeed(),
|
||||
draw(
|
||||
rc: RoughCanvas,
|
||||
context: CanvasRenderingContext2D,
|
||||
sceneState: SceneState
|
||||
) {}
|
||||
};
|
||||
return element;
|
||||
}
|
Reference in New Issue
Block a user