From 6bb44c389c208f59af4d3ee35a004a0467d00f43 Mon Sep 17 00:00:00 2001 From: tga Date: Wed, 20 Sep 2023 21:23:32 +0800 Subject: [PATCH] add fill option --- CHANGELOG.md | 3 +++ package.json | 2 +- src/kaboom.ts | 7 +++++-- src/types.ts | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 259261981..859c19d73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### v3000.1.9 +- added `fill` option to `rect()`, `circle()` and `sprite()` + ### v3000.1.8 - fixed `scale` option acting weird when width and height are defined (by @hirnsalat) diff --git a/package.json b/package.json index eada81d79..942e32cce 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "kaboom", "description": "kaboom.js is a JavaScript library that helps you make games fast and fun!", - "version": "3000.1.8", + "version": "3000.1.9", "license": "MIT", "homepage": "https://kaboomjs.com/", "repository": "github:replit/kaboom", diff --git a/src/kaboom.ts b/src/kaboom.ts index 8eff7a5be..f36682831 100644 --- a/src/kaboom.ts +++ b/src/kaboom.ts @@ -1,4 +1,4 @@ -const VERSION = "3000.1.8" +const VERSION = "3000.1.9" import initApp from "./app" @@ -125,6 +125,7 @@ import type { RectComp, RectCompOpt, UVQuadComp, + CircleCompOpt, CircleComp, OutlineComp, TimerComp, @@ -4527,6 +4528,7 @@ export default (gopt: KaboomOpt = {}): KaboomCtx => { width: this.width, height: this.height, radius: this.radius, + fill: opt.fill, })) }, renderArea() { @@ -4558,13 +4560,14 @@ export default (gopt: KaboomOpt = {}): KaboomCtx => { } } - function circle(radius: number): CircleComp { + function circle(radius: number, opt: CircleCompOpt = {}): CircleComp { return { id: "circle", radius: radius, draw(this: GameObj) { drawCircle(Object.assign(getRenderProps(this), { radius: this.radius, + fill: opt.fill, })) }, renderArea(this: GameObj) { diff --git a/src/types.ts b/src/types.ts index 038c53dc4..a4818ce45 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4344,6 +4344,10 @@ export interface SpriteCompOpt { * The rectangular sub-area of the texture to render, default to full texture `quad(0, 0, 1, 1)`. */ quad?: Quad, + /** + * If fill the sprite (useful if you only want to render outline with outline() component). + */ + fill?: boolean, } export interface SpriteComp extends Comp { @@ -4512,6 +4516,10 @@ export interface RectCompOpt { * Radius of the rectangle corners. */ radius?: number, + /** + * If fill the rectangle (useful if you only want to render outline with outline() component). + */ + fill?: boolean, } export interface RectComp extends Comp { @@ -4533,6 +4541,13 @@ export interface RectComp extends Comp { renderArea(): Rect, } +export interface CircleCompOpt { + /** + * If fill the circle (useful if you only want to render outline with outline() component). + */ + fill?: boolean, +} + export interface CircleComp extends Comp { /** * Radius of circle.