Skip to content

Commit

Permalink
feat: Introduce rect item
Browse files Browse the repository at this point in the history
  • Loading branch information
warxander committed Nov 19, 2023
1 parent f5505cb commit 8043e3a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions src/items/rect.ts
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 8043e3a

Please sign in to comment.