mirror of
https://github.com/processing/processing4.git
synced 2026-02-11 01:29:17 +01:00
finish ltext and rtext debugging
This commit is contained in:
@@ -606,55 +606,47 @@ public class PFont implements PConstants {
|
||||
* This method is incomplete and should not be used.
|
||||
*/
|
||||
public void ltext(char c, float x, float y, PGraphics parent) {
|
||||
//PGraphics parent = g;
|
||||
PFont font = this;
|
||||
|
||||
int glyph = font.index(c);
|
||||
int glyph = index(c);
|
||||
if (glyph == -1) return;
|
||||
|
||||
//int xx = (int) x + font.leftExtent[glyph];
|
||||
//int yy = (int) y - font.topExtent[glyph];
|
||||
// starting point on the screen
|
||||
int xx = (int) x - font.topExtent[glyph];
|
||||
//+ font.leftExtent[glyph];
|
||||
//int yy = (int) y + font.leftExtent[glyph]; //- font.topExtent[glyph];
|
||||
//int yy = (int)y;
|
||||
int yy = (int) y - font.leftExtent[glyph];
|
||||
// top-lefthand corner of the char
|
||||
int sx = (int) x - topExtent[glyph];
|
||||
int sy = (int) y - leftExtent[glyph];
|
||||
|
||||
// boundary of the character's pixel buffer to copy
|
||||
int x0 = 0;
|
||||
int y0 = 0;
|
||||
int w0 = font.width[glyph];
|
||||
int h0 = font.height[glyph];
|
||||
int px = 0;
|
||||
int py = 0;
|
||||
int pw = width[glyph];
|
||||
int ph = height[glyph];
|
||||
|
||||
// if the character is off the screen
|
||||
if ((xx >= parent.width) || (yy >= parent.height) ||
|
||||
(yy + w0 < 0) || (xx + h0 < 0)) return;
|
||||
//(xx + w0 < 0) || (yy + h0 < 0)) return;
|
||||
if ((sx >= parent.width) || // top of letter past width
|
||||
(sy - pw >= parent.height) ||
|
||||
(sy + pw < 0) ||
|
||||
(sx + ph < 0)) return;
|
||||
|
||||
if (xx < 0) { // if starting x is off screen
|
||||
//x0 -= xx; // chop that amount off of the image area to be copied
|
||||
//w0 += xx; // and reduce the width by that (negative) amount
|
||||
y0 -= xx;
|
||||
h0 += xx;
|
||||
xx = 0;
|
||||
if (sx < 0) { // if starting x is off screen
|
||||
py -= sx;
|
||||
ph += sx;
|
||||
sx = 0;
|
||||
}
|
||||
if (yy < 0) {
|
||||
//y0 -= yy;
|
||||
//h0 += yy;
|
||||
x0 -= yy;
|
||||
w0 += yy;
|
||||
yy = 0;
|
||||
if (sx + ph >= parent.width) {
|
||||
ph -= ((sx + ph) - parent.width);
|
||||
}
|
||||
//if (xx + w0 > parent.width) { // if the ending x is off screen
|
||||
if (xx + h0 > parent.width) { // if the ending x is off screen
|
||||
//w0 -= ((xx + w0) - parent.width);
|
||||
h0 -= ((xx + h0) - parent.width);
|
||||
|
||||
if (sy < pw) {
|
||||
//int extra = pw - sy;
|
||||
pw -= -1 + pw - sy;
|
||||
//px -= sy;
|
||||
//pw += sy;
|
||||
//sy = 0;
|
||||
}
|
||||
//if (yy + h0 > parent.height) {
|
||||
if (yy + w0 > parent.height) {
|
||||
//h0 -= ((yy + h0) - parent.height);
|
||||
w0 -= ((yy + w0) - parent.height);
|
||||
if (sy >= parent.height) { // off bottom edge
|
||||
int extra = 1 + sy - parent.height;
|
||||
pw -= extra;
|
||||
px += extra;
|
||||
sy -= extra;
|
||||
//pw -= ((sy + pw) - parent.height);
|
||||
}
|
||||
|
||||
int fr = parent.fillRi;
|
||||
@@ -662,22 +654,20 @@ public class PFont implements PConstants {
|
||||
int fb = parent.fillBi;
|
||||
int fa = parent.fillAi;
|
||||
|
||||
int pixels1[] = font.images[glyph].pixels;
|
||||
int pixels1[] = images[glyph].pixels;
|
||||
int pixels2[] = parent.pixels;
|
||||
|
||||
// loop over the source pixels in the character image
|
||||
// row & col is the row and column of the source image
|
||||
// (but they become col & row in the target image)
|
||||
for (int row = y0; row < y0 + h0; row++) {
|
||||
for (int col = x0; col < x0 + w0; col++) {
|
||||
int a1 = (fa * pixels1[row * font.twidth + col]) >> 8;
|
||||
for (int row = py; row < py + ph; row++) {
|
||||
for (int col = px; col < px + pw; col++) {
|
||||
int a1 = (fa * pixels1[row * twidth + col]) >> 8;
|
||||
int a2 = a1 ^ 0xff;
|
||||
int p1 = pixels1[row * font.width[glyph] + col];
|
||||
int p1 = pixels1[row * width[glyph] + col];
|
||||
|
||||
try {
|
||||
//int index = (yy + row-y0)*parent.width + (xx+col-x0);
|
||||
int index = (yy + x0-col)*parent.width + (xx+row-y0);
|
||||
//int index = (yy + col)*parent.width + (xx+row-y0);
|
||||
int index = (sy + px-col)*parent.width + (sx+row-py);
|
||||
int p2 = pixels2[index];
|
||||
|
||||
pixels2[index] =
|
||||
@@ -686,7 +676,7 @@ public class PFont implements PConstants {
|
||||
(( a1 * fg + a2 * ((p2 >> 8) & 0xff)) & 0xff00) |
|
||||
(( a1 * fb + a2 * ( p2 & 0xff)) >> 8));
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
System.out.println("out of bounds " + yy + " " + x0 + " " + col);
|
||||
System.out.println("out of bounds " + sy + " " + px + " " + col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
X properly swap alpha values when lines need to be rendered backwards
|
||||
X make cursor() commands public
|
||||
X ltext and rtext for screen space stuff
|
||||
X ltext is broken when it goes y < 0 or y > height
|
||||
X ltext & rtext completely working
|
||||
|
||||
_ now that it's actually a key, should it be a char? (what's keyChar?)
|
||||
_ that way println(c) would work a little better..
|
||||
@@ -12,6 +14,11 @@ _ write PApplet2, a full screen version of PApplet
|
||||
_ this might be used for presentation mode
|
||||
|
||||
text fixes
|
||||
_ need to resolve rotated text in SCREEN_SPACE
|
||||
_ SCREEN_SPACE is weird for text
|
||||
_ does the font or PApplet control the size? (the font, ala java)
|
||||
_ without setting the font, the values come out weird rotated text
|
||||
_ get rotated text into the screen space stuff
|
||||
_ if a word (no spaces) is too long to fit, insert a 'space'
|
||||
_ move left/center/right aligning into the font class
|
||||
_ otherwise text with alignment has problems with returns
|
||||
@@ -41,11 +48,6 @@ _ test with rgb cube, shut off smoothing
|
||||
_ make sure line artifacts are because of smoothing
|
||||
_ implement 2x oversampling for anti-aliasing
|
||||
|
||||
_ need to resolve rotated text in SCREEN_SPACE
|
||||
_ SCREEN_SPACE is weird for text
|
||||
_ does the font or PApplet control the size? (the font, ala java)
|
||||
_ without setting the font, the values come out weird rotated text
|
||||
_ get rotated text into the screen space stuff
|
||||
_ make PApplet2 that handles full screen 1.4 mode drawing
|
||||
|
||||
_ api for file-based renderers
|
||||
|
||||
Reference in New Issue
Block a user