todos and tweaks

This commit is contained in:
benfry
2005-03-28 01:16:16 +00:00
parent bbc893658c
commit 136aed53a4
5 changed files with 175 additions and 86 deletions

View File

@@ -435,8 +435,8 @@ public class PFont implements PConstants {
/**
* Draw a character at an x, y, z position.
*/
//public void text(char c, float x, float y, float z, PGraphics parent) {
protected void textImpl(char c, float x, float y, float z, PGraphics parent) {
protected void textImpl(char c, float x, float y, float z,
PGraphics parent) {
//if (!valid) return;
//if (!exists(c)) return;
@@ -643,8 +643,8 @@ public class PFont implements PConstants {
* Same as below, just without a z coordinate.
*/
public void text(String str, float x, float y,
float w, float h, PGraphics parent) {
text(str, x, y, 0, w, h, parent);
float c, float d, PGraphics parent) {
text(str, x, y, c, d, 0, parent);
}
@@ -673,7 +673,7 @@ public class PFont implements PConstants {
}
// ala illustrator, the text itself must fit inside the box
currentY += ascent();
currentY += ascent() * parent.textSize;
// if the box is already too small, tell em to f off
if (currentY > boxY2) return;
@@ -693,6 +693,7 @@ public class PFont implements PConstants {
// boundary of a word
float wordWidth = parent.textSize *
calcWidth(textBuffer, wordStart, index);
if (runningX + wordWidth > boxX2) {
if (runningX == boxX1) {
// if this is the first word, and its width is
@@ -703,6 +704,7 @@ public class PFont implements PConstants {
index--;
if (index == wordStart) {
// not a single char will fit on this line. screw 'em.
//System.out.println("screw you");
return;
}
wordWidth = parent.textSize *

View File

@@ -1399,11 +1399,25 @@ public class PGraphics extends PImage implements PConstants {
float a, float b, float c, float d,
int u1, int v1, int u2, int v2) {
if (imageMode == CORNER) {
if (c < 0) { // reset a negative width
a += c; c = -c;
}
if (d < 0) { // reset a negative height
b += d; d = -d;
}
imageImpl(image,
a, b, a + c, b + d,
u1, v1, u2, v2);
} else if (imageMode == CORNERS) {
if (c < a) { // reverse because x2 < x1
float temp = a; a = c; c = temp;
}
if (d < b) { // reverse because y2 < y1
float temp = b; b = d; d = temp;
}
imageImpl(image,
a, b, c, d,
u1, v1, u2, v2);
@@ -1420,6 +1434,10 @@ public class PGraphics extends PImage implements PConstants {
}
/**
* Expects x1, y1, x2, y2 coordinates where (x2 >= x1) and (y2 >= y1).
* If tint() has been called, the image will be colored.
*/
protected void imageImpl(PImage image,
float x1, float y1, float x2, float y2,
int u1, int v1, int u2, int v2) {
@@ -1578,6 +1596,11 @@ public class PGraphics extends PImage implements PConstants {
}
/**
* Newlines that are \n (unix newline or linefeed char, ascii 10)
* are honored, and \r (carriage return, windows and mac) are
* ignored.
*/
public void text(char c, float x, float y, float z) {
if ((z != 0) && (textSpace == SCREEN_SPACE)) {
String msg = "textSpace(SCREEN_SPACE) cannot have a z coordinate";
@@ -1639,6 +1662,10 @@ public class PGraphics extends PImage implements PConstants {
* Note that the x,y coords of the start of the box
* will align with the *ascent* of the text, not the baseline,
* as is the case for the other text() functions.
*
* Newlines that are \n (unix newline or linefeed char, ascii 10)
* are honored, and \r (carriage return, windows and mac) are
* ignored.
*/
public void text(String s, float x1, float y1, float x2, float y2) {
if (textFont != null) {

View File

@@ -33,7 +33,7 @@ import java.awt.image.*;
public class PGraphics2 extends PGraphics {
Graphics2D graphics;
public Graphics2D g2;
GeneralPath gpath;
int transformCount;
@@ -104,7 +104,7 @@ public class PGraphics2 extends PGraphics {
// broken out because of subclassing for opengl
protected void allocate() {
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
graphics = (Graphics2D) image.getGraphics();
g2 = (Graphics2D) image.getGraphics();
}
@@ -389,21 +389,21 @@ public class PGraphics2 extends PGraphics {
protected void stroke_shape(Shape s) {
if (stroke) {
//System.out.println("stroking shape");
graphics.setColor(strokeColorObject);
graphics.draw(s);
g2.setColor(strokeColorObject);
g2.draw(s);
}
}
protected void draw_shape(Shape s) {
if (fill) {
//System.out.println("filling shape");
graphics.setColor(fillColorObject);
graphics.fill(s);
g2.setColor(fillColorObject);
g2.fill(s);
}
if (stroke) {
//System.out.println("stroking shape");
graphics.setColor(strokeColorObject);
graphics.draw(s);
g2.setColor(strokeColorObject);
g2.draw(s);
}
}
@@ -605,7 +605,7 @@ public class PGraphics2 extends PGraphics {
//int x2 = (int) (x + w);
//int y2 = (int) (y + h);
graphics.drawImage(((ImageCache) who.cache).image,
g2.drawImage(((ImageCache) who.cache).image,
//(int) x, (int) y, x2, y2,
(int) x1, (int) y1, (int) x2, (int) y2,
u1, v1, u2, v2, null);
@@ -724,22 +724,22 @@ public class PGraphics2 extends PGraphics {
public void translate(float tx, float ty) {
graphics.translate(tx, ty);
g2.translate(tx, ty);
}
public void rotate(float angle) {
graphics.rotate(angle);
g2.rotate(angle);
}
public void scale(float s) {
graphics.scale(s, s);
g2.scale(s, s);
}
public void scale(float sx, float sy) {
graphics.scale(sx, sy);
g2.scale(sx, sy);
}
@@ -751,7 +751,7 @@ public class PGraphics2 extends PGraphics {
throw new RuntimeException("push() cannot use push more than " +
transformStack.length + " times");
}
transformStack[transformCount] = graphics.getTransform();
transformStack[transformCount] = g2.getTransform();
transformCount++;
}
@@ -761,23 +761,23 @@ public class PGraphics2 extends PGraphics {
throw new RuntimeException("missing a pop() to go with that push()");
}
transformCount--;
graphics.setTransform(transformStack[transformCount]);
g2.setTransform(transformStack[transformCount]);
}
public void resetMatrix() {
graphics.setTransform(new AffineTransform());
g2.setTransform(new AffineTransform());
}
public void applyMatrix(float n00, float n01, float n02,
float n10, float n11, float n12) {
graphics.transform(new AffineTransform(n00, n10, n01, n11, n02, n12));
g2.transform(new AffineTransform(n00, n10, n01, n11, n02, n12));
}
public void printMatrix() {
graphics.getTransform().getMatrix(transform);
g2.getTransform().getMatrix(transform);
m00 = (float) transform[0];
m01 = (float) transform[2];
@@ -792,14 +792,14 @@ public class PGraphics2 extends PGraphics {
public float screenX(float x, float y) {
graphics.getTransform().getMatrix(transform);
g2.getTransform().getMatrix(transform);
//return m00*x + m01*y + m02;
return (float)transform[0]*x + (float)transform[2]*y + (float)transform[4];
}
public float screenY(float x, float y) {
graphics.getTransform().getMatrix(transform);
g2.getTransform().getMatrix(transform);
return (float)transform[1]*x + (float)transform[3]*y + (float)transform[5];
}
@@ -860,7 +860,7 @@ public class PGraphics2 extends PGraphics {
join = BasicStroke.JOIN_ROUND;
}
graphics.setStroke(new BasicStroke(strokeWeight, cap, join));
g2.setStroke(new BasicStroke(strokeWeight, cap, join));
}
@@ -879,6 +879,7 @@ public class PGraphics2 extends PGraphics {
// make sure it's been properly updated
//check_image_cache(image);
// blit image to the screen
//g2.drawImage((BufferedImage) image.cache, 0, 0, null);
//graphics.drawImage((BufferedImage) image.cache, 0, 0, null);
push();
resetMatrix();
@@ -895,8 +896,8 @@ public class PGraphics2 extends PGraphics {
* even if noDepth() was called before draw() exited.
*/
public void clear() {
graphics.setColor(new Color(backgroundColor));
graphics.fillRect(0, 0, width, height);
g2.setColor(new Color(backgroundColor));
g2.fillRect(0, 0, width, height);
}
@@ -907,14 +908,14 @@ public class PGraphics2 extends PGraphics {
public void smooth() {
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
public void noSmooth() {
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
}

View File

@@ -194,7 +194,7 @@ public class PImage implements PConstants, Cloneable {
* just too weird for the other functions
*/
public void imageMode(int mode) {
if ((imageMode == CORNER) || (imageMode == CORNERS)) {
if ((mode == CORNER) || (mode == CORNERS)) {
imageMode = mode;
} else {
throw new RuntimeException("imageMode() only works with CORNER or CORNERS");

View File

@@ -5,50 +5,133 @@ X lines also getting vertically smashed together
X make a note of the change to font.width()
X backwards rects and backwards ellipses weren't properly drawn
X code now compensates for negative widths or swapped x1/x2
X what to do about backwards images
X imageMode() wasn't being set properly
X fix noLoop() not properly running
X If noLoop() is called in setup(), nothing is drawn to the screen.
X also fix redraw() to include interrupt() again
X loadPixels throwing NPEs
X fixes to SCREEN_SPACE text not being sized properly
X loadPixels()/updatePixels() on screen space text (ouch)
X get SCREEN_SPACE text working again
_ why is java2d so flickery?
X is it because the lock was taken off (g) in PApplet?
_ test to see whether it's still happening
_ saveFrame seems to be broken (PGraphics2 and PGraphicsGL?)
PApplet
_ updatePixels() not setting PApplet.pixels
_ make loadPixels in PGraphics ignored, and put it in PApplet
X made loadStrings() and openStream(File) static again
_ fix other stuff that's supposed to be static
_ text in a box is broken (at least for PGraphics2)
o get text rect working again (seems to be in infinite loop)
_ patch in newer jogl.. too many BSODs
PGraphics2
_ In this example, tint() is working fine with OpenGL,
_ but not working with the Processing renderer.
size(200, 200);
PImage a; // Declare variable "a" of type PImage
a = loadImage("arch.jpg"); // Load the images into the program
image(a, 0, 0); // Displays the image from point (0,0)
tint(255, 0, 0, 100);
image(a, width/2, 0, a.width/2, a.height/2);
PAppletGL
_ are draw mode apps now fixed in gl?
_ (gl was missing a beginFrame)
_ pmouseX, pmouseY are not working in OpenGL mode
_ (as they are working in Processing mode)
_ Stroking a rect() leaves the upper right pixel off.
_ points not working in opengl (carlos line truncation?)
void setup() {
size(200, 200);
background(0);
}
void draw() {
stroke(255);
point(60, 30);
}
. . . . .
0079+ core
api questions
_ alpha() colors are inverted (white is opaque.. doesn't make sense)
_ should we swap this around? also get rid of static version?
_ colorMode(GRAY) to avoid stroke(0) causing trouble?
_ or maybe get rid of stroke(0)? hrm
_ sphere x,y,z,r or box w,h,d.. need to make them consistent
_ look at curve functions more closely
_ should we switch to curveVertex(1,2,3) (ala curveto)
_ because some confusion with mixing types of curves
_ really need to take a look at the curve/vertex code
_ make sure we don't want curveVertices(1,2,3,u,v)
_ also make test cases so that java2d and java11 behave the same
_ make pappletgl work back inside papplet
_ and then size(300, 300, DEPTH) etc
_ get rid of opengl renderer menu
_ othersise hint() to use the p5 renderer instead of java2d
_ how to force PGraphics() instead of PGraphics2()
_ write filter() functions
_ remove SCREEN_SPACE altogether?
_ PImage.filter()
_ maybe use quasimonod's gaussian blur code?
_ http://incubator.quasimondo.com/processing/gaussian_blur_1.php
_ filter() on subsections? yes, in keeping with rest of api
_ PImage: remove the static versions of manipulators?
_ might be able to do a typed expand()
public Object growArray(Object array, int size) {
Class type = array.getClass().getComponentType();
Object grown = Array.newInstance(type, size);
System.arraycopy(array, 0, grown, 0,
Math.min(Array.getLength(array), size));
return grown;
}
_ should nf() handle commas as well?
_ yes, and add nf(int what) so that non-padded version works
_ but don't put commas into the zero-padded version
_ make nf/nfs/nfp not so weird
_ image(String name) and textFont(String name)
_ do we change to font(arial, 12) ?
_ how to shut off rendering to screen when illustrator in use?
_ need size(30000, 20000) for illustrator, problem in papplet
_ be consistent about getXxx() methods
_ or just what functions are actually made public
_ is fillRi needed? it's pretty goofy..
_ how to handle full screen (opengl especially) or no screen (for scripts)
_ implement fullsize().. this takes over the screen as best it can
_ or should it be more like present mode?
_ that if applet is 500x500, centers on a 800x600 window
_ though how do you get the screen size?
_ screen.width and screen.height?
_ particles lib requires depth() (but shouldn't)
_ fix for 78 since not sure when simon's new version is happening
_ something really bad happened with println() in this release
_ perhaps only without a code folder and/or running in java2d mode?
_ this may also be what's hosing
_ text should maybe use built-in font if available?
_ don't use pixels to do screen space text inside PFont
_ add a function in PGraphics for direct pixel image impl
_ in java2d, can quickly blit the image itself
_ this way, can isolate it for gl too, which will use glBitmap
X made loadStrings() and openStream(File) static again
_ fix other stuff that's supposed to be static
_ why is java2d so flickery?
X is it because the lock was taken off (g) in PApplet?
_ test to see whether it's still happening
_ draw method gl stuff fix? was missing a beginframe
_ get SCREEN_SPACE text working again
_ textFont with a named font can use the renderer/os font
_ PFont.list() to return string list of all the available fonts
_ for postscript, can grab the real font
_ -> altho problem here is that really the fonts just need a name
_ since needs to render to screen as well
_ 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
_ make loadPixels in PGraphics ignored, and put it in PApplet
_ closing window w/o first hitting stop() causes freak out
_ opengl gives an OutOfMemoryError
_ java2d just goes into a lock
@@ -60,7 +143,7 @@ _ doesn't seem to actually be stopping things
_ sphere() and box() should set normals and take textures
- applets on osx sometimes show up 20 pixels off the top
- applets on osx (and windows) sometimes show up 20 pixels off the top
_ implement PGraphics2.curveVertex()
@@ -72,29 +155,20 @@ _ make Graphics2 et al load dynamically using reflection
_ can this be done with g2 and if exception just falls back to g1?
_ this way people can remove g1 by hand
api todos
_ sphere x,y,z,r or box w,h,d.. need to make them consistent
_ look at curve functions more closely
_ should we switch to curveVertex(1,2,3) (ala curveto)
_ because some confusion with mixing types of curves
_ how to force PGraphics() instead of PGraphics2()
_ write filter() functions
_ remove SCREEN_SPACE altogether?
to be fixed with new lighting
_ The PushPop example in Transformations is not working
_ with lights() callled
_ The transparency of the Rotate3D example in Translformations
_ is not as expected
_ lighting totally sucks (both PGraphics3 and PGraphicsGL)
_ bring in materials for opengl as well?
_ don't include a class, just make it similar to the light functions
_ also have a simple way to hook in triangle leeches to PGraphics3
_ this exists, but needs to be documented, or have accessors
_ get PGraphics.java engine working again
lighting
_ lighting totally sucks (both PGraphics3 and PGraphicsGL)
_ bring in materials for opengl as well?
_ don't include a class, just make it similar to the light functions
_ be consistent about getXxx() methods
_ or just what functions are actually made public
_ is fillRi needed? it's pretty goofy..
_ beginShape()
_ don't allow you to draw stroked items unless stroke() is called
_ don't allow beginShape() if shape is already set
@@ -112,23 +186,8 @@ _ figure out how to handle cached images, multiple images
_ MediaTracker blocking is prolly making jar download really slow
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1089914280;start=0
_ image(String name) and textFont(String name)
_ do we change to font(arial, 12) ?
_ 404 error because first searches applet directory on zipdecode
_ how to handle full screen (opengl especially) or no screen (for scripts)
_ implement fullsize().. this takes over the screen as best it can
_ or should it be more like present mode?
_ that if applet is 500x500, centers on a 800x600 window
_ though how do you get the screen size?
_ screen.width and screen.height?
_ textFont with a named font can use the renderer/os font
_ PFont.list() to return string list of all the available fonts
_ for postscript, can grab the real font
_ -> altho problem here is that really the fonts just need a name
_ since needs to render to screen as well
//
_ when running externally, applets don't always get placed properly