mirror of
https://github.com/processing/processing4.git
synced 2026-02-02 13:21:07 +01:00
first pile of fixes to bagel api
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
@@ -11,6 +12,9 @@ public class ProcessingApplet extends Applet
|
||||
public Bagel g;
|
||||
public int pixels[];
|
||||
|
||||
MemoryImageSource mis;
|
||||
Image image;
|
||||
|
||||
public int mouseX, mouseY;
|
||||
public boolean mousePressed;
|
||||
boolean mousePressedBriefly; // internal only
|
||||
@@ -58,7 +62,7 @@ public class ProcessingApplet extends Applet
|
||||
if (g == null) {
|
||||
// if programmer hasn't added a special graphics
|
||||
// object, then setup a standard 320x240 one
|
||||
size(320, 240);
|
||||
size(100, 100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,11 +120,13 @@ public class ProcessingApplet extends Applet
|
||||
|
||||
|
||||
// this is where screen grab could attach itself
|
||||
|
||||
DirectColorModel cm =
|
||||
new DirectColorModel(32, 0x00ff0000, 0x0000ff00, 0x000000ff);
|
||||
|
||||
public void update() {
|
||||
Graphics g = this.getGraphics();
|
||||
if (g != null) {
|
||||
paint(g);
|
||||
}
|
||||
if (g != null) paint(g);
|
||||
}
|
||||
|
||||
public void update(Graphics screen) {
|
||||
@@ -128,6 +134,8 @@ public class ProcessingApplet extends Applet
|
||||
}
|
||||
|
||||
public void paint(Graphics screen) {
|
||||
mis.newPixels(pixels, cm, 0, width); // must call this
|
||||
|
||||
/*
|
||||
if ((thread == null) && !finished) {
|
||||
// kickstart my heart
|
||||
@@ -140,11 +148,11 @@ public class ProcessingApplet extends Applet
|
||||
screen.drawImage(g.image, 0, 0, null);
|
||||
}
|
||||
*/
|
||||
if (screen == null)
|
||||
System.out.println("ProcessinApplet.paint screen is null");
|
||||
if (g == null)
|
||||
System.out.println("ProcessinApplet.paint g is null");
|
||||
screen.drawImage(g.image, 0, 0, null);
|
||||
//if (screen == null)
|
||||
//System.out.println("ProcessinApplet.paint screen is null");
|
||||
//if (g == null)
|
||||
//System.out.println("ProcessinApplet.paint g is null");
|
||||
screen.drawImage(image, 0, 0, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -237,6 +245,15 @@ public class ProcessingApplet extends Applet
|
||||
g = new Bagel(width, height);
|
||||
pixels = g.pixels;
|
||||
|
||||
// because of a java bug
|
||||
for (int i = 0; i < pixels.length; i++) pixels[i] = 0xffffffff;
|
||||
|
||||
// setup MemoryImageSource
|
||||
mis = new MemoryImageSource(width, height, pixels, 0, width);
|
||||
mis.setFullBufferUpdates(true); // maybe this will help ipaq?
|
||||
mis.setAnimated(true);
|
||||
image = Toolkit.getDefaultToolkit().createImage(mis);
|
||||
|
||||
// set this here, and if not inside browser, getDocumentBase()
|
||||
// will fail with a NullPointerException, and cause applet to
|
||||
// be set to null. might be a better way to deal with that, but..
|
||||
@@ -774,6 +791,11 @@ public class ProcessingApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public void beginShape() {
|
||||
g.beginShape();
|
||||
}
|
||||
|
||||
|
||||
public void beginShape(int kind) {
|
||||
g.beginShape(kind);
|
||||
}
|
||||
@@ -809,8 +831,8 @@ public class ProcessingApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public void catmullRomVertex(float x, float y) {
|
||||
g.catmullRomVertex(x, y);
|
||||
public void curveVertex(float x, float y) {
|
||||
g.curveVertex(x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -840,11 +862,21 @@ public class ProcessingApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public void rectMode(int mode) {
|
||||
g.rectMode(mode);
|
||||
}
|
||||
|
||||
|
||||
public void rect(float x1, float y1, float x2, float y2) {
|
||||
g.rect(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
|
||||
public void ellipseMode(int mode) {
|
||||
g.ellipseMode(mode);
|
||||
}
|
||||
|
||||
|
||||
public void ellipse(float x, float y, float hradius, float vradius) {
|
||||
g.ellipse(x, y, hradius, vradius);
|
||||
}
|
||||
@@ -870,19 +902,19 @@ public class ProcessingApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public void bezierCurve(float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4) {
|
||||
g.bezierCurve(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
public void bezier(float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4) {
|
||||
g.bezier(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
}
|
||||
|
||||
|
||||
public void catmullRomCurve(float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4) {
|
||||
g.catmullRomCurve(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
public void curve(float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4) {
|
||||
g.curve(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
}
|
||||
|
||||
|
||||
@@ -962,6 +994,12 @@ public class ProcessingApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public void projectSize(float x, float y, float z,
|
||||
float w, float h, float d) {
|
||||
g.projectSize(x, y, z, w, h, d);
|
||||
}
|
||||
|
||||
|
||||
public void translate(float tx, float ty) {
|
||||
g.translate(tx, ty);
|
||||
}
|
||||
@@ -1122,13 +1160,13 @@ public class ProcessingApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public void lightsOn() {
|
||||
g.lightsOn();
|
||||
public void lights() {
|
||||
g.lights();
|
||||
}
|
||||
|
||||
|
||||
public void lightsOff() {
|
||||
g.lightsOff();
|
||||
public void noLights() {
|
||||
g.noLights();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,32 +3,36 @@ _ is it necessary to have fullscreen option on toolbar anymore?
|
||||
|
||||
|
||||
QUESTIONS
|
||||
_ lightsOff() seems dumb with noStroke and noFill
|
||||
X lightsOff() seems dumb with noStroke and noFill
|
||||
X lights() and noLights()
|
||||
_ what's better than POLYGON_CONVEX and POLYGON_CONCAVE?
|
||||
_ should we use jdk 1.3 or msft vm?
|
||||
|
||||
|
||||
BAGEL / high
|
||||
_ single color function inside applet
|
||||
_ need to clamp colors (nothing > 255 or < 0)
|
||||
_ do by simplifying stroke/fill/background inside bagel
|
||||
_ these should be done w/ a switch (STROKE, FILL, BK, OTHER)
|
||||
_ needs to be done inside cpp version too.. minimize amt of code
|
||||
_ rewrite fill/stroke/etc to use same code
|
||||
_ doesn't need to be super fast, so the extra assigns no big deal
|
||||
_ add ellipseMode(), rectMode()
|
||||
_ CENTER_RADIUS, CENTER_DIAMETER, CORNER
|
||||
_ make default size be 100x100
|
||||
_ make default background color 204
|
||||
_ curveVertex and bezierVertex instead of catmull/bezier crap
|
||||
_ garbage created when color values out of range
|
||||
_ move MemoryImageSource out of bagel and into ProcessingApplet
|
||||
_ need to run bagel to just render to a large internal buffer
|
||||
_ this fits better with the c++ model of things
|
||||
_ beginShape() defaults to POLYGON
|
||||
_ bezier and catmullrom aren't setting ndim to at least two
|
||||
_ translate(x, y) doesn't seem to affect a rect()
|
||||
_ same with rect. looks like this causing trouble with lots of things
|
||||
X change lightsOn/lightsOff to lights() and noLights()
|
||||
X beginShape() defaults to POLYGON
|
||||
X introduce constants for other poly modes
|
||||
X add ellipseMode(), rectMode()
|
||||
X CENTER_RADIUS, CENTER_DIAMETER, CORNER, TWO_CORNERS
|
||||
X bezier and catmullrom aren't setting ndim to at least two
|
||||
X ?? not sure why they would
|
||||
X translate(x, y) doesn't seem to affect a rect()
|
||||
X flat_rect was being used where ndim was 2, not 0
|
||||
X curveVertex and bezierVertex instead of catmull/bezier crap
|
||||
X single color function
|
||||
X need to clamp colors (nothing > 255 or < 0)
|
||||
X (garbage created when color values out of range)
|
||||
X do by simplifying stroke/fill/background inside bagel
|
||||
X these should be done w/ a switch (STROKE, FILL, BK, OTHER)
|
||||
X needs to be done inside cpp version too.. minimize amt of code
|
||||
X rewrite fill/stroke/etc to use same code
|
||||
X doesn't need to be super fast, so the extra assigns no big deal
|
||||
X move MemoryImageSource out of bagel and into ProcessingApplet
|
||||
X need to run bagel to just render to a large internal buffer
|
||||
X this fits better with the c++ model of things
|
||||
X make default size be 100x100
|
||||
X make default background color 204
|
||||
|
||||
|
||||
BAGEL / high & time consuming
|
||||
@@ -40,7 +44,8 @@ _ alpha
|
||||
_ concave/complex polygon shtuff
|
||||
_ eventually POLYGON auto-detects convex/concave polygon
|
||||
_ also add POLYGON_CONVEX and POLYGON_CONCAVE
|
||||
_ picking
|
||||
_ z coordinates are backwards from gl (at least from mazo)
|
||||
_ how did this happen? what's the appropriate way to fix?
|
||||
|
||||
|
||||
BAGEL / medium
|
||||
@@ -48,8 +53,6 @@ _ area copying functions
|
||||
_ copyPixel(x, y, to_x, to_y)
|
||||
_ copyArea(x, y, w, h, to_x, to_y)
|
||||
_ copyImage(x, y, w, h, to_x, to_y)
|
||||
_ z coordinates are backwards from gl (at least from mazo)
|
||||
_ how did this happen? what's the appropriate way to fix?
|
||||
_ NullPointerException apparently when things way offscreen
|
||||
_ i.e. glyphrot with scale set to 4
|
||||
_ or at least that things get ridiculously slow
|
||||
|
||||
Reference in New Issue
Block a user