From 8043e3af1e9afc5194c8e2207bba7245bb58d080 Mon Sep 17 00:00:00 2001 From: warxander Date: Sun, 19 Nov 2023 16:35:42 +0300 Subject: [PATCH] feat: Introduce `rect` item --- src/exports.ts | 1 + src/index.ts | 1 + src/items/rect.ts | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 src/items/rect.ts diff --git a/src/exports.ts b/src/exports.ts index 50cc193..71ae8a9 100644 --- a/src/exports.ts +++ b/src/exports.ts @@ -34,6 +34,7 @@ export * from './items/heading'; export * from './items/hyperlink'; export * from './items/label'; export * from './items/progressbar'; +export * from './items/rect'; export * from './items/selectable'; export * from './items/separator'; export * from './items/slider'; diff --git a/src/index.ts b/src/index.ts index 0c73a4c..369c542 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,6 +45,7 @@ globalThis.exports('heading', Exports.heading); globalThis.exports('hyperlink', Exports.hyperlink); globalThis.exports('label', Exports.label); globalThis.exports('progressBar', Exports.progressBar); +globalThis.exports('rect', Exports.rect); globalThis.exports('selectable', Exports.selectable); globalThis.exports('separator', Exports.separator); globalThis.exports('slider', Exports.slider); diff --git a/src/items/rect.ts b/src/items/rect.ts new file mode 100644 index 0000000..6ed9015 --- /dev/null +++ b/src/items/rect.ts @@ -0,0 +1,13 @@ +import { getFrameChecked } from '../core/frame'; + +export function rect(w: number, h: number, r: number, g: number, b: number, a: number) { + const frame = getFrameChecked(); + const painter = frame.getPainter(); + + frame.beginItem(w, h); + + painter.setColor([r, g, b, a]); + painter.drawRect(w, h); + + frame.endItem(); +}