Skip to content

Commit

Permalink
impl: change_brush_transparency, set_brush_tranparency
Browse files Browse the repository at this point in the history
asdf
  • Loading branch information
gnlow committed Dec 26, 2023
1 parent b3fc678 commit d70ea86
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,15 @@ export class Entry {
set_thickness(n: number, obj: EntryContainer) {
obj.strokeThickness = n
}
change_brush_transparency(n: number, obj: EntryContainer) {
obj.brushTransparency += n
}
/**
* "TRAN-PARENCY!"
*/
set_brush_tranparency(n: number, obj: EntryContainer) {
obj.brushTransparency = n
}
brush_erase_all(obj: EntryContainer) {
obj._brushGraphics?.destroy()
delete obj._brushGraphics
Expand Down
12 changes: 12 additions & 0 deletions src/obj/EntryContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export abstract class EntryContainer extends EventEmitter {
this._brushGraphics = new Graphics()
this.strokeColor = this.strokeColor
this.strokeThickness = this.strokeThickness
this.brushTransparency = this.brushTransparency

this._lineListener = () => {
this._brushGraphics!.lineTo(
Expand Down Expand Up @@ -84,6 +85,17 @@ export abstract class EntryContainer extends EventEmitter {
this._brushGraphics.strokeStyle.width = n
}
}

_brushTransparency?: number
get brushTransparency() {
return this._brushTransparency || 0
}
set brushTransparency(n: number) {
this._brushTransparency = n
if (this._brushGraphics) {
this._brushGraphics.alpha = 1 - n / 100
}
}

abstract pixiSprite: Container

Expand Down

0 comments on commit d70ea86

Please sign in to comment.