Skip to content

Commit

Permalink
Merge pull request #304 from akashic-games/add-composite-operation
Browse files Browse the repository at this point in the history
add difference and saturation to composite operation
  • Loading branch information
dera- authored Feb 26, 2024
2 parents 3966721 + 067dd4f commit 282637a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2.9.0
* @akashic/pdi-types@1.13.0 に追従
* サポートする `CompisiteOperation``"difference"``"saturation"` を追加(ただし Canvas 描画時のみ)

## 2.8.6
* `HTMLAudioPlayer#play()` で部分再生するかどうかの判定が誤っていたため修正

Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/renderer/Renderer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ describe("Renderer", () => {
"experimental-source-out",
"experimental-destination-in",
"experimental-destination-atop",
"difference",
"saturation"
];

for (const rendererCandidate of ["canvas", "webgl"]) {
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@akashic/pdi-browser",
"version": "2.8.6",
"version": "2.9.0",
"description": "An akashic-pdi implementation for Web browsers",
"main": "index.js",
"typings": "lib/full/index.d.ts",
Expand Down Expand Up @@ -43,7 +43,7 @@
"devDependencies": {
"@akashic/amflow": "^3.3.0",
"@akashic/eslint-config": "^2.0.0",
"@akashic/pdi-types": "^1.12.0",
"@akashic/pdi-types": "^1.13.0",
"@akashic/playlog": "^3.3.0",
"@types/jest": "^29.2.0",
"@types/node": "^18.0.0",
Expand Down
4 changes: 3 additions & 1 deletion src/canvas/context2d/Context2DRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const compositeOperationTable: { [P in pdi.CompositeOperationString]: string } =
"experimental-destination-in": "destination-in",
"destination-out": "destination-out",
"destination-over": "destination-over",
"xor": "xor"
"xor": "xor",
"difference": "difference",
"saturation": "saturation"
};

export class Context2DRenderer implements Renderer {
Expand Down
5 changes: 4 additions & 1 deletion src/canvas/webgl/WebGLSharedObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,10 @@ export class WebGLSharedObject {
"destination-over": [this._context.ONE_MINUS_DST_ALPHA, this._context.ONE],
"lighter": [this._context.ONE, this._context.ONE],
"copy": [this._context.ONE, this._context.ZERO],
"xor": [this._context.ONE_MINUS_DST_ALPHA, this._context.ONE_MINUS_SRC_ALPHA]
"xor": [this._context.ONE_MINUS_DST_ALPHA, this._context.ONE_MINUS_SRC_ALPHA],
// difference と saturation は WebGL での描画に対応していないため、source-over と同等の値にする
"difference": [this._context.ONE, this._context.ONE_MINUS_SRC_ALPHA],
"saturation": [this._context.ONE, this._context.ONE_MINUS_SRC_ALPHA],
};

const compositeOperation = this._compositeOps[this._currentCompositeOperation];
Expand Down

0 comments on commit 282637a

Please sign in to comment.