Skip to content

Commit a9089e4

Browse files
author
Kevin Busch
committed
Filled in some defaults for storybook
1 parent 52c1b88 commit a9089e4

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/atoms/forms/canvas-sketch/react-canvas-sketch.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ const canvasToolTypes = [
1818
export const reactCanvasSketch = () => (
1919
<ReactCanvasSketch
2020
backgroundImageUrl={text("Background Image URL", "https://rlv.zcache.com/yellow_emoji_birthday_party_happy_face_symbol_classic_round_sticker-r821c9ad7d35943228f0f0e973050e063_0ugmm_8byvr_704.jpg")}
21-
canvasHeight={number("Canvas Height", 500)}
21+
canvasHeight={number("Canvas Height", 720)}
2222
canvasWidth={number("Canvas Width", 1000)}
2323
className={text("Class Name", "")}
24-
containerHeight={number("Container Height", 300)}
25-
containerWidth={number("Container Width", 600)}
24+
containerHeight={number("Container Height", 700)}
25+
containerWidth={number("Container Width", 700)}
2626
onAddedStroke={(strokeSettings: CanvasDrawToolSettings) => { console.log(`onAddedStroke: ${JSON.stringify(strokeSettings)}`) }}
2727
redrawIncrement={number("Redraw Trigger Increment", 1)}
2828
canvasToolType={select("Tool Type", canvasToolTypes, CanvasToolType.pencil)}
2929
showCanvasBorder={boolean("Show Border", true)}
3030
toolWidth={number("Tool Width", 1)}
31-
toolColor={text("Tool Color", "FFFFFF")}
31+
toolColor={text("Tool Color", "#000000")}
3232
value={{ currentObjectIndex: -1, objects: [] }}
3333
/>
3434
);

src/atoms/forms/canvas-sketch/tools/line-canvas-draw-tool.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { PositionUtils } from "../utils/position-utils";
1010
// -------------------------------------------------------------------------------------------------
1111

1212
export interface LineStrokeSettings extends CanvasDrawToolSettings {
13-
left: number;
14-
top: number;
15-
x2: number;
16-
y2: number;
13+
endX: number;
14+
endY: number;
15+
startX: number;
16+
startY: number;
1717
}
1818

1919
// #endregion Interfaces
@@ -39,10 +39,10 @@ class LineCanvasDrawTool extends BaseCanvasDrawTool implements CanvasDrawTool {
3939

4040
public drawStrokes(strokes: CanvasDrawToolSettings[]): void {
4141
(strokes as LineStrokeSettings[]).forEach((stroke: LineStrokeSettings) => {
42-
const startX: number = stroke.left;
43-
const endX: number = stroke.left + (stroke.x2 * 2);
44-
const startY: number = stroke.top;
45-
const endY: number = stroke.top + (stroke.y2 * 2);
42+
const startX: number = stroke.startX;
43+
const endX: number = stroke.endX
44+
const startY: number = stroke.startY;
45+
const endY: number = stroke.endY;
4646

4747
const color = stroke.stroke;
4848
const width = stroke.strokeWidth;
@@ -143,13 +143,13 @@ class LineCanvasDrawTool extends BaseCanvasDrawTool implements CanvasDrawTool {
143143
private _getStrokeSettings(): LineStrokeSettings {
144144
// Put together tool stroke here
145145
return {
146-
left: this._previousPosition.x,
146+
endX: this._currentPosition.x,
147+
endY: this._currentPosition.y,
148+
startX: this._previousPosition.x,
149+
startY: this._previousPosition.y,
147150
stroke: this._uiSettings.color,
148151
strokeWidth: this._uiSettings.width,
149-
top: this._previousPosition.y,
150152
type: CanvasObjectType.line,
151-
x2: (this._currentPosition.x - this._previousPosition.x) / 2,
152-
y2: (this._currentPosition.y - this._previousPosition.y) / 2,
153153
};
154154
}
155155

0 commit comments

Comments
 (0)