mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 01:50:44 +01:00
fixes for SCREEN_SPACE text and avoiding infinite loop in printMatrix
This commit is contained in:
@@ -530,6 +530,8 @@ public class PFont implements PConstants {
|
||||
*/
|
||||
|
||||
} else { // SCREEN_SPACE
|
||||
parent.loadPixels();
|
||||
|
||||
int xx = (int) x + leftExtent[glyph];;
|
||||
int yy = (int) y - topExtent[glyph];
|
||||
|
||||
@@ -583,6 +585,7 @@ public class PFont implements PConstants {
|
||||
(( a1 * fb + a2 * ( p2 & 0xff)) >> 8));
|
||||
}
|
||||
}
|
||||
parent.updatePixels();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1442,8 +1442,10 @@ public class PGraphics extends PImage implements PConstants {
|
||||
public void textFont(PFont which) {
|
||||
if (which != null) {
|
||||
textFont = which;
|
||||
//textFont.resetSize();
|
||||
//textFont.resetLeading();
|
||||
|
||||
if (textSpace == SCREEN_SPACE) {
|
||||
textSize(textFont.mbox);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new RuntimeException("a null PFont was passed to textFont()");
|
||||
@@ -1451,10 +1453,20 @@ public class PGraphics extends PImage implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the text size, also resets the value for the leading.
|
||||
*/
|
||||
public void textSize(float size) {
|
||||
if (textFont != null) {
|
||||
if ((textSpace == SCREEN_SPACE) &&
|
||||
(size != textFont.mbox)) {
|
||||
throw new RuntimeException("can't use textSize() with " +
|
||||
"textSpace(SCREEN_SPACE)");
|
||||
}
|
||||
textSize = size;
|
||||
textLeadingReset();
|
||||
textLeading = textSize *
|
||||
((textFont.ascent() + textFont.descent()) * 1.275f);
|
||||
//textLeadingReset();
|
||||
|
||||
} else {
|
||||
throw new RuntimeException("use textFont() before textSize()");
|
||||
@@ -1462,10 +1474,10 @@ public class PGraphics extends PImage implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
protected void textLeadingReset() {
|
||||
textLeading = textSize *
|
||||
((textFont.ascent() + textFont.descent()) * 1.275f);
|
||||
}
|
||||
//protected void textLeadingReset() {
|
||||
//textLeading = textSize *
|
||||
// ((textFont.ascent() + textFont.descent()) * 1.275f);
|
||||
//}
|
||||
|
||||
|
||||
public void textLeading(float leading) {
|
||||
@@ -1495,15 +1507,18 @@ public class PGraphics extends PImage implements PConstants {
|
||||
|
||||
|
||||
public void textSpace(int space) {
|
||||
textSpace = space;
|
||||
/*
|
||||
if (textFont != null) {
|
||||
textFont.space(space);
|
||||
textSpace = space;
|
||||
|
||||
// reset the font to its natural size
|
||||
// (helps with width calculations and all that)
|
||||
if (textSpace == SCREEN_SPACE) {
|
||||
textSize(textFont.mbox);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new RuntimeException("use textFont() before textSpace()");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -1854,7 +1869,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
|
||||
// avoid infinite loop
|
||||
if (Float.isNaN(big) || Float.isInfinite(big)) {
|
||||
big = 8; // set to something arbitrary
|
||||
big = 1000000; // set to something arbitrary
|
||||
}
|
||||
|
||||
int d = 1;
|
||||
|
||||
@@ -865,7 +865,10 @@ public class PGraphics2 extends PGraphics {
|
||||
//check_image_cache(image);
|
||||
// blit image to the screen
|
||||
//graphics.drawImage((BufferedImage) image.cache, 0, 0, null);
|
||||
push();
|
||||
resetMatrix();
|
||||
imageImpl(image, 0, 0, width, height, 0, 0, width, height);
|
||||
pop();
|
||||
}
|
||||
|
||||
|
||||
@@ -904,6 +907,9 @@ public class PGraphics2 extends PGraphics {
|
||||
|
||||
|
||||
public void loadPixels() {
|
||||
if ((pixels == null) || (pixels.length != width * height)) {
|
||||
pixels = new int[width * height];
|
||||
}
|
||||
((BufferedImage) image).getRGB(0, 0, width, height, pixels, 0, width);
|
||||
}
|
||||
|
||||
|
||||
@@ -2190,6 +2190,12 @@ public class PGraphics3 extends PGraphics {
|
||||
max(abs(m22), abs(m23))),
|
||||
max(max(abs(m30), abs(m31)),
|
||||
max(abs(m32), abs(m33))))));
|
||||
|
||||
// avoid infinite loop
|
||||
if (Float.isNaN(big) || Float.isInfinite(big)) {
|
||||
big = 1000000; // set to something arbitrary
|
||||
}
|
||||
|
||||
int d = 1;
|
||||
while ((big /= 10) != 0) d++; // cheap log()
|
||||
|
||||
@@ -2401,6 +2407,12 @@ public class PGraphics3 extends PGraphics {
|
||||
max(abs(p22), abs(p23))),
|
||||
max(max(abs(p30), abs(p31)),
|
||||
max(abs(p32), abs(p33))))));
|
||||
|
||||
// avoid infinite loop
|
||||
if (Float.isNaN(big) || Float.isInfinite(big)) {
|
||||
big = 1000000; // set to something arbitrary
|
||||
}
|
||||
|
||||
int d = 1;
|
||||
while ((big /= 10) != 0) d++; // cheap log()
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ X backwards rects and backwards ellipses weren't properly drawn
|
||||
X code now compensates for negative widths or swapped x1/x2
|
||||
X fix noLoop() not properly running
|
||||
X also fix redraw() to include interrupt() again
|
||||
X loadPixels throwing NPEs
|
||||
X fixes to SCREEN_SPACE text not being sized properly
|
||||
|
||||
X made loadStrings() and openStream(File) static again
|
||||
_ fix other stuff that's supposed to be static
|
||||
@@ -21,10 +23,12 @@ _ get SCREEN_SPACE text working again
|
||||
|
||||
_ rewrite library/howto.txt for to get rid of old interface
|
||||
|
||||
_ how to shut off rendering to screen when illustrator in use?
|
||||
_ need size(30000, 20000) for illustrator, problem in papplet
|
||||
|
||||
_ problem with flicker may be the lack of synchronization on g
|
||||
|
||||
_ updatePixels() not setting PApplet.pixels
|
||||
_ also throwing NPEs
|
||||
_ make loadPixels in PGraphics ignored, and put it in PApplet
|
||||
|
||||
_ closing window w/o first hitting stop() causes freak out
|
||||
|
||||
Reference in New Issue
Block a user