Skip to content

Commit

Permalink
feat: 新增options
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Heng committed Jul 20, 2023
1 parent 2925313 commit c1975d8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ import { BaseService } from '@pictode/utils';
import { fabric } from 'fabric';

import { Rect } from './customs/rect';
import { EventArgs, Plugin } from './types';
import { AppOptions, EventArgs, Plugin } from './types';

type Model = 'select' | 'drawing' | 'rect' | 'circle';

export class App extends BaseService<EventArgs> {
public canvas: fabric.Canvas;

private options?: AppOptions;
private installedPlugins: Map<string, Plugin> = new Map();
private canvasEl: HTMLCanvasElement;

constructor() {
constructor(options?: AppOptions) {
super();
this.options = options;
this.canvasEl = document.createElement('canvas');
this.canvas = new fabric.Canvas(null, {
backgroundColor: 'lightgray',
backgroundColor: options?.backgroundColor,
});
}

Expand Down
32 changes: 32 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,35 @@ export interface Plugin {
}

export interface EventArgs {}

export interface ControlVisible {
bl?: boolean;
br?: boolean;
mb?: boolean;
ml?: boolean;
mr?: boolean;
mt?: boolean;
tl?: boolean;
tr?: boolean;
mtr?: boolean;
}

export interface Controls {
enable?: boolean;
padding?: number;
borderColor?: string;
cornerColor?: string;
connerStrokeColor?: string;
cornerStyle?: 'rect' | 'circle';
cornerSize?: number;
rotatingPointOffset?: number;
transparentCorners?: boolean;
centeredScaling?: boolean;
centeredRotation?: boolean;
controlVisible?: ControlVisible;
}

export interface AppOptions {
backgroundColor?: string;
controls?: Controls;
}

0 comments on commit c1975d8

Please sign in to comment.