From 4da92a70d30ff410e95c88e613375defee86eeae Mon Sep 17 00:00:00 2001 From: benfry Date: Thu, 15 Jul 2004 13:40:28 +0000 Subject: [PATCH] focus code, and color(gray) / color(gray/alpha) --- processing/core/PApplet.java | 59 +++++++++++++++++++++++++++++++++- processing/core/PGraphics.java | 28 ++++++++++++++++ processing/core/todo.txt | 29 +++++++++++++---- processing/todo.txt | 28 ++++++++++++++++ 4 files changed, 137 insertions(+), 7 deletions(-) diff --git a/processing/core/PApplet.java b/processing/core/PApplet.java index d0857fb4b..9a55e8429 100644 --- a/processing/core/PApplet.java +++ b/processing/core/PApplet.java @@ -38,7 +38,7 @@ import java.util.*; public class PApplet extends Applet implements PConstants, Runnable, - MouseListener, MouseMotionListener, KeyListener + MouseListener, MouseMotionListener, KeyListener, FocusListener { static final double jdkVersion = toDouble(System.getProperty("java.version").substring(0,3)); @@ -61,6 +61,17 @@ public class PApplet extends Applet public boolean keyPressed; public KeyEvent keyEvent; + /** + * Gets set to true/false as the applet gains/loses focus. + */ + public boolean focused = false; + + /** + * Is the applet online or not? This can be used to test how the + * applet should behave since online situations are different. + */ + public boolean online = false; + long millisOffset; // getting the frame rate @@ -136,6 +147,7 @@ public class PApplet extends Applet addMouseListener(this); addMouseMotionListener(this); addKeyListener(this); + addFocusListener(this); //timing = true; millisOffset = System.currentTimeMillis(); @@ -175,6 +187,13 @@ public class PApplet extends Applet this.width = g.width; this.height = g.height; g.applet = this; + + try { + getAppletContext(); + online = true; + } catch (NullPointerException e) { + online = false; + } } @@ -551,6 +570,22 @@ public class PApplet extends Applet } + // ------------------------------------------------------------ + + // i am focused man, and i'm not afraid of death. + // and i'm going all out. i circle the vultures in a van + // and i run the block. + + + public void focusGained(FocusEvent e) { + focused = true; + } + + public void focusLost(FocusEvent e) { + focused = false; + } + + // ------------------------------------------------------------ // getting the time @@ -642,6 +677,7 @@ public class PApplet extends Applet * Is the applet online or not? This can be used to test how the * applet should behave since online situations are different. */ + /* public boolean online() { try { getAppletContext(); @@ -650,6 +686,7 @@ public class PApplet extends Applet } return true; } + */ /** @@ -3178,6 +3215,26 @@ public class PApplet extends Applet } + public final int color(int gray) { + return g.color(gray); + } + + + public final int color(float gray) { + return g.color(gray); + } + + + public final int color(int gray, int alpha) { + return g.color(gray, alpha); + } + + + public final int color(float gray, float alpha) { + return g.color(gray, alpha); + } + + public final int color(int x, int y, int z) { return g.color(x, y, z); } diff --git a/processing/core/PGraphics.java b/processing/core/PGraphics.java index 33852e4d9..86f086fc4 100644 --- a/processing/core/PGraphics.java +++ b/processing/core/PGraphics.java @@ -5887,6 +5887,34 @@ public class PGraphics extends PImage implements PConstants { // they can write it themselves (not difficult) + public final int color(int gray) { + if ((color_mode == RGB) && (!color_scale)) { + return 0xff000000 | (gray << 16) | (gray << 8) | gray; + } + calc_color(gray); + return calci; + } + + public final int color(float gray) { + calc_color(gray); + return calci; + } + + + public final int color(int gray, int alpha) { + if ((color_mode == RGB) && (!color_scale)) { + return (gray << 24) | (gray << 16) | (gray << 8) | gray; + } + calc_color(gray, alpha); + return calci; + } + + public final int color(float gray, float alpha) { + calc_color(gray, alpha); + return calci; + } + + public final int color(int x, int y, int z) { if ((color_mode == RGB) && (!color_scale)) { return 0xff000000 | (x << 16) | (y << 8) | z; diff --git a/processing/core/todo.txt b/processing/core/todo.txt index a5ced955a..ba526a82a 100644 --- a/processing/core/todo.txt +++ b/processing/core/todo.txt @@ -61,15 +61,15 @@ X would be good to set a param in p5 so that the thread dies X if people have other threads they've spawned, impossible to stop X include a lerp()? is there one in flash? -_ http://processing.org/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1083289030 -_ should it be called lerp or mix? +X http://processing.org/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1083289030 +X should it be called lerp or mix? X acos, asin, log, exp, ceil/floor, pow, mag(x,y,z) +X add color(gray) and color(gray, alpha) +X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1089898189;start=0 MEGABUCKET (api) - +_ passing in args[] from main _ color issues -_ add color(gray) and color(gray, alpha) -_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1074180764 _ doesn't work when outside a function: _ color bg_color = color(255,0,0); _ colorMode broken for red() green() etc @@ -182,9 +182,11 @@ CORE / PImage CORE / PGraphics b _ lines + b _ z value hack for lines is causing trouble for 2D + b _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1089737928;start=0 b X rewrite line and stroke code, it's a buggy mess b X lines become 2 pixels thick after a 3D transform - b X better handling of single-pixel special se + b X better handling of single-pixel special case b _ flat_line_retribution is a hack, can go away b _ mgorbet stroke transparency problem b _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1076383048;start=0 @@ -214,6 +216,21 @@ CORE / PGraphics 1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1073329613;start=0 1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1080342288;start=0 + b _ super nasty lineweight issue: +void setup() +{ + size(400, 400); +} + +void loop() +{ + stroke(#ff0000); + strokeWeight(2); + line(0, 0, 40, 40); + point(100, 100); + rect(200, 200, 100, 100); +} + 1 _ ellipse problems 1 _ weird ellipse bug with an alpha line in same image 1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1083221401;start=0 diff --git a/processing/todo.txt b/processing/todo.txt index d85027dfb..521216fd4 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -7,6 +7,8 @@ X was this the big one? a big one? 040713 X fixes to line and curve code +_ moving p5 prefs on mac into documents? or inside sketchbook? + _ terrible loadImage bug.. does it affect loadStrings? _ "save as" needs to update the editorheader @@ -469,3 +471,29 @@ _ wrap up oro for simple matching _ (as alternative to the sun classes.. link to those in the docs) _ method for file handling, recursive walk-through a directory _ file i/o: file listing util that leaves out . and .. + +more random thoughts +_ stroke picker +_ just lineweight, so don't bother.. use constants palette instead +_ font picker +_ same thing, just quickly generates fonts on the fly and applies them +_ need to look at matlab's visualization tools +_ arcs, better 'color' object +_ take everything in perl cookbook, and make easy to do with p5 +_ database access and reading large files are always hangups +_ support capabilities of matlab's visualization tools +_ charting/labeling primitives.. excel never quite does it +_ botting engine +_ difficulty of initial grab/analysis of data, that may take some time +_ then needs to be stored and run on multiple times +_ methods for picking colors.. how to color code, limit to 5? gradients.. +_ simple way to do tufte-style small multiples on an app +_ function for reporting percent finished (or swing dialog) +_ also for reporting the amount of time remaining +_ loading/selecting a file (or folder), or from command line +_ load large file as lattice (option of whether to keep in memory) +_ how many rows/columns for headings +_ walking through an entire directory, with a handler +_ that throws out the . and .. items +_ that knows about aliases (jdk13) +_ overall contrast/color control (genomevalence for hulk)