41 lines
821 B
TypeScript
41 lines
821 B
TypeScript
|
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;
|
||
|
}
|