first pile of fixes to bagel api

This commit is contained in:
benfry
2002-02-26 04:23:25 +00:00
parent 068d309d87
commit ef4798dfd2
2 changed files with 90 additions and 49 deletions

View File

@@ -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();
}