-
-
Notifications
You must be signed in to change notification settings - Fork 148
Add visual tests for blendMode() across renderers #1440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
avinxshKD
wants to merge
2
commits into
processing:visual-testing
Choose a base branch
from
avinxshKD:visual-tests/blend-mode
base: visual-testing
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+270 Bytes
core/test/processing/visual/__screenshots__/blend-modes/add-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+266 Bytes
core/test/processing/visual/__screenshots__/blend-modes/blend-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+260 Bytes
core/test/processing/visual/__screenshots__/blend-modes/darkest-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+269 Bytes
core/test/processing/visual/__screenshots__/blend-modes/difference-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+264 Bytes
core/test/processing/visual/__screenshots__/blend-modes/exclusion-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+285 Bytes
core/test/processing/visual/__screenshots__/blend-modes/lightest-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+236 Bytes
core/test/processing/visual/__screenshots__/blend-modes/mode-switch-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+269 Bytes
core/test/processing/visual/__screenshots__/blend-modes/multiply-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+250 Bytes
core/test/processing/visual/__screenshots__/blend-modes/replace-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+269 Bytes
core/test/processing/visual/__screenshots__/blend-modes/screen-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+265 Bytes
core/test/processing/visual/__screenshots__/blend-modes/subtract-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
161 changes: 161 additions & 0 deletions
161
core/test/processing/visual/src/test/blendmodes/BlendModeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| package processing.visual.src.test.blendmodes; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import processing.core.*; | ||
| import processing.visual.src.test.base.VisualTest; | ||
| import processing.visual.src.core.ProcessingSketch; | ||
| import processing.visual.src.core.TestConfig; | ||
|
|
||
| @Tag("blend-modes") | ||
| @Tag("rendering") | ||
| @TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
| public class BlendModeTest extends VisualTest { | ||
|
|
||
| // Draws base rects with BLEND, then overlays a green rect using the given mode | ||
| private ProcessingSketch createBlendTest(int mode) { | ||
| return new ProcessingSketch() { | ||
| @Override | ||
| public void setup(PApplet p) { | ||
| p.background(128); | ||
| p.noStroke(); | ||
| } | ||
|
|
||
| @Override | ||
| public void draw(PApplet p) { | ||
| // Base layer — always drawn with normal BLEND | ||
| p.blendMode(PApplet.BLEND); | ||
| p.fill(200, 60, 60); | ||
| p.rect(5, 5, 30, 30); | ||
| p.fill(60, 60, 200); | ||
| p.rect(15, 15, 30, 30); | ||
|
|
||
| p.blendMode(mode); | ||
| p.fill(60, 200, 60, 160); | ||
| p.rect(10, 10, 30, 30); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| // ========== Individual Blend Modes ========== | ||
|
|
||
| @Test | ||
| @Order(1) | ||
| @DisplayName("blendMode(BLEND)") | ||
| public void testBlend() { | ||
| assertVisualMatch("blend-modes/blend", | ||
| createBlendTest(PApplet.BLEND), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| @Test | ||
| @Order(2) | ||
| @DisplayName("blendMode(ADD)") | ||
| public void testAdd() { | ||
| assertVisualMatch("blend-modes/add", | ||
| createBlendTest(PApplet.ADD), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| @Test | ||
| @Order(3) | ||
| @DisplayName("blendMode(SUBTRACT)") | ||
| public void testSubtract() { | ||
| assertVisualMatch("blend-modes/subtract", | ||
| createBlendTest(PApplet.SUBTRACT), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| @Test | ||
| @Order(4) | ||
| @DisplayName("blendMode(MULTIPLY)") | ||
| public void testMultiply() { | ||
| assertVisualMatch("blend-modes/multiply", | ||
| createBlendTest(PApplet.MULTIPLY), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| @Test | ||
| @Order(5) | ||
| @DisplayName("blendMode(SCREEN)") | ||
| public void testScreen() { | ||
| assertVisualMatch("blend-modes/screen", | ||
| createBlendTest(PApplet.SCREEN), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| @Test | ||
| @Order(6) | ||
| @DisplayName("blendMode(DARKEST)") | ||
| public void testDarkest() { | ||
| assertVisualMatch("blend-modes/darkest", | ||
| createBlendTest(PApplet.DARKEST), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| @Test | ||
| @Order(7) | ||
| @DisplayName("blendMode(LIGHTEST)") | ||
| public void testLightest() { | ||
| assertVisualMatch("blend-modes/lightest", | ||
| createBlendTest(PApplet.LIGHTEST), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| @Test | ||
| @Order(8) | ||
| @DisplayName("blendMode(DIFFERENCE)") | ||
| public void testDifference() { | ||
| assertVisualMatch("blend-modes/difference", | ||
| createBlendTest(PApplet.DIFFERENCE), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| @Test | ||
| @Order(9) | ||
| @DisplayName("blendMode(EXCLUSION)") | ||
| public void testExclusion() { | ||
| assertVisualMatch("blend-modes/exclusion", | ||
| createBlendTest(PApplet.EXCLUSION), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| @Test | ||
| @Order(10) | ||
| @DisplayName("blendMode(REPLACE)") | ||
| public void testReplace() { | ||
| assertVisualMatch("blend-modes/replace", | ||
| createBlendTest(PApplet.REPLACE), | ||
| new TestConfig(50, 50)); | ||
| } | ||
|
|
||
| // ========== Sequential Mode Switch ========== | ||
|
|
||
| @Test | ||
| @Order(11) | ||
| @DisplayName("Switching blend modes mid-sketch") | ||
| public void testModeSwitch() { | ||
| assertVisualMatch("blend-modes/mode-switch", new ProcessingSketch() { | ||
| @Override | ||
| public void setup(PApplet p) { | ||
| p.background(128); | ||
| p.noStroke(); | ||
| } | ||
|
|
||
| @Override | ||
| public void draw(PApplet p) { | ||
| // Each strip should only reflect its own blend mode | ||
| p.blendMode(PApplet.ADD); | ||
| p.fill(200, 60, 60, 160); | ||
| p.rect(5, 5, 20, 40); | ||
|
|
||
| p.blendMode(PApplet.MULTIPLY); | ||
| p.fill(60, 200, 60, 160); | ||
| p.rect(15, 5, 20, 40); | ||
|
|
||
| p.blendMode(PApplet.BLEND); | ||
| p.fill(60, 60, 200, 160); | ||
| p.rect(25, 5, 20, 40); | ||
| } | ||
| }, new TestConfig(50, 50)); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testModeSwitchis the only test that doesn't go throughcreateBlendTest, meaning its background setup lives in a separate code path.This is fine for now, but
createBlendTestalso hardcodesbackground(128)andnoStroke()— so if those defaults ever change,testModeSwitchwill silently drift out of sync. Worth either routing it through a shared base or leaving a comment that these need to be kept in step with thecreateBLendTest