Skip to content

Commit 71d0e21

Browse files
committed
Fix Processing Java constants: TOP/BOTTOM/BASELINE, blend modes, filter values, stroke values; add textAlign vertical support
1 parent 8cee9a2 commit 71d0e21

2 files changed

Lines changed: 38 additions & 21 deletions

File tree

src/Processing.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,9 @@ void PApplet::textAlign(int alignX, int alignY) {
24232423
if(a==37||a==20) return LEFT_ALIGN; // LEFT or LEFT_ALIGN
24242424
if(a==39||a==21) return RIGHT_ALIGN; // RIGHT or RIGHT_ALIGN
24252425
if(a==3 ||a==25) return CENTER_ALIGN; // CENTER or CENTER_ALIGN
2426-
if(a==0) return BASELINE;
2426+
if(a==101||a==22) return TOP_ALIGN; // TOP or TOP_ALIGN
2427+
if(a==102||a==23) return BOTTOM_ALIGN;// BOTTOM or BOTTOM_ALIGN
2428+
if(a==0) return BASELINE; // BASELINE
24272429
return a;
24282430
};
24292431
g_textAlignX = mapAlign(alignX);

src/Processing.h

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,12 @@ void tint(const PColor& c);
524524

525525
static constexpr int THRESHOLD = 1;
526526
static constexpr int GRAY = 2;
527-
static constexpr int OPAQUE = 3;
527+
static constexpr int OPAQUE = 14;
528528
static constexpr int INVERT = 4;
529-
static constexpr int POSTERIZE = 5;
530-
static constexpr int BLUR = 6;
531-
static constexpr int ERODE = 7;
532-
static constexpr int DILATE = 8;
529+
static constexpr int POSTERIZE = 8;
530+
static constexpr int BLUR = 11;
531+
static constexpr int ERODE = 15;
532+
static constexpr int DILATE = 16;
533533

534534
// =============================================================================
535535
// PIMAGE -- Pixel buffer backed by an OpenGL texture
@@ -1180,7 +1180,7 @@ static constexpr int CENTER = 3; // middle mouse button; also rectMode/el
11801180

11811181
// Color modes
11821182
static constexpr int RGB = 1;
1183-
static constexpr int HSB = 2;
1183+
static constexpr int HSB = 3;
11841184
#define ARGB 3 /* createImage(w,h,ARGB) */
11851185

11861186
// Shape / rect / ellipse modes
@@ -1190,10 +1190,10 @@ static constexpr int RADIUS = 2;
11901190

11911191
// Stroke caps and joins
11921192
static constexpr int ROUND = 10;
1193-
static constexpr int SQUARE = 11;
1194-
static constexpr int PROJECT = 12;
1195-
static constexpr int MITER = 13;
1196-
static constexpr int BEVEL = 14;
1193+
static constexpr int SQUARE = 1;
1194+
static constexpr int PROJECT = 4;
1195+
static constexpr int MITER = 8;
1196+
static constexpr int BEVEL = 32;
11971197

11981198
// beginShape() kinds
11991199
static constexpr int POINTS = 0;
@@ -1206,23 +1206,38 @@ static constexpr int QUAD_STRIP = 6;
12061206
static constexpr int CLOSE = 7;
12071207

12081208
// Text alignment
1209+
// Text alignment internal constants
12091210
static constexpr int LEFT_ALIGN = 20;
12101211
static constexpr int RIGHT_ALIGN = 21;
12111212
static constexpr int TOP_ALIGN = 22;
12121213
static constexpr int BOTTOM_ALIGN = 23;
1213-
static constexpr int BASELINE = 24;
1214+
static constexpr int BASELINE = 0; // Processing Java value
12141215
static constexpr int CENTER_ALIGN = 25;
1216+
// Processing Java textAlign vertical aliases
1217+
static constexpr int TOP = 101;
1218+
static constexpr int BOTTOM = 102;
12151219

12161220
// Blend modes
1217-
static constexpr int BLEND = 30;
1218-
static constexpr int ADD = 31;
1219-
static constexpr int SUBTRACT = 32;
1220-
static constexpr int MULTIPLY = 33;
1221-
static constexpr int SCREEN = 34;
1222-
static constexpr int DARKEST = 35;
1223-
static constexpr int LIGHTEST = 36;
1224-
static constexpr int DIFFERENCE = 37;
1225-
static constexpr int EXCLUSION = 38;
1221+
static constexpr int BLEND = 1;
1222+
static constexpr int ADD = 2;
1223+
static constexpr int SUBTRACT = 4;
1224+
static constexpr int MULTIPLY = 128;
1225+
static constexpr int SCREEN = 256;
1226+
static constexpr int DARKEST = 8;
1227+
static constexpr int LIGHTEST = 16;
1228+
static constexpr int DIFFERENCE = 32;
1229+
static constexpr int EXCLUSION = 64;
1230+
static constexpr int OVERLAY = 512;
1231+
static constexpr int HARD_LIGHT = 1024;
1232+
static constexpr int SOFT_LIGHT = 2048;
1233+
static constexpr int DODGE = 4096;
1234+
static constexpr int BURN = 8192;
1235+
static constexpr int REPLACE = 0;
1236+
// Boolean aliases
1237+
#ifndef TRUE
1238+
#define TRUE true
1239+
#define FALSE false
1240+
#endif
12261241

12271242
// Math constants (float precision)
12281243
static constexpr float PI = static_cast<float>(M_PI);

0 commit comments

Comments
 (0)