Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
add fill option
Browse files Browse the repository at this point in the history
  • Loading branch information
slmjkdbtl committed Sep 20, 2023
1 parent 095cdd6 commit 6bb44c3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 5 additions & 2 deletions src/kaboom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const VERSION = "3000.1.8"
const VERSION = "3000.1.9"

import initApp from "./app"

Expand Down Expand Up @@ -125,6 +125,7 @@ import type {
RectComp,
RectCompOpt,
UVQuadComp,
CircleCompOpt,
CircleComp,
OutlineComp,
TimerComp,
Expand Down Expand Up @@ -4527,6 +4528,7 @@ export default (gopt: KaboomOpt = {}): KaboomCtx => {
width: this.width,
height: this.height,
radius: this.radius,
fill: opt.fill,
}))
},
renderArea() {
Expand Down Expand Up @@ -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<CircleComp>) {
drawCircle(Object.assign(getRenderProps(this), {
radius: this.radius,
fill: opt.fill,
}))
},
renderArea(this: GameObj<AnchorComp | CircleComp>) {
Expand Down
15 changes: 15 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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.
Expand Down

0 comments on commit 6bb44c3

Please sign in to comment.