Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions core/test/processing/visual/src/test/blendmodes/BlendModeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,92 @@ public void draw(PApplet p) {
}
}, new TestConfig(50, 50));
}
@Test
@Order(12)
@DisplayName("blendMode(OVERLAY)")
public void testOverlay() {
assertVisualMatch("blend-modes/overlay",
createBlendTest(PApplet.OVERLAY),
new TestConfig(50, 50));
}

@Test
@Order(13)
@DisplayName("blendMode(HARD_LIGHT)")
public void testHardLight() {
assertVisualMatch("blend-modes/hard-light",
createBlendTest(PApplet.HARD_LIGHT),
new TestConfig(50, 50));
}

@Test
@Order(14)
@DisplayName("blendMode(SOFT_LIGHT)")
public void testSoftLight() {
assertVisualMatch("blend-modes/soft-light",
createBlendTest(PApplet.SOFT_LIGHT),
new TestConfig(50, 50));
}
@Test
@Order(15)
@DisplayName("blendMode with background color change")
public void testBlendWithBackground() {
assertVisualMatch("blend-modes/background-blend", new ProcessingSketch() {
@Override
public void setup(PApplet p) {
p.noStroke();
}

@Override
public void draw(PApplet p) {
p.background(255);

// Draw gradient-like background
for (int i = 0; i < 50; i++) {
p.fill(i * 5, 0, 255 - i * 5);
p.rect(i, 0, 1, 50);
}

// Overlay with different blend modes
p.blendMode(PApplet.MULTIPLY);
p.fill(255, 200, 0, 180);
p.rect(5, 5, 40, 40);
}
}, new TestConfig(50, 50));
}

@Test
@Order(16)
@DisplayName("Blend mode reset to BLEND after change")
public void testBlendModeReset() {
assertVisualMatch("blend-modes/mode-reset", new ProcessingSketch() {
@Override
public void setup(PApplet p) {
p.noStroke();
}

@Override
public void draw(PApplet p) {
p.background(128);

p.blendMode(PApplet.ADD);
p.fill(200, 0, 0, 160);
p.rect(5, 5, 20, 40);

// Reset back to BLEND
p.blendMode(PApplet.BLEND);
p.fill(0, 200, 0, 160);
p.rect(15, 5, 20, 40);

p.blendMode(PApplet.SUBTRACT);
p.fill(0, 0, 200, 160);
p.rect(25, 5, 20, 40);

// Final reset
p.blendMode(PApplet.BLEND);
p.fill(200, 200, 0, 160);
p.rect(35, 5, 10, 40);
}
}, new TestConfig(50, 50));
}
}
120 changes: 120 additions & 0 deletions core/test/processing/visual/src/test/shapes/ColorTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package processing.visual.src.test.shapes;

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("shapes")
@Tag("color")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ColorTest extends VisualTest {

@Test
@Order(1)
@DisplayName("Fill with RGB color")
public void testFillRGB() {
assertVisualMatch("shapes/color-fill-rgb", new ProcessingSketch() {
@Override
public void setup(PApplet p) {
p.background(255);
p.noStroke();
}
@Override
public void draw(PApplet p) {
p.fill(255, 0, 0);
p.rect(5, 5, 15, 40);
p.fill(0, 255, 0);
p.rect(20, 5, 15, 40);
p.fill(0, 0, 255);
p.rect(35, 5, 10, 40);
}
}, new TestConfig(50, 50));
}

@Test
@Order(2)
@DisplayName("Fill with alpha transparency")
public void testFillAlpha() {
assertVisualMatch("shapes/color-fill-alpha", new ProcessingSketch() {
@Override
public void setup(PApplet p) {
p.background(255);
p.noStroke();
}
@Override
public void draw(PApplet p) {
p.fill(255, 0, 0);
p.rect(5, 5, 30, 40);
p.fill(0, 0, 255, 128);
p.rect(15, 5, 30, 40);
}
}, new TestConfig(50, 50));
}

@Test
@Order(3)
@DisplayName("Stroke color")
public void testStrokeColor() {
assertVisualMatch("shapes/color-stroke", new ProcessingSketch() {
@Override
public void setup(PApplet p) {
p.background(255);
p.strokeWeight(3);
p.noFill();
}
@Override
public void draw(PApplet p) {
p.stroke(255, 0, 0);
p.rect(5, 5, 15, 15);
p.stroke(0, 255, 0);
p.rect(25, 5, 15, 15);
p.stroke(0, 0, 255);
p.rect(5, 25, 15, 15);
p.stroke(255, 165, 0);
p.rect(25, 25, 15, 15);
}
}, new TestConfig(50, 50));
}

@Test
@Order(4)
@DisplayName("HSB color mode")
public void testHSBColorMode() {
assertVisualMatch("shapes/color-hsb", new ProcessingSketch() {
@Override
public void setup(PApplet p) {
p.background(255);
p.noStroke();
p.colorMode(PApplet.HSB, 360, 100, 100);
}
@Override
public void draw(PApplet p) {
for (int i = 0; i < 5; i++) {
p.fill(i * 72, 80, 90);
p.rect(i * 10, 10, 10, 30);
}
}
}, new TestConfig(50, 50));
}

@Test
@Order(5)
@DisplayName("Background color")
public void testBackgroundColor() {
assertVisualMatch("shapes/color-background", new ProcessingSketch() {
@Override
public void setup(PApplet p) {
p.noStroke();
}
@Override
public void draw(PApplet p) {
p.background(100, 150, 200);
p.fill(255);
p.rect(10, 10, 30, 30);
}
}, new TestConfig(50, 50));
}
}

85 changes: 85 additions & 0 deletions core/test/processing/visual/src/test/shapes/ImageTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package processing.visual.src.test.shapes;

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("shapes")
@Tag("image")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ImageTest extends VisualTest {

@Test
@Order(1)
@DisplayName("Draw PImage")
public void testDrawImage() {
assertVisualMatch("shapes/image-draw", new ProcessingSketch() {
PImage img;
@Override
public void setup(PApplet p) {
img = p.createImage(20, 20, PApplet.RGB);
img.loadPixels();
for (int i = 0; i < img.pixels.length; i++) {
img.pixels[i] = p.color(255, 0, 0);
}
img.updatePixels();
}
@Override
public void draw(PApplet p) {
p.background(255);
p.image(img, 10, 10);
}
}, new TestConfig(50, 50));
}

@Test
@Order(2)
@DisplayName("Tint image")
public void testTintImage() {
assertVisualMatch("shapes/image-tint", new ProcessingSketch() {
PImage img;
@Override
public void setup(PApplet p) {
img = p.createImage(20, 20, PApplet.RGB);
img.loadPixels();
for (int i = 0; i < img.pixels.length; i++) {
img.pixels[i] = p.color(255);
}
img.updatePixels();
}
@Override
public void draw(PApplet p) {
p.background(255);
p.tint(0, 150, 255);
p.image(img, 5, 5);
p.noTint();
p.image(img, 25, 25);
}
}, new TestConfig(50, 50));
}

@Test
@Order(3)
@DisplayName("Resize image")
public void testResizeImage() {
assertVisualMatch("shapes/image-resize", new ProcessingSketch() {
PImage img;
@Override
public void setup(PApplet p) {
img = p.createImage(10, 10, PApplet.RGB);
img.loadPixels();
for (int i = 0; i < img.pixels.length; i++) {
img.pixels[i] = p.color(0, 200, 100);
}
img.updatePixels();
}
@Override
public void draw(PApplet p) {
p.background(255);
p.image(img, 5, 5, 40, 40);
}
}, new TestConfig(50, 50));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package processing.visual.src.test.shapes;

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("shapes")
@Tag("primitives")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class PrimitiveShapeTest extends VisualTest {

private ProcessingSketch createTest(ShapeCallback callback) {
return new ProcessingSketch() {
@Override
public void setup(PApplet p) {
p.background(200);
p.fill(255);
p.stroke(0);
}

@Override
public void draw(PApplet p) {
callback.draw(p);
}
};
}

@FunctionalInterface
interface ShapeCallback {
void draw(PApplet p);
}

@Test
@Order(1)
@DisplayName("Drawing a rectangle")
public void testRect() {
assertVisualMatch("shapes/rect", createTest(p -> {
p.rect(10, 10, 30, 30);
}), new TestConfig(50, 50));
}

@Test
@Order(2)
@DisplayName("Drawing an ellipse")
public void testEllipse() {
assertVisualMatch("shapes/ellipse", createTest(p -> {
p.ellipse(25, 25, 30, 20);
}), new TestConfig(50, 50));
}

@Test
@Order(3)
@DisplayName("Drawing a triangle")
public void testTriangle() {
assertVisualMatch("shapes/triangle", createTest(p -> {
p.triangle(25, 10, 10, 40, 40, 40);
}), new TestConfig(50, 50));
}

@Test
@Order(4)
@DisplayName("Drawing an arc")
public void testArc() {
assertVisualMatch("shapes/arc", createTest(p -> {
p.arc(25, 25, 30, 30, 0, PApplet.PI);
}), new TestConfig(50, 50));
}

@Test
@Order(5)
@DisplayName("Drawing a line")
public void testLine() {
assertVisualMatch("shapes/line", createTest(p -> {
p.line(10, 10, 40, 40);
}), new TestConfig(50, 50));
}

@Test
@Order(6)
@DisplayName("Drawing a point")
public void testPoint() {
assertVisualMatch("shapes/point", createTest(p -> {
p.strokeWeight(5);
p.point(25, 25);
}), new TestConfig(50, 50));
}
}
Loading