Skip to content

Commit 4a5f775

Browse files
committed
1 parent 189b717 commit 4a5f775

4 files changed

Lines changed: 83 additions & 2 deletions

File tree

java/examples/Basics/Shape/LoadDisplayOBJ/LoadDisplayOBJ.pde

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
* OBJ file of a rocket and displays it to the screen.
77
*/
88

9-
// The next line is needed if running in JavaScript Mode with Processing.js
10-
/* @pjs preload="rocket.obj"; */
119

1210
PShape rocket;
1311

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* Blending
3+
* by Andres Colubri.
4+
*
5+
* Images can be blended using one of the 10 blending modes
6+
* (currently available only in P2D and P3).
7+
* Click to go to cycle through the modes.
8+
*/
9+
10+
// NOTE: THIS EXAMPLE IS IN PROGRESS -- REAS
11+
12+
PImage img1, img2;
13+
int selMode = REPLACE;
14+
String name = "REPLACE";
15+
int picAlpha = 255;
16+
17+
void setup() {
18+
size(640, 360, P3D);
19+
img1 = loadImage("layer1.jpg");
20+
img2 = loadImage("layer2.jpg");
21+
noStroke();
22+
}
23+
24+
void draw() {
25+
26+
picAlpha = int(map(mouseX, 0, width, 0, 255));
27+
28+
background(0);
29+
30+
tint(255, 255);
31+
image(img1, 0, 0);
32+
33+
blendMode(selMode);
34+
tint(255, picAlpha);
35+
image(img2, 0, 0);
36+
37+
blendMode(REPLACE);
38+
fill(255);
39+
rect(0, 0, 94, 22);
40+
fill(0);
41+
text(name, 10, 15);
42+
}
43+
44+
void mousePressed() {
45+
46+
if (selMode == REPLACE) {
47+
selMode = BLEND;
48+
name = "BLEND";
49+
} else if (selMode == BLEND) {
50+
selMode = ADD;
51+
name = "ADD";
52+
} else if (selMode == ADD) {
53+
selMode = SUBTRACT;
54+
name = "SUBTRACT";
55+
} else if (selMode == SUBTRACT) {
56+
selMode = LIGHTEST;
57+
name = "LIGHTEST";
58+
} else if (selMode == LIGHTEST) {
59+
selMode = DARKEST;
60+
name = "DARKEST";
61+
} else if (selMode == DARKEST) {
62+
selMode = DIFFERENCE;
63+
name = "DIFFERENCE";
64+
} else if (selMode == DIFFERENCE) {
65+
selMode = EXCLUSION;
66+
name = "EXCLUSION";
67+
} else if (selMode == EXCLUSION) {
68+
selMode = MULTIPLY;
69+
name = "MULTIPLY";
70+
} else if (selMode == MULTIPLY) {
71+
selMode = SCREEN;
72+
name = "SCREEN";
73+
} else if (selMode == SCREEN) {
74+
selMode = REPLACE;
75+
name = "REPLACE";
76+
}
77+
}
78+
79+
void mouseDragged() {
80+
if (height - 50 < mouseY) {
81+
picAlpha = int(map(mouseX, 0, width, 0, 255));
82+
}
83+
}
163 KB
Loading
244 KB
Loading

0 commit comments

Comments
 (0)