Skip to content

Commit 8808b98

Browse files
Refactor setAdditiveBlendMode to remove context parameter
- Removed the context parameter from the setAdditiveBlendMode function in both littlejs.release.js and engineDraw.js. - Updated the function to directly use drawContext for setting the globalCompositeOperation.
1 parent daa683b commit 8808b98

7 files changed

Lines changed: 11 additions & 16 deletions

File tree

dist/littlejs.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,9 +2016,8 @@ declare module "littlejsengine" {
20162016
export function drawTextScreen(text: string | number, pos: Vector2, size: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
20172017
/** Enable additive blending
20182018
* @param {boolean} [additive]
2019-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
20202019
* @memberof Draw */
2021-
export function setAdditiveBlendMode(additive?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
2020+
export function setAdditiveBlendMode(additive?: boolean): void;
20222021
/** Combines LittleJS canvases onto the main canvas
20232022
* This is necessary for things like screenshots and video
20242023
* @memberof Draw */

dist/littlejs.esm.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5189,12 +5189,11 @@ function isOnScreen(pos, size=0)
51895189

51905190
/** Enable additive blending
51915191
* @param {boolean} [additive]
5192-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
51935192
* @memberof Draw */
5194-
function setAdditiveBlendMode(additive=true, context=drawContext)
5193+
function setAdditiveBlendMode(additive=true)
51955194
{
51965195
glAdditive = additive;
5197-
context.globalCompositeOperation = additive ? 'lighter' : 'source-over';
5196+
drawContext.globalCompositeOperation = additive ? 'lighter' : 'source-over';
51985197
}
51995198

52005199
/** Combines LittleJS canvases onto the main canvas

dist/littlejs.esm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/littlejs.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5189,12 +5189,11 @@ function isOnScreen(pos, size=0)
51895189

51905190
/** Enable additive blending
51915191
* @param {boolean} [additive]
5192-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
51935192
* @memberof Draw */
5194-
function setAdditiveBlendMode(additive=true, context=drawContext)
5193+
function setAdditiveBlendMode(additive=true)
51955194
{
51965195
glAdditive = additive;
5197-
context.globalCompositeOperation = additive ? 'lighter' : 'source-over';
5196+
drawContext.globalCompositeOperation = additive ? 'lighter' : 'source-over';
51985197
}
51995198

52005199
/** Combines LittleJS canvases onto the main canvas

dist/littlejs.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/littlejs.release.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4501,12 +4501,11 @@ function isOnScreen(pos, size=0)
45014501

45024502
/** Enable additive blending
45034503
* @param {boolean} [additive]
4504-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
45054504
* @memberof Draw */
4506-
function setAdditiveBlendMode(additive=true, context=drawContext)
4505+
function setAdditiveBlendMode(additive=true)
45074506
{
45084507
glAdditive = additive;
4509-
context.globalCompositeOperation = additive ? 'lighter' : 'source-over';
4508+
drawContext.globalCompositeOperation = additive ? 'lighter' : 'source-over';
45104509
}
45114510

45124511
/** Combines LittleJS canvases onto the main canvas

src/engineDraw.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,12 +1183,11 @@ function isOnScreen(pos, size=0)
11831183

11841184
/** Enable additive blending
11851185
* @param {boolean} [additive]
1186-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
11871186
* @memberof Draw */
1188-
function setAdditiveBlendMode(additive=true, context=drawContext)
1187+
function setAdditiveBlendMode(additive=true)
11891188
{
11901189
glAdditive = additive;
1191-
context.globalCompositeOperation = additive ? 'lighter' : 'source-over';
1190+
drawContext.globalCompositeOperation = additive ? 'lighter' : 'source-over';
11921191
}
11931192

11941193
/** Combines LittleJS canvases onto the main canvas

0 commit comments

Comments
 (0)