mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
cleaning up new versions, things now compiling
This commit is contained in:
+53
-670
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,11 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
BConstants - numbers shared throughout the bagel engine
|
||||
Part of the Processing project - http://Proce55ing.net
|
||||
PConstants - numbers shared throughout processing.core
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2001-03
|
||||
Ben Fry, Massachusetts Institute of Technology and
|
||||
Casey Reas, Interaction Design Institute Ivrea
|
||||
Except where noted, code is written by Ben Fry and
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
@@ -24,11 +23,13 @@
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.core;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
|
||||
public interface BConstants {
|
||||
public interface PConstants {
|
||||
|
||||
// for better parity between c++ version (at no speed cost)
|
||||
|
||||
|
||||
+13
-175
@@ -23,21 +23,17 @@
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.core;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
#ifdef JDK13
|
||||
// for font builder.. but prolly no need to ifdef
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
#endif
|
||||
|
||||
|
||||
// value[] could be used to build a char to byte mapping table
|
||||
// as the font is loaded..
|
||||
// when generating, use the native char mapping.
|
||||
|
||||
public class BFont implements BConstants {
|
||||
public class PFont implements PConstants {
|
||||
|
||||
/**
|
||||
* This is the union of the Mac Roman and Windows ANSI
|
||||
@@ -98,7 +94,7 @@ public class BFont implements BConstants {
|
||||
|
||||
//int firstChar = 33; // always
|
||||
int charCount;
|
||||
BImage images[];
|
||||
PImage images[];
|
||||
|
||||
// image width, a power of 2
|
||||
// note! these will always be the same
|
||||
@@ -123,11 +119,11 @@ public class BFont implements BConstants {
|
||||
boolean cached;
|
||||
|
||||
|
||||
public BFont() { } // for BFontAI subclass and font builder
|
||||
public PFont() { } // for PFontAI subclass and font builder
|
||||
|
||||
|
||||
// can this throw an exception instead?
|
||||
public BFont(String filename, BGraphics parent) throws IOException {
|
||||
public PFont(String filename, PGraphics parent) throws IOException {
|
||||
//this.parent = parent;
|
||||
//this.valid = false;
|
||||
|
||||
@@ -145,158 +141,9 @@ public class BFont implements BConstants {
|
||||
}
|
||||
cached = false;
|
||||
size();
|
||||
//valid = true;
|
||||
|
||||
//} catch (IOException e) {
|
||||
//parent.message(COMPLAINT, "could not load font " + filename, e);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
#ifdef JDK13
|
||||
|
||||
public BFont(String name, int size) throws IOException {
|
||||
this(new Font(name, Font.PLAIN, size), true);
|
||||
}
|
||||
|
||||
public BFont(String name, int size, boolean smooth) throws IOException {
|
||||
this(new Font(name, Font.PLAIN, size), smooth);
|
||||
}
|
||||
|
||||
public BFont(Font font, boolean smooth) throws IOException {
|
||||
//int firstChar = 33;
|
||||
//int lastChar = 126;
|
||||
|
||||
//this.charCount = lastChar - firstChar + 1;
|
||||
this.charCount = charset.length;
|
||||
this.mbox = font.getSize();
|
||||
|
||||
// size for image/texture is next power of 2 over font size
|
||||
iwidth = iheight = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2)));
|
||||
|
||||
iwidthf = iheightf = (float) iwidth;
|
||||
|
||||
/*
|
||||
iwidth = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2)));
|
||||
iheight = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2)));
|
||||
|
||||
iwidthf = (float) iwidth;
|
||||
iheightf = (float) iheight;
|
||||
*/
|
||||
|
||||
images = new BImage[charCount];
|
||||
|
||||
// allocate enough space for the character info
|
||||
value = new int[charCount];
|
||||
height = new int[charCount];
|
||||
width = new int[charCount];
|
||||
setWidth = new int[charCount];
|
||||
topExtent = new int[charCount];
|
||||
leftExtent = new int[charCount];
|
||||
|
||||
int mbox3 = mbox * 3;
|
||||
|
||||
BufferedImage playground =
|
||||
new BufferedImage(mbox3, mbox3, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
Graphics2D g = (Graphics2D) playground.getGraphics();
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
smooth ?
|
||||
RenderingHints.VALUE_ANTIALIAS_ON :
|
||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
|
||||
g.setFont(font);
|
||||
FontMetrics metrics = g.getFontMetrics();
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
char c = charset[i];
|
||||
if (!font.canDisplay(c)) { // skip chars not in the font
|
||||
continue;
|
||||
}
|
||||
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0, 0, mbox3, mbox3);
|
||||
g.setColor(Color.black);
|
||||
g.drawString(String.valueOf(c), mbox, mbox * 2);
|
||||
|
||||
// grabs copy of the current data.. so no updates (do each time)
|
||||
Raster raster = playground.getData();
|
||||
|
||||
//int w = metrics.charWidth(c);
|
||||
int minX = 1000, maxX = 0;
|
||||
int minY = 1000, maxY = 0;
|
||||
boolean pixelFound = false;
|
||||
|
||||
for (int y = 0; y < mbox3; y++) {
|
||||
for (int x = 0; x < mbox3; x++) {
|
||||
int sample = raster.getSample(x, y, 0); // maybe?
|
||||
// or int samples[] = raster.getPixel(x, y, null);
|
||||
|
||||
//if (sample == 0) { // or just not white? hmm
|
||||
if (sample != 255) {
|
||||
if (x < minX) minX = x;
|
||||
if (y < minY) minY = y;
|
||||
if (x > maxX) maxX = x;
|
||||
if (y > maxY) maxY = y;
|
||||
pixelFound = true;
|
||||
//System.out.println(x + " " + y + " = " + sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pixelFound) {
|
||||
//System.out.println("no pixels found in char " + ((char)i));
|
||||
// this was dumb that it was set to 20 & 30, because for small
|
||||
// fonts, those guys don't exist
|
||||
minX = minY = 0; //20;
|
||||
maxX = maxY = 0; //30;
|
||||
|
||||
// this will create a 1 pixel white (clear) character..
|
||||
// maybe better to set one to -1 so nothing is added?
|
||||
}
|
||||
|
||||
value[index] = c;
|
||||
height[index] = (maxY - minY) + 1;
|
||||
width[index] = (maxX - minX) + 1;
|
||||
setWidth[index] = metrics.charWidth(c);
|
||||
|
||||
// offset from vertical location of baseline
|
||||
// of where the char was drawn (mbox*2)
|
||||
topExtent[index] = mbox*2 - minY;
|
||||
|
||||
// offset from left of where coord was drawn
|
||||
leftExtent[index] = minX - mbox;
|
||||
|
||||
//System.out.println(height[index] + " " + width[index] + " " +
|
||||
// setWidth[index] + " " +
|
||||
// topExtent[index] + " " + leftExtent[index]);
|
||||
|
||||
images[index] = new BImage(new int[width[index] * height[index]],
|
||||
width[index], height[index], ALPHA);
|
||||
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
//System.out.println("getting pixel " + x + " " + y);
|
||||
int value = 255 - raster.getSample(x, y, 0);
|
||||
int pindex = (y - minY) * width[index] + (x - minX);
|
||||
images[index].pixels[pindex] = value;
|
||||
//System.out.print(BApplet.nf(value, 3) + " ");
|
||||
}
|
||||
//System.out.println();
|
||||
}
|
||||
//System.out.println();
|
||||
index++;
|
||||
}
|
||||
charCount = index;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
public void write(OutputStream output) throws IOException {
|
||||
DataOutputStream os = new DataOutputStream(output);
|
||||
|
||||
@@ -383,12 +230,12 @@ public class BFont implements BConstants {
|
||||
is.readInt();
|
||||
}
|
||||
|
||||
images = new BImage[charCount];
|
||||
images = new PImage[charCount];
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
//int pixels[] = new int[64 * 64];
|
||||
int pixels[] = new int[iwidth * iheight];
|
||||
//images[i] = new BImage(pixels, 64, 64, ALPHA);
|
||||
images[i] = new BImage(pixels, iwidth, iheight, ALPHA);
|
||||
//images[i] = new PImage(pixels, 64, 64, ALPHA);
|
||||
images[i] = new PImage(pixels, iwidth, iheight, ALPHA);
|
||||
int bitmapSize = height[i] * width[i];
|
||||
|
||||
byte temp[] = new byte[bitmapSize];
|
||||
@@ -411,21 +258,13 @@ public class BFont implements BConstants {
|
||||
}
|
||||
//System.out.println();
|
||||
}
|
||||
//kind = VLW;
|
||||
}
|
||||
|
||||
|
||||
//boolean exists(char c) {
|
||||
//return ((c >= firstChar) && (c - firstChar < charCount));
|
||||
//}
|
||||
|
||||
|
||||
/**
|
||||
* Get index for the char (convert from unicode to bagel charset).
|
||||
* @return index into arrays or -1 if not found
|
||||
*/
|
||||
//static private int index(char c) {
|
||||
//static public int index(char c) {
|
||||
public int index(char c) {
|
||||
// these chars required in all fonts
|
||||
if ((c >= 33) && (c <= 126)) {
|
||||
@@ -440,7 +279,6 @@ public class BFont implements BConstants {
|
||||
// whups, this used the p5 charset rather than what was inside the font
|
||||
// meaning that old fonts would crash.. fixed for 0069
|
||||
|
||||
//static private int index_hunt(int c, int start, int stop) {
|
||||
private int index_hunt(int c, int start, int stop) {
|
||||
//System.out.println("checking between " + start + " and " + stop);
|
||||
int pivot = (start + stop) / 2;
|
||||
@@ -526,12 +364,12 @@ public class BFont implements BConstants {
|
||||
}
|
||||
|
||||
|
||||
public void text(char c, float x, float y, BGraphics parent) {
|
||||
public void text(char c, float x, float y, PGraphics parent) {
|
||||
text(c, x, y, 0, parent);
|
||||
}
|
||||
|
||||
|
||||
public void text(char c, float x, float y, float z, BGraphics parent) {
|
||||
public void text(char c, float x, float y, float z, PGraphics parent) {
|
||||
//if (!valid) return;
|
||||
//if (!exists(c)) return;
|
||||
|
||||
@@ -676,11 +514,11 @@ public class BFont implements BConstants {
|
||||
|
||||
private char c[] = new char[8192];
|
||||
|
||||
public void text(String str, float x, float y, BGraphics parent) {
|
||||
public void text(String str, float x, float y, PGraphics parent) {
|
||||
text(str, x, y, 0, parent);
|
||||
}
|
||||
|
||||
public void text(String str, float x, float y, float z, BGraphics parent) {
|
||||
public void text(String str, float x, float y, float z, PGraphics parent) {
|
||||
float startX = x;
|
||||
int index = 0;
|
||||
char previous = 0;
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
package processing.core;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
|
||||
|
||||
public class PFont2 extends PFont {
|
||||
|
||||
public PFont2(String name, int size) throws IOException {
|
||||
this(new Font(name, Font.PLAIN, size), true);
|
||||
}
|
||||
|
||||
public PFont2(String name, int size, boolean smooth) throws IOException {
|
||||
this(new Font(name, Font.PLAIN, size), smooth);
|
||||
}
|
||||
|
||||
public PFont2(Font font, boolean smooth) throws IOException {
|
||||
//int firstChar = 33;
|
||||
//int lastChar = 126;
|
||||
|
||||
//this.charCount = lastChar - firstChar + 1;
|
||||
this.charCount = charset.length;
|
||||
this.mbox = font.getSize();
|
||||
|
||||
// size for image/texture is next power of 2 over font size
|
||||
iwidth = iheight = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2)));
|
||||
|
||||
iwidthf = iheightf = (float) iwidth;
|
||||
|
||||
/*
|
||||
iwidth = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2)));
|
||||
iheight = (int)
|
||||
Math.pow(2, Math.ceil(Math.log(mbox) / Math.log(2)));
|
||||
|
||||
iwidthf = (float) iwidth;
|
||||
iheightf = (float) iheight;
|
||||
*/
|
||||
|
||||
images = new PImage[charCount];
|
||||
|
||||
// allocate enough space for the character info
|
||||
value = new int[charCount];
|
||||
height = new int[charCount];
|
||||
width = new int[charCount];
|
||||
setWidth = new int[charCount];
|
||||
topExtent = new int[charCount];
|
||||
leftExtent = new int[charCount];
|
||||
|
||||
int mbox3 = mbox * 3;
|
||||
|
||||
BufferedImage playground =
|
||||
new BufferedImage(mbox3, mbox3, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
Graphics2D g = (Graphics2D) playground.getGraphics();
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
smooth ?
|
||||
RenderingHints.VALUE_ANTIALIAS_ON :
|
||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
|
||||
g.setFont(font);
|
||||
FontMetrics metrics = g.getFontMetrics();
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
char c = charset[i];
|
||||
if (!font.canDisplay(c)) { // skip chars not in the font
|
||||
continue;
|
||||
}
|
||||
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0, 0, mbox3, mbox3);
|
||||
g.setColor(Color.black);
|
||||
g.drawString(String.valueOf(c), mbox, mbox * 2);
|
||||
|
||||
// grabs copy of the current data.. so no updates (do each time)
|
||||
Raster raster = playground.getData();
|
||||
|
||||
//int w = metrics.charWidth(c);
|
||||
int minX = 1000, maxX = 0;
|
||||
int minY = 1000, maxY = 0;
|
||||
boolean pixelFound = false;
|
||||
|
||||
for (int y = 0; y < mbox3; y++) {
|
||||
for (int x = 0; x < mbox3; x++) {
|
||||
int sample = raster.getSample(x, y, 0); // maybe?
|
||||
// or int samples[] = raster.getPixel(x, y, null);
|
||||
|
||||
//if (sample == 0) { // or just not white? hmm
|
||||
if (sample != 255) {
|
||||
if (x < minX) minX = x;
|
||||
if (y < minY) minY = y;
|
||||
if (x > maxX) maxX = x;
|
||||
if (y > maxY) maxY = y;
|
||||
pixelFound = true;
|
||||
//System.out.println(x + " " + y + " = " + sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pixelFound) {
|
||||
//System.out.println("no pixels found in char " + ((char)i));
|
||||
// this was dumb that it was set to 20 & 30, because for small
|
||||
// fonts, those guys don't exist
|
||||
minX = minY = 0; //20;
|
||||
maxX = maxY = 0; //30;
|
||||
|
||||
// this will create a 1 pixel white (clear) character..
|
||||
// maybe better to set one to -1 so nothing is added?
|
||||
}
|
||||
|
||||
value[index] = c;
|
||||
height[index] = (maxY - minY) + 1;
|
||||
width[index] = (maxX - minX) + 1;
|
||||
setWidth[index] = metrics.charWidth(c);
|
||||
|
||||
// offset from vertical location of baseline
|
||||
// of where the char was drawn (mbox*2)
|
||||
topExtent[index] = mbox*2 - minY;
|
||||
|
||||
// offset from left of where coord was drawn
|
||||
leftExtent[index] = minX - mbox;
|
||||
|
||||
//System.out.println(height[index] + " " + width[index] + " " +
|
||||
// setWidth[index] + " " +
|
||||
// topExtent[index] + " " + leftExtent[index]);
|
||||
|
||||
images[index] = new PImage(new int[width[index] * height[index]],
|
||||
width[index], height[index], ALPHA);
|
||||
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
//System.out.println("getting pixel " + x + " " + y);
|
||||
int value = 255 - raster.getSample(x, y, 0);
|
||||
int pindex = (y - minY) * width[index] + (x - minX);
|
||||
images[index].pixels[pindex] = value;
|
||||
//System.out.print(BApplet.nf(value, 3) + " ");
|
||||
}
|
||||
//System.out.println();
|
||||
}
|
||||
//System.out.println();
|
||||
index++;
|
||||
}
|
||||
charCount = index;
|
||||
}
|
||||
}
|
||||
+78
-76
@@ -1,10 +1,10 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
BGraphics - main graphics and rendering context for bagel
|
||||
PGraphics - main graphics and rendering context for bagel
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2001-03 Massachusetts Institute of Technology
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
(Except where noted that the author is not Ben Fry)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -23,6 +23,8 @@
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.core;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
@@ -32,7 +34,7 @@ import java.net.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
|
||||
public class BGraphics extends BImage implements BConstants {
|
||||
public class PGraphics extends PImage implements PConstants {
|
||||
public Applet applet; // not comfortable with this being static
|
||||
|
||||
// ........................................................
|
||||
@@ -131,7 +133,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
float lightX[], lightY[], lightZ[];
|
||||
int lightKind[];
|
||||
|
||||
// inherited from BImage
|
||||
// inherited from PImage
|
||||
//boolean smooth = false; // antialiasing
|
||||
|
||||
// projection
|
||||
@@ -183,12 +185,12 @@ public class BGraphics extends BImage implements BConstants {
|
||||
|
||||
// OLD_GRAPHICS
|
||||
|
||||
BPolygon polygon; // general polygon to use for shape
|
||||
BPolygon fpolygon; // used to fill polys for tri or quad strips
|
||||
BPolygon spolygon; // stroke/line polygon
|
||||
PPolygon polygon; // general polygon to use for shape
|
||||
PPolygon fpolygon; // used to fill polys for tri or quad strips
|
||||
PPolygon spolygon; // stroke/line polygon
|
||||
float svertices[][]; // temp vertices used for stroking end of poly
|
||||
|
||||
BPolygon tpolygon; // for calculating concave/convex
|
||||
PPolygon tpolygon; // for calculating concave/convex
|
||||
int TPOLYGON_MAX_VERTICES = 512;
|
||||
int tpolygon_vertex_order[]; // = new int[MAX_VERTICES];
|
||||
|
||||
@@ -210,13 +212,13 @@ public class BGraphics extends BImage implements BConstants {
|
||||
|
||||
// lines
|
||||
static final int DEFAULT_LINES = 512;
|
||||
BLine line; // used for drawing
|
||||
PLine line; // used for drawing
|
||||
int lines[][] = new int[DEFAULT_LINES][LINE_FIELD_COUNT];
|
||||
int lines_count;
|
||||
|
||||
// triangles
|
||||
static final int DEFAULT_TRIANGLES = 256;
|
||||
BTriangle triangle; // used for rendering
|
||||
PTriangle triangle; // used for rendering
|
||||
int triangles[][] = new int[DEFAULT_TRIANGLES][TRIANGLE_FIELD_COUNT];
|
||||
int triangles_count; // total number of triangles
|
||||
|
||||
@@ -242,9 +244,9 @@ public class BGraphics extends BImage implements BConstants {
|
||||
boolean texture;
|
||||
|
||||
// NEW_GRAPHICS
|
||||
private BImage textureImage;
|
||||
private PImage textureImage;
|
||||
static final int DEFAULT_TEXTURES = 3;
|
||||
BImage textures[] = new BImage[DEFAULT_TEXTURES];
|
||||
PImage textures[] = new PImage[DEFAULT_TEXTURES];
|
||||
int texture_index;
|
||||
|
||||
|
||||
@@ -305,7 +307,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
|
||||
int text_mode = ALIGN_LEFT;
|
||||
int text_space = OBJECT_SPACE;
|
||||
BFont text_font;
|
||||
PFont text_font;
|
||||
boolean drawing_text = false;
|
||||
|
||||
|
||||
@@ -315,20 +317,20 @@ public class BGraphics extends BImage implements BConstants {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the BGraphics object.
|
||||
* Constructor for the PGraphics object.
|
||||
* This prototype only exists because of annoying
|
||||
* java compilers, and should not be used.
|
||||
*/
|
||||
public BGraphics() { }
|
||||
public PGraphics() { }
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the BGraphics object
|
||||
* Constructor for the PGraphics object
|
||||
*
|
||||
* @param iwidth viewport width
|
||||
* @param iheight viewport height
|
||||
*/
|
||||
public BGraphics(int iwidth, int iheight) {
|
||||
public PGraphics(int iwidth, int iheight) {
|
||||
resize(iwidth, iheight);
|
||||
|
||||
// init color/stroke/fill
|
||||
@@ -400,12 +402,12 @@ public class BGraphics extends BImage implements BConstants {
|
||||
image = Toolkit.getDefaultToolkit().createImage(mis);
|
||||
|
||||
// use now in the old engine too
|
||||
line = new BLine(this);
|
||||
line = new PLine(this);
|
||||
|
||||
// moved from BGraphics constructor since not needed by opengl
|
||||
// moved from PGraphics constructor since not needed by opengl
|
||||
if (hints[NEW_GRAPHICS]) {
|
||||
//line = new BLine(this);
|
||||
triangle = new BTriangle(this);
|
||||
//line = new PLine(this);
|
||||
triangle = new PTriangle(this);
|
||||
|
||||
/*
|
||||
// these are all done on beginFrame(), so not doing them here [fry]
|
||||
@@ -419,11 +421,11 @@ public class BGraphics extends BImage implements BConstants {
|
||||
vertex_end = 0;
|
||||
|
||||
// init lines
|
||||
line = new BLine(this);
|
||||
line = new PLine(this);
|
||||
lines_count = 0;
|
||||
|
||||
// init triangles
|
||||
triangle = new BTriangle(this);
|
||||
triangle = new PTriangle(this);
|
||||
triangles_count = 0;
|
||||
|
||||
// textures
|
||||
@@ -450,9 +452,9 @@ public class BGraphics extends BImage implements BConstants {
|
||||
shapeKind = 0;
|
||||
|
||||
if (!hints[NEW_GRAPHICS]) {
|
||||
polygon = new BPolygon(this);
|
||||
fpolygon = new BPolygon(this);
|
||||
spolygon = new BPolygon(this);
|
||||
polygon = new PPolygon(this);
|
||||
fpolygon = new PPolygon(this);
|
||||
spolygon = new PPolygon(this);
|
||||
spolygon.vertexCount = 4;
|
||||
svertices = new float[2][];
|
||||
}
|
||||
@@ -506,7 +508,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
* initializes engine before drawing a new frame
|
||||
*/
|
||||
public void beginFrame() {
|
||||
if (BApplet.THREAD_DEBUG) System.out.println(" 1 beginFrame");
|
||||
if (PApplet.THREAD_DEBUG) System.out.println(" 1 beginFrame");
|
||||
/*
|
||||
if (camera_mode == -1) {
|
||||
//System.out.println("setting up camera");
|
||||
@@ -558,7 +560,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
* indicates a completed frame
|
||||
*/
|
||||
public void endFrame() {
|
||||
if (BApplet.THREAD_DEBUG) System.out.println(" 2 endFrame");
|
||||
if (PApplet.THREAD_DEBUG) System.out.println(" 2 endFrame");
|
||||
|
||||
if (hints[NEW_GRAPHICS]) {
|
||||
|
||||
@@ -654,10 +656,10 @@ public class BGraphics extends BImage implements BConstants {
|
||||
}
|
||||
|
||||
|
||||
public final void addTexture(BImage image) {
|
||||
public final void addTexture(PImage image) {
|
||||
|
||||
if (texture_index == textures.length - 1) {
|
||||
BImage temp[] = new BImage[texture_index<<1];
|
||||
PImage temp[] = new PImage[texture_index<<1];
|
||||
System.arraycopy(textures, 0, temp, 0, texture_index);
|
||||
textures = temp;
|
||||
System.out.println("allocating more textures " + textures.length);
|
||||
@@ -977,10 +979,10 @@ public class BGraphics extends BImage implements BConstants {
|
||||
* set texture image for current shape
|
||||
* needs to be called between @see beginShape and @see endShape
|
||||
*
|
||||
* @param image reference to a BImage object
|
||||
* @param image reference to a PImage object
|
||||
*/
|
||||
//public void textureImage(BImage image) {
|
||||
public void texture(BImage image) {
|
||||
//public void textureImage(PImage image) {
|
||||
public void texture(PImage image) {
|
||||
if (hints[NEW_GRAPHICS]) {
|
||||
if (z_order == true) {
|
||||
addTexture(image);
|
||||
@@ -2281,7 +2283,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
if (tpolygon == null) {
|
||||
// allocate on first use, rather than slowing
|
||||
// the startup of the class.
|
||||
tpolygon = new BPolygon(this);
|
||||
tpolygon = new PPolygon(this);
|
||||
tpolygon_vertex_order = new int[TPOLYGON_MAX_VERTICES];
|
||||
}
|
||||
tpolygon.reset(3);
|
||||
@@ -3187,7 +3189,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
* @param sx1 x coordinate of upper-lefthand corner in screen space
|
||||
* @param sy1 y coordinate of upper-lefthand corner in screen space
|
||||
*/
|
||||
public void flat_image(BImage image, int sx1, int sy1) {
|
||||
public void flat_image(PImage image, int sx1, int sy1) {
|
||||
int ix1 = 0;
|
||||
int iy1 = 0;
|
||||
int ix2 = image.width;
|
||||
@@ -4069,7 +4071,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
}
|
||||
}
|
||||
|
||||
public BImage loadImage(String filename) {
|
||||
public PImage loadImage(String filename) {
|
||||
if (filename.toLowerCase().endsWith(".tga")) {
|
||||
return loadTargaImage(filename);
|
||||
}
|
||||
@@ -4077,7 +4079,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
}
|
||||
|
||||
// returns null if no image of that name is found
|
||||
public BImage loadImage(String filename, boolean force) {
|
||||
public PImage loadImage(String filename, boolean force) {
|
||||
Image awtimage = null;
|
||||
//String randomizer = "?" + nf((int) (random()*10000), 4);
|
||||
|
||||
@@ -4165,18 +4167,18 @@ public class BGraphics extends BImage implements BConstants {
|
||||
// since transparency is often at corners, hopefully this
|
||||
// will find a non-transparent pixel quickly and exit
|
||||
if ((jpixels[i] & 0xff000000) != 0xff000000) {
|
||||
return new BImage(jpixels, jwidth, jheight, RGBA);
|
||||
return new PImage(jpixels, jwidth, jheight, RGBA);
|
||||
//format = RGBA;
|
||||
//break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new BImage(jpixels, jwidth, jheight, RGB);
|
||||
return new PImage(jpixels, jwidth, jheight, RGB);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public BImage loadImage(String file) {
|
||||
public PImage loadImage(String file) {
|
||||
try {
|
||||
byte[] imgarray=loadBytes(file);
|
||||
java.awt.Image awtimage =
|
||||
@@ -4201,7 +4203,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
BImage img=new BImage(pix,w,h,RGB);
|
||||
PImage img=new PImage(pix,w,h,RGB);
|
||||
|
||||
if (file.toLowerCase().endsWith(".gif")) {
|
||||
for (int i = 0; i < pix.length; i++) {
|
||||
@@ -4225,7 +4227,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
// [fry] this could be optimized to not use loadBytes
|
||||
// which would help out memory situations with large images
|
||||
|
||||
protected BImage loadTargaImage(String filename) {
|
||||
protected PImage loadTargaImage(String filename) {
|
||||
// load image file as byte array
|
||||
byte[] buffer = loadBytes(filename);
|
||||
|
||||
@@ -4240,7 +4242,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
boolean hasAlpha=(buffer[16] == 32);
|
||||
|
||||
// setup new image object
|
||||
BImage img = new BImage(w,h);
|
||||
PImage img = new PImage(w,h);
|
||||
img.format = (hasAlpha ? RGBA : RGB);
|
||||
|
||||
// targa's are written upside down, so we need to parse it in reverse
|
||||
@@ -4275,7 +4277,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
image_mode = mode;
|
||||
}
|
||||
|
||||
public void image(BImage image, float x1, float y1) {
|
||||
public void image(PImage image, float x1, float y1) {
|
||||
if ((dimensions == 0) && !lighting && !_tint &&
|
||||
(image_mode != CENTER_RADIUS)) {
|
||||
// if drawing a flat image with no warping,
|
||||
@@ -4289,13 +4291,13 @@ public class BGraphics extends BImage implements BConstants {
|
||||
}
|
||||
|
||||
|
||||
public void image(BImage image,
|
||||
public void image(PImage image,
|
||||
float x1, float y1, float x2, float y2) {
|
||||
image(image, x1, y1, x2, y2, 0, 0, image.width, image.height);
|
||||
}
|
||||
|
||||
|
||||
public void image(BImage image,
|
||||
public void image(PImage image,
|
||||
float x1, float y1, float x2, float y2,
|
||||
float u1, float v1, float u2, float v2) {
|
||||
switch (image_mode) {
|
||||
@@ -4361,13 +4363,13 @@ public class BGraphics extends BImage implements BConstants {
|
||||
}
|
||||
|
||||
|
||||
public void cache(BImage image) {
|
||||
public void cache(PImage image) {
|
||||
}
|
||||
|
||||
public void cache(BImage images[]) {
|
||||
public void cache(PImage images[]) {
|
||||
}
|
||||
|
||||
protected void cache(BImage image, int index) {
|
||||
protected void cache(PImage image, int index) {
|
||||
}
|
||||
|
||||
|
||||
@@ -4376,9 +4378,9 @@ public class BGraphics extends BImage implements BConstants {
|
||||
// TEXT/FONTS
|
||||
|
||||
|
||||
public BFont loadFont(String name) {
|
||||
public PFont loadFont(String name) {
|
||||
try {
|
||||
BFont font = new BFont(name, this);
|
||||
PFont font = new PFont(name, this);
|
||||
return font;
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -4391,7 +4393,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
}
|
||||
|
||||
|
||||
public void textFont(BFont which) {
|
||||
public void textFont(PFont which) {
|
||||
if (which == null) {
|
||||
System.err.println("Ignoring improperly loaded font in textFont()");
|
||||
return;
|
||||
@@ -4405,7 +4407,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
text_font.leading();
|
||||
}
|
||||
|
||||
public void textFont(BFont which, float size) {
|
||||
public void textFont(PFont which, float size) {
|
||||
if (which == null) {
|
||||
System.err.println("Ignoring improperly loaded font in textFont()");
|
||||
return;
|
||||
@@ -4502,7 +4504,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
|
||||
|
||||
public void text(float num, float x, float y) {
|
||||
text(BApplet.nfs(num, 0, 3), x, y, 0);
|
||||
text(PApplet.nfs(num, 0, 3), x, y, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4511,7 +4513,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
* Users who want more control should use their own nfs() cmmand.
|
||||
*/
|
||||
public void text(float num, float x, float y, float z) {
|
||||
text(BApplet.nfs(num, 0, 3), x, y, z);
|
||||
text(PApplet.nfs(num, 0, 3), x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -4606,19 +4608,19 @@ public class BGraphics extends BImage implements BConstants {
|
||||
int d = 1;
|
||||
while ((big /= 10) != 0) d++;
|
||||
|
||||
BApplet.println(BApplet.nfs(m00, d, 4) + " " + BApplet.nfs(m01, d, 4) + " " +
|
||||
BApplet.nfs(m02, d, 4) + " " + BApplet.nfs(m03, d, 4));
|
||||
PApplet.println(PApplet.nfs(m00, d, 4) + " " + PApplet.nfs(m01, d, 4) + " " +
|
||||
PApplet.nfs(m02, d, 4) + " " + PApplet.nfs(m03, d, 4));
|
||||
|
||||
BApplet.println(BApplet.nfs(m10, d, 4) + " " + BApplet.nfs(m11, d, 4) + " " +
|
||||
BApplet.nfs(m12, d, 4) + " " + BApplet.nfs(m13, d, 4));
|
||||
PApplet.println(PApplet.nfs(m10, d, 4) + " " + PApplet.nfs(m11, d, 4) + " " +
|
||||
PApplet.nfs(m12, d, 4) + " " + PApplet.nfs(m13, d, 4));
|
||||
|
||||
BApplet.println(BApplet.nfs(m20, d, 4) + " " + BApplet.nfs(m21, d, 4) + " " +
|
||||
BApplet.nfs(m22, d, 4) + " " + BApplet.nfs(m23, d, 4));
|
||||
PApplet.println(PApplet.nfs(m20, d, 4) + " " + PApplet.nfs(m21, d, 4) + " " +
|
||||
PApplet.nfs(m22, d, 4) + " " + PApplet.nfs(m23, d, 4));
|
||||
|
||||
BApplet.println(BApplet.nfs(m30, d, 4) + " " + BApplet.nfs(m31, d, 4) + " " +
|
||||
BApplet.nfs(m32, d, 4) + " " + BApplet.nfs(m33, d, 4));
|
||||
PApplet.println(PApplet.nfs(m30, d, 4) + " " + PApplet.nfs(m31, d, 4) + " " +
|
||||
PApplet.nfs(m32, d, 4) + " " + PApplet.nfs(m33, d, 4));
|
||||
|
||||
BApplet.println();
|
||||
PApplet.println();
|
||||
}
|
||||
|
||||
|
||||
@@ -4662,19 +4664,19 @@ public class BGraphics extends BImage implements BConstants {
|
||||
int d = 1;
|
||||
while ((big /= 10) != 0) d++;
|
||||
|
||||
BApplet.println(BApplet.nfs(p00, d, 4) + " " + BApplet.nfs(p01, d, 4) + " " +
|
||||
BApplet.nfs(p02, d, 4) + " " + BApplet.nfs(p03, d, 4));
|
||||
PApplet.println(PApplet.nfs(p00, d, 4) + " " + PApplet.nfs(p01, d, 4) + " " +
|
||||
PApplet.nfs(p02, d, 4) + " " + PApplet.nfs(p03, d, 4));
|
||||
|
||||
BApplet.println(BApplet.nfs(p10, d, 4) + " " + BApplet.nfs(p11, d, 4) + " " +
|
||||
BApplet.nfs(p12, d, 4) + " " + BApplet.nfs(p13, d, 4));
|
||||
PApplet.println(PApplet.nfs(p10, d, 4) + " " + PApplet.nfs(p11, d, 4) + " " +
|
||||
PApplet.nfs(p12, d, 4) + " " + PApplet.nfs(p13, d, 4));
|
||||
|
||||
BApplet.println(BApplet.nfs(p20, d, 4) + " " + BApplet.nfs(p21, d, 4) + " " +
|
||||
BApplet.nfs(p22, d, 4) + " " + BApplet.nfs(p23, d, 4));
|
||||
PApplet.println(PApplet.nfs(p20, d, 4) + " " + PApplet.nfs(p21, d, 4) + " " +
|
||||
PApplet.nfs(p22, d, 4) + " " + PApplet.nfs(p23, d, 4));
|
||||
|
||||
BApplet.println(BApplet.nfs(p30, d, 4) + " " + BApplet.nfs(p31, d, 4) + " " +
|
||||
BApplet.nfs(p32, d, 4) + " " + BApplet.nfs(p33, d, 4));
|
||||
PApplet.println(PApplet.nfs(p30, d, 4) + " " + PApplet.nfs(p31, d, 4) + " " +
|
||||
PApplet.nfs(p32, d, 4) + " " + PApplet.nfs(p33, d, 4));
|
||||
|
||||
BApplet.println();
|
||||
PApplet.println();
|
||||
}
|
||||
|
||||
|
||||
@@ -5375,7 +5377,7 @@ public class BGraphics extends BImage implements BConstants {
|
||||
}
|
||||
|
||||
|
||||
public void background(BImage image) {
|
||||
public void background(PImage image) {
|
||||
if ((image.width != width) || (image.height != height)) {
|
||||
System.err.println("background image must be the same size " +
|
||||
"as your application");
|
||||
@@ -5969,10 +5971,10 @@ public class BGraphics extends BImage implements BConstants {
|
||||
// MATH
|
||||
|
||||
// these are *only* the functions used internally
|
||||
// the real math functions are inside BApplet
|
||||
// the real math functions are inside PApplet
|
||||
|
||||
// these have been made private so as not to conflict
|
||||
// with the versions found in BApplet when fxn importing happens
|
||||
// with the versions found in PApplet when fxn importing happens
|
||||
// also might be faster that way. hmm.
|
||||
|
||||
|
||||
|
||||
+45
-44
@@ -1,7 +1,7 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
BImage - storage class for pixel data
|
||||
PImage - storage class for pixel data
|
||||
Part of the Processing project - http://Proce55ing.net
|
||||
|
||||
Copyright (c) 2001-03
|
||||
@@ -24,6 +24,8 @@
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.core;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.*;
|
||||
@@ -56,9 +58,9 @@ import java.io.*;
|
||||
* image object as parameter. this is to provide an easy syntax for cases
|
||||
* where the main pixel buffer is the destination. as those methods are
|
||||
* overloaded in BApplet, users can call those functions directly without
|
||||
* explicitly giving a reference to BGraphics.
|
||||
* explicitly giving a reference to PGraphics.
|
||||
*/
|
||||
public class BImage implements BConstants, Cloneable {
|
||||
public class PImage implements PConstants, Cloneable {
|
||||
|
||||
// note that RGB images still require 0xff in the high byte
|
||||
// because of how they'll be manipulated by other functions
|
||||
@@ -66,20 +68,15 @@ public class BImage implements BConstants, Cloneable {
|
||||
|
||||
int pixels[];
|
||||
int width, height;
|
||||
// maybe also scan line, etc?
|
||||
// would scan line be useful? maybe for pow of 2 gl textures
|
||||
|
||||
// note! inherited by BGraphics
|
||||
// note! inherited by PGraphics
|
||||
boolean smooth = false; //true; // for now.. how to fix?
|
||||
|
||||
// for gl subclass / hardware accel
|
||||
int cacheIndex;
|
||||
|
||||
// blend mode used for copy et al.
|
||||
//int blend_mode = REPLACE;
|
||||
|
||||
|
||||
// private fields
|
||||
|
||||
private int fracU, ifU, fracV, ifV, u1, u2, v1, v2, sX, sY, iw, iw1, ih1;
|
||||
private int ul, ll, ur, lr, cUL, cLL, cUR, cLR;
|
||||
private int srcXOffset, srcYOffset;
|
||||
@@ -97,7 +94,7 @@ public class BImage implements BConstants, Cloneable {
|
||||
/**
|
||||
* Constructor required by java compiler for subclasses.
|
||||
*/
|
||||
public BImage() { }
|
||||
public PImage() { }
|
||||
|
||||
|
||||
/**
|
||||
@@ -105,7 +102,7 @@ public class BImage implements BConstants, Cloneable {
|
||||
* All pixels are set to zero, meaning black, but since the
|
||||
* alpha is zero, it will be transparent.
|
||||
*/
|
||||
public BImage(int width, int height) {
|
||||
public PImage(int width, int height) {
|
||||
this(new int[width * height], width, height, RGBA);
|
||||
// toxi: is it maybe better to init the image with max alpha enabled?
|
||||
//for(int i=0; i<pixels.length; i++) pixels[i]=0xffffffff;
|
||||
@@ -118,7 +115,7 @@ public class BImage implements BConstants, Cloneable {
|
||||
}
|
||||
|
||||
|
||||
public BImage(int pixels[], int width, int height, int format) {
|
||||
public PImage(int pixels[], int width, int height, int format) {
|
||||
this.pixels = pixels;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
@@ -128,13 +125,13 @@ public class BImage implements BConstants, Cloneable {
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new BImage from a java.awt.Image
|
||||
* Construct a new PImage from a java.awt.Image
|
||||
*
|
||||
* this constructor assumes that you've done the work of
|
||||
* making sure a MediaTracker has been used to fully
|
||||
* download the data and that the img is valid.
|
||||
*/
|
||||
public BImage(java.awt.Image img) {
|
||||
public PImage(java.awt.Image img) {
|
||||
width = img.getWidth(null);
|
||||
height = img.getHeight(null);
|
||||
|
||||
@@ -180,7 +177,7 @@ public class BImage implements BConstants, Cloneable {
|
||||
/**
|
||||
* Set alpha channel for an image using another image as the source.
|
||||
*/
|
||||
public void alpha(BImage alpha) {
|
||||
public void alpha(PImage alpha) {
|
||||
alpha(alpha.pixels);
|
||||
}
|
||||
|
||||
@@ -197,20 +194,24 @@ public class BImage implements BConstants, Cloneable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// [toxi040115] converts RGB image data into grayscale using weighted RGB components
|
||||
// keeps alpha channel intact
|
||||
public void toGrayscale() {
|
||||
int col,lum,i;
|
||||
for(i=0; i<pixels.length; i++) {
|
||||
col=pixels[i];
|
||||
// luminance = 0.3*red + 0.59*green + 0.11*blue
|
||||
// 0.3*256 = 77
|
||||
// 0.59*256 = 151
|
||||
// 0.11*256 = 28
|
||||
lum = ( 77*(col>>16&0xff) + 151*(col>>8&0xff) + 28*(col&0xff) )>>8;
|
||||
pixels[i] = (col & ALPHA_MASK) | lum<<16 | lum<<8 | lum;
|
||||
}
|
||||
/**
|
||||
* [toxi040115]
|
||||
* Converts RGB image data into grayscale using
|
||||
* weighted RGB components, and keeps alpha channel intact.
|
||||
*/
|
||||
public void toGrayscale() {
|
||||
for (int i = 0; i<pixels.length; i++) {
|
||||
int col = pixels[i];
|
||||
// luminance = 0.3*red + 0.59*green + 0.11*blue
|
||||
// 0.3*256 = 77
|
||||
// 0.59*256 = 151
|
||||
// 0.11*256 = 28
|
||||
int lum = (77*(col>>16&0xff) + 151*(col>>8&0xff) + 28*(col&0xff))>>8;
|
||||
pixels[i] = (col & ALPHA_MASK) | lum<<16 | lum<<8 | lum;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -223,14 +224,14 @@ public class BImage implements BConstants, Cloneable {
|
||||
}
|
||||
|
||||
|
||||
public BImage get(int x, int y, int w, int h) {
|
||||
public PImage get(int x, int y, int w, int h) {
|
||||
if (x < 0) x = 0;
|
||||
if (y < 0) y = 0;
|
||||
|
||||
if (x + w > width) w = width - x;
|
||||
if (y + h > height) h = height - y;
|
||||
|
||||
BImage newbie = new BImage(new int[w*h], w, h, format);
|
||||
PImage newbie = new PImage(new int[w*h], w, h, format);
|
||||
|
||||
int index = y*width + x;
|
||||
int index2 = 0;
|
||||
@@ -258,7 +259,7 @@ public class BImage implements BConstants, Cloneable {
|
||||
|
||||
// not all variables here are needed.. fix it up later
|
||||
|
||||
public void set(int x, int y, BImage image) {
|
||||
public void set(int x, int y, PImage image) {
|
||||
// source
|
||||
int sx = 0;
|
||||
int sy = 0;
|
||||
@@ -325,7 +326,7 @@ public class BImage implements BConstants, Cloneable {
|
||||
// this function is excluded from using any blend modes
|
||||
// it always replaces/overwrites the target pixel value
|
||||
|
||||
public void copy(BImage src, int sx, int sy, int dx, int dy) {
|
||||
public void copy(PImage src, int sx, int sy, int dx, int dy) {
|
||||
if ((dx >= 0) && (dx < width) && (sx >= 0) && (sx < src.width) &&
|
||||
(dy >= 0) && (dy < height) && (sy >= 0) && (sy < src.height)) {
|
||||
pixels[dy * width + dx] = src.pixels[sy * src.width + sx];
|
||||
@@ -350,9 +351,9 @@ public class BImage implements BConstants, Cloneable {
|
||||
|
||||
|
||||
/**
|
||||
* Copies area of one image into another BImage object
|
||||
* Copies area of one image into another PImage object
|
||||
*/
|
||||
public void copy(BImage src, int sx1, int sy1, int sx2, int sy2,
|
||||
public void copy(PImage src, int sx1, int sy1, int sx2, int sy2,
|
||||
int dx1, int dy1, int dx2, int dy2) {
|
||||
blit_resize(src, sx1, sy1, sx2, sy2,
|
||||
pixels, width, height, dx1, dy1, dx2, dy2, REPLACE);
|
||||
@@ -362,7 +363,7 @@ public class BImage implements BConstants, Cloneable {
|
||||
/**
|
||||
* Copies and blends 1 pixel with MODE to pixel in another image
|
||||
*/
|
||||
public void blend(BImage src, int sx, int sy, int dx, int dy, int mode) {
|
||||
public void blend(PImage src, int sx, int sy, int dx, int dy, int mode) {
|
||||
if ((dx >= 0) && (dx < width) && (sx >= 0) && (sx < src.width) &&
|
||||
(dy >= 0) && (dy < height) && (sy >= 0) && (sy < src.height)) {
|
||||
pixels[dy * width + dx] =
|
||||
@@ -395,9 +396,9 @@ public class BImage implements BConstants, Cloneable {
|
||||
|
||||
|
||||
/**
|
||||
* Copies area of one image into another BImage object
|
||||
* Copies area of one image into another PImage object
|
||||
*/
|
||||
public void blend(BImage src, int sx1, int sy1, int sx2, int sy2,
|
||||
public void blend(PImage src, int sx1, int sy1, int sx2, int sy2,
|
||||
int dx1, int dy1, int dx2, int dy2, int mode) {
|
||||
blit_resize(src, sx1, sy1, sx2, sy2,
|
||||
pixels, width, height, dx1, dy1, dx2, dy2, mode);
|
||||
@@ -410,7 +411,7 @@ public class BImage implements BConstants, Cloneable {
|
||||
// COPYING IMAGE DATA
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
BImage c = (BImage) super.clone();
|
||||
PImage c = (PImage) super.clone();
|
||||
|
||||
// super.clone() will only copy the reference to the pixels
|
||||
// array, so this will do a proper duplication of it instead.
|
||||
@@ -426,8 +427,8 @@ public class BImage implements BConstants, Cloneable {
|
||||
* Duplicate an image, returns new object
|
||||
*/
|
||||
/*
|
||||
public BImage duplicate() {
|
||||
BImage c = new BImage(new int[pixels.length], width, height, format);
|
||||
public PImage duplicate() {
|
||||
PImage c = new PImage(new int[pixels.length], width, height, format);
|
||||
System.arraycopy(pixels, 0, c.pixels, 0, pixels.length);
|
||||
return c;
|
||||
}
|
||||
@@ -437,8 +438,8 @@ public class BImage implements BConstants, Cloneable {
|
||||
* Duplicate and resize image
|
||||
*/
|
||||
/*
|
||||
public BImage duplicate(int newWidth, int newHeight) {
|
||||
BImage dupe = new BImage(new int[newWidth * newHeight],
|
||||
public PImage duplicate(int newWidth, int newHeight) {
|
||||
PImage dupe = new PImage(new int[newWidth * newHeight],
|
||||
newWidth, newHeight, format);
|
||||
|
||||
dupe.copy(this, 0, 0, width - 1, height - 1,
|
||||
@@ -491,7 +492,7 @@ public class BImage implements BConstants, Cloneable {
|
||||
// uses bilinear filtering if smooth() has been enabled
|
||||
// 'mode' determines the blending mode used in the process
|
||||
|
||||
private void blit_resize(BImage img,
|
||||
private void blit_resize(PImage img,
|
||||
int srcX1, int srcY1, int srcX2, int srcY2,
|
||||
int[] destPixels, int screenW, int screenH,
|
||||
int destX1, int destY1, int destX2, int destY2,
|
||||
|
||||
+6
-3
@@ -1,7 +1,7 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
BLibrary - interface for classes that plug into bagel
|
||||
PLibrary - interface for classes that plug into bagel
|
||||
Part of the Processing project - http://Proce55ing.net
|
||||
|
||||
Copyright (c) 2001-03
|
||||
@@ -25,7 +25,10 @@
|
||||
*/
|
||||
|
||||
|
||||
public interface BLibrary {
|
||||
package processing.core;
|
||||
|
||||
|
||||
public interface PLibrary {
|
||||
|
||||
// called when the applet is stopped
|
||||
public void stop();
|
||||
@@ -34,7 +37,7 @@ public interface BLibrary {
|
||||
|
||||
|
||||
/*
|
||||
public void libraryEvent(BLibrary who, Object data) {
|
||||
public void libraryEvent(PLibrary who, Object data) {
|
||||
//if (who instanceof BVideo) {
|
||||
if (who.signature() == Sonia.SIGNATURE) {
|
||||
BImage frame = (BImage)data;
|
||||
|
||||
+7
-6
@@ -1,8 +1,8 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
BFont - font object for text rendering
|
||||
Part of the Processing project - http://Proce55ing.net
|
||||
PLine - code for rendering lines
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2001-03
|
||||
Ben Fry, Massachusetts Institute of Technology and
|
||||
@@ -24,8 +24,9 @@
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.core;
|
||||
|
||||
public class BLine implements BConstants
|
||||
public class PLine implements PConstants
|
||||
{
|
||||
|
||||
private int[] m_pixels;
|
||||
@@ -97,10 +98,10 @@ public class BLine implements BConstants
|
||||
//int x[] = new int[2];
|
||||
//int y[] = new int[2];
|
||||
|
||||
private BGraphics parent;
|
||||
private PGraphics parent;
|
||||
|
||||
|
||||
public BLine(BGraphics g)
|
||||
public PLine(PGraphics g)
|
||||
{
|
||||
//SCREEN_WIDTH = g.width;
|
||||
//SCREEN_HEIGHT = g.height;
|
||||
@@ -126,7 +127,7 @@ public class BLine implements BConstants
|
||||
|
||||
public void reset()
|
||||
{
|
||||
// reset these in case BGraphics was resized
|
||||
// reset these in case PGraphics was resized
|
||||
|
||||
SCREEN_WIDTH = parent.width;
|
||||
SCREEN_HEIGHT = parent.height;
|
||||
|
||||
+8
-6
@@ -1,7 +1,7 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
BPolygon - zbuffer polygon rendering object for BGraphics
|
||||
PPolygon - zbuffer polygon rendering object for BGraphics
|
||||
Part of the Processing project - http://Proce55ing.net
|
||||
|
||||
Copyright (c) 2001-03
|
||||
@@ -24,8 +24,10 @@
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.core;
|
||||
|
||||
public class BPolygon implements BConstants {
|
||||
|
||||
public class PPolygon implements PConstants {
|
||||
static final int DEFAULT_SIZE = 64; // this is needed for spheres
|
||||
float vertices[][] = new float[DEFAULT_SIZE][VERTEX_FIELD_COUNT];
|
||||
int vertexCount;
|
||||
@@ -55,7 +57,7 @@ public class BPolygon implements BConstants {
|
||||
float zbuffer[];
|
||||
boolean noDepthTest;
|
||||
|
||||
BGraphics parent;
|
||||
PGraphics parent;
|
||||
int pixels[];
|
||||
|
||||
// the parent's width/height,
|
||||
@@ -64,7 +66,7 @@ public class BPolygon implements BConstants {
|
||||
int width, height;
|
||||
int width1, height1;
|
||||
|
||||
BImage timage;
|
||||
PImage timage;
|
||||
int tpixels[];
|
||||
int theight, twidth;
|
||||
int theight1, twidth1;
|
||||
@@ -95,7 +97,7 @@ public class BPolygon implements BConstants {
|
||||
}
|
||||
|
||||
|
||||
public BPolygon(BGraphics iparent) {
|
||||
public PPolygon(PGraphics iparent) {
|
||||
parent = iparent;
|
||||
reset(0);
|
||||
}
|
||||
@@ -130,7 +132,7 @@ public class BPolygon implements BConstants {
|
||||
}
|
||||
|
||||
|
||||
public void texture(BImage image) {
|
||||
public void texture(PImage image) {
|
||||
this.timage = image;
|
||||
this.tpixels = image.pixels;
|
||||
this.twidth = image.width;
|
||||
|
||||
+13
-10
@@ -1,8 +1,8 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
BFont - font object for text rendering
|
||||
Part of the Processing project - http://Proce55ing.net
|
||||
PTriangle - handler for tesselated triangle rendering
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2001-03
|
||||
Ben Fry, Massachusetts Institute of Technology and
|
||||
@@ -24,9 +24,12 @@
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// written by sami www.sumea.com
|
||||
package processing.core;
|
||||
|
||||
public class BTriangle implements BConstants
|
||||
/**
|
||||
* written by sami www.sumea.com
|
||||
*/
|
||||
public class PTriangle implements PConstants
|
||||
{
|
||||
static final int R_GOURAUD = 0x1;
|
||||
static final int R_TEXTURE8 = 0x2;
|
||||
@@ -41,7 +44,7 @@ public class BTriangle implements BConstants
|
||||
private float[] m_zbuffer;
|
||||
|
||||
// texture image
|
||||
private BImage m_tImage;
|
||||
private PImage m_tImage;
|
||||
|
||||
//
|
||||
private int SCREEN_WIDTH;
|
||||
@@ -182,7 +185,7 @@ public class BTriangle implements BConstants
|
||||
private int m_index;
|
||||
|
||||
/** */
|
||||
private BGraphics parent;
|
||||
private PGraphics parent;
|
||||
|
||||
/** */
|
||||
private boolean m_culling;
|
||||
@@ -193,7 +196,7 @@ public class BTriangle implements BConstants
|
||||
/** */
|
||||
private boolean m_bilinear;
|
||||
|
||||
public BTriangle(BGraphics g) {
|
||||
public PTriangle(PGraphics g) {
|
||||
//SCREEN_WIDTH = g.width;
|
||||
//SCREEN_HEIGHT = g.height;
|
||||
//SCREEN_WIDTH1 = SCREEN_WIDTH-1;
|
||||
@@ -221,7 +224,7 @@ public class BTriangle implements BConstants
|
||||
* Resets polygon attributes
|
||||
*/
|
||||
public void reset() {
|
||||
// reset these in case BGraphics was resized
|
||||
// reset these in case PGraphics was resized
|
||||
|
||||
SCREEN_WIDTH = parent.width;
|
||||
SCREEN_HEIGHT = parent.height;
|
||||
@@ -338,7 +341,7 @@ public class BTriangle implements BConstants
|
||||
/**
|
||||
* Sets texture image used for the polygon
|
||||
*/
|
||||
public void setTexture(BImage image) {
|
||||
public void setTexture(PImage image) {
|
||||
m_tImage = image;
|
||||
m_texture = image.pixels;
|
||||
TEX_WIDTH = image.width;
|
||||
@@ -394,7 +397,7 @@ public class BTriangle implements BConstants
|
||||
* Renders the polygon
|
||||
*/
|
||||
public void render() {
|
||||
// removed. done in BGraphics [rocha]
|
||||
// removed. done in PGraphics [rocha]
|
||||
// increase polygon offset
|
||||
//m_index = (m_index + 1) & 0xFFFFFFF;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user