Skip to content

Commit

Permalink
add CanvasRenderingContext2D API description
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Jan 28, 2024
1 parent 279d9e0 commit 347b9b6
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions vstgui/uidescription-scripting/uiscripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,73 @@ struct DrawContextObject : ScriptObject,
void onDestroy (CScriptVar* v) override;

private:
// CanvasRenderingContext2D API
// clang-format off
/*
fillStyle: string | CanvasGradient | CanvasPattern;
filter: string
font: string;
fontKerning: string;
fontStretch: string;
fontVariantCaps: string;
globalAlpha: number;
globalCompositionOperation: string;
lineCap: string;
lineDashOffset: number;
lineJoin: string;
lineWidth: number;
miterLimit: number;
shadowBlur: number;
shadowColor: string;
shadowOffsetX: number;
shadowOffsetY: number;
strokeStyle: string;
textAlign: string;
textBaseline: string;
arc: (x: number, y: number, r: number, sAngle: number, eAngle: number, counterClockwise?: boolean) => void;
arcTo: (x1: number, y1: number, x2: number, y2: number, r: number) => void;
beginPath: () => void;
bezierCurveTo: (cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number) => void;
clearRect: (x: number, y: number, width: number, height: number) => void;
clip: () => void;
closePath: () => void;
createImageData: (width: number, height: number, imageData: ImageData) => void;
createLinearGradient: (x0: number, yo: number, x1: number, y1: number) => CanvasGradient;
createPattern: () => CanvasPattern;
createRadialGradient: (x0: number, y0: number, r0: number, x1: number, y1: number, r1: number) => CanvasGradient;
drawFocusIfNeeded: (html: HTMLElement) => void;
drawImage: (image: Image,dx: number,dy: number,sx?: number,sy?: number,sWidth?: number,sHeight?: number,dWidth?: number,dHeight?: number) => void;
ellipse: (x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean) => void;
fill: (Path2D?: Path2D, fillRule?: any) => void;
fillRect: (x: number, y: number, width: number, height: number) => void;
fillText: (text: string, x: number, y: number, maxWidth?: number) => void;
getImageData: (sx: number, sy: number, sw: number, sh: number) => Promise<ImageData>;
getLineDash: () => number[];
isPointInPath: (x: number, y: number, fillRule: any, path: Path2D) => boolean;
isPointInStroke: (x: number, y: number, path: Path2D) => boolean;
lineTo: (x: number, y: number) => void;
measureText: (text: string) => any;
moveTo: (x: number, y: number) => void;
putImageData: (imageData: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number) => void;
quadraticCurveTo: (cpx: number, cpy: number, x: number, y: number) => void;
rect: (x: number, y: number, width: number, height: number) => void;
reset: () => void
resetTransform: () => void
restore: () => void;
rotate: (angle: number) => void;
roundRect: (x: number, y: number, width: number, height: number, radii: number) => void
save: () => void;
scale: (x: number, y: number) => void;
setLineDash: (segments: number[]) => void;
setTransform: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
stroke: (path?: Path2D) => void;
strokeRect: (x: number, y: number, width: number, height: number) => void;
strokeText: (text: string, x: number, y: number, maxWidth?: number) => void;
transform: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
translate: (x: number, y: number) => void;
*/
// clang-format on

CDrawContext* context {nullptr};
IUIDescription* uiDesc {nullptr};
};
Expand Down Expand Up @@ -1256,6 +1323,8 @@ DrawContextObject::DrawContextObject ()
{
// TODO: decide if this object should expose the same interface as "CanvasRenderingContext2D"
scriptVar->setLifeTimeObserver (this);
#if 0
#else
addFunc ("drawLine"sv,
[this] (CScriptVar* var) {
if (!context)
Expand Down Expand Up @@ -1500,6 +1569,7 @@ DrawContextObject::DrawContextObject ()
context->setLineWidth (widthVar->getDouble ());
},
{"width"});
#endif
}

//------------------------------------------------------------------------
Expand Down

0 comments on commit 347b9b6

Please sign in to comment.