From 60c5e2cd4978e862e8b60dd69e4ed9b4ce1814bd Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 17 Jul 2004 19:54:36 +0000 Subject: [PATCH] get() for image dupe instead of copy().. also hex/binary unhex/unbinary --- app/PdeEditor.java | 8 ++--- core/PApplet.java | 73 ++++++++++++++++++++++++++++++++++++++++++++-- core/PImage.java | 5 ++-- core/PMethods.java | 2 +- core/todo.txt | 30 ++++++++++++------- future.txt | 2 ++ todo.txt | 33 ++++++++++----------- 7 files changed, 115 insertions(+), 38 deletions(-) diff --git a/app/PdeEditor.java b/app/PdeEditor.java index 6d488743f..b38655162 100644 --- a/app/PdeEditor.java +++ b/app/PdeEditor.java @@ -73,11 +73,11 @@ implements MRJAboutHandler, MRJQuitHandler, MRJPrefsHandler JSplitPane splitPane; JPanel consolePanel; - JEditTextArea textarea; - PdeEditorListener listener; - // currently opened program - PdeSketch sketch; + public PdeSketch sketch; + + public JEditTextArea textarea; + PdeEditorListener listener; // runtime information and window placement Point appletLocation; diff --git a/core/PApplet.java b/core/PApplet.java index dd653f400..3116815bf 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -3212,6 +3212,75 @@ public class PApplet extends Applet + ////////////////////////////////////////////////////////////// + + // HEX/BINARY CONVERSION + + + static final public String hex(byte what) { + return hex(what, 2); + } + + static final public String hex(char what) { + return hex(what, 4); + } + + static final public String hex(int what) { + return hex(what, 8); + } + + static final public String hex(int what, int digits) { + String stuff = Integer.toHexString(what).toUpperCase(); + + int length = stuff.length(); + if (length > digits) { + return stuff.substring(length - digits); + + } else if (length < digits) { + return "00000000".substring(8 - (digits-length)) + stuff; + } + return stuff; + } + + static final int unhex(String what) { + return Integer.parseInt(what, 16); + } + + // + + static final public String binary(byte what) { + return binary(what, 8); + } + + static final public String binary(char what) { + return binary(what, 16); + } + + static final public String binary(int what) { + return binary(what, 32); + } + + static final public String binary(int what, int digits) { + String stuff = Integer.toBinaryString(what); + + int length = stuff.length(); + if (length > digits) { + return stuff.substring(length - digits); + + } else if (length < digits) { + int offset = 8 - (digits-length); + return "00000000000000000000000000000000".substring(offset) + stuff; + } + return stuff; + } + + + static final int unbinary(String what) { + return Integer.parseInt(what, 2); + } + + + ////////////////////////////////////////////////////////////// // COLOR FUNCTIONS @@ -3573,8 +3642,8 @@ public class PApplet extends Applet } - public PImage copy() { - return g.copy(); + public PImage get() { + return g.get(); } diff --git a/core/PImage.java b/core/PImage.java index da9ccb6c3..11172e16f 100644 --- a/core/PImage.java +++ b/core/PImage.java @@ -552,9 +552,10 @@ public class PImage implements PConstants, Cloneable { /** - * Convenience method to avoid an extra cast. + * Convenience method to avoid an extra cast, + * and the exception handling. */ - public PImage copy() { + public PImage get() { try { return (PImage) clone(); } catch (CloneNotSupportedException e) { diff --git a/core/PMethods.java b/core/PMethods.java index 9bd7e0f4a..638c18e9f 100755 --- a/core/PMethods.java +++ b/core/PMethods.java @@ -38,7 +38,7 @@ public interface PMethods { public void blend(PImage src, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode); - public PImage copy(); + public PImage get(); public void save(String filename); diff --git a/core/todo.txt b/core/todo.txt index 1ca6bb45a..f90f689cd 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -117,18 +117,18 @@ X use it to repair saveBytes, saveStrings, etc X put screenshots into their sketch folder o http://processing.org/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1046185738;start=0 X full casting operations on primitives and arrays of them +X text(String text, x, y, width, height) // based on rectMode +X textMode() for align left, center, right (no justify.. har!) +X hex(), binary(), unhex(), unbinary() -_ array utiles on Object[] are worthless.. fix it with reflection? -_ also, should it be named resize() instead? -_ see if reflection will allow expand for all class types - -megabucket -_ move to new graphics engine -_ test with rgb cube, shut off smoothing -_ make sure line artifacts are because of smoothing -_ explicitly state depth()/nodepth() -_ implement 2x oversampling for anti-aliasing +_ processing.net -> PClient, PServer +_ api for file-based renderers +_ need to work this out since it will affect other api changes +_ size(0, 0) and then ai.size(10000, 20000) +_ saveFrame(PRenderer) or saveFrame("name", PRenderer) +_ saveFrame gets called at the beginning of loop() +_ or is just a message to save the next frame (problem for anim) _ illustrator export / rendering mode _ also postscript or pdf export? _ version of Illustrator.java that uses core api @@ -142,6 +142,13 @@ _ colorMode(CMYK) _ just does 1-r/1-g/1-b inside _ http://processing.org/discourse/yabb/YaBB.cgi?board=Tools;action=display;num=1082055374;start=0 +_ massive graphics engine changes +_ explicitly state depth()/nodepth() +_ move to new graphics engine +_ test with rgb cube, shut off smoothing +_ make sure line artifacts are because of smoothing +_ implement 2x oversampling for anti-aliasing + ............................................................ @@ -206,7 +213,6 @@ CORE / PImage 1 _ loadImage must be used inside or after setup 1 _ either document this and/or provide a better error message 1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1060879468;start=0 - b _ more blend() modes (the five listed on the thread below?) b _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1082056702 b _ figure out what the modes should actually be: @@ -351,6 +357,8 @@ CORE / Details 1 _ catch security exceptions around applet i/o calls 1 _ not just for saving files, but provide better error msgs when 1 _ attempting to download from another server + 1 _ array utilities on Object[] are worthless.. fix it with reflection? + 1 _ see if reflection will allow expand for all class types CORE / main() diff --git a/future.txt b/future.txt index 55aef916f..1cfed9de1 100644 --- a/future.txt +++ b/future.txt @@ -48,6 +48,8 @@ BAGEL / Future PDE / see you next year not necessary for 1.0 release +2 _ better api for plugins +2 _ jedit guide might be useful: http://plugins.jedit.org/building.php 2 _ comments -> embedding in applet text? (ala javadoc) 2 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1076967353 2 _ would this help casey with the examples? diff --git a/todo.txt b/todo.txt index d05dce9fc..90c613c22 100644 --- a/todo.txt +++ b/todo.txt @@ -26,16 +26,21 @@ X i.e. cut -> new file -> paste doesn't mark any as changed X "include all chars" and all the bugs it represents X working on datatype conversions +040717 +o dll and jnilib files have to be in the p5 folder (confirmed by amit) +o there should be other places that they work.. +o could even copy the dll to the p5 folder from the code folder +o already fixed with LD_LIBRARY_PATH stuff + + _ System.out isn't being heard from P* classes _ errors inside those classes also causing weirdness +_ this might be a broader running as external app problem -_ processing.net -> PClient, PServer - +_ add preference for showing library stuff +_ make built-in libraries read-only _ "add library" menu item and submenu -_ iterate through the 'library' folders -_ dll and jnilib files have to be in the p5 folder (confirmed by amit) -_ there should be other places that they work.. -_ could even copy the dll to the p5 folder from the code folder +_ looks for subfolder called 'library' inside sketches _ libraries: static and non-static init for libs _ final stop() for static shutdown of lib _ but also potential stop() for individual items @@ -45,8 +50,8 @@ _ where do libraries for distribution go? _ libraries subfolder of p5? or inside examples? _ String in apache classes and java.lang _ maybe ignore classes not inside the p5 libs dir? -_ need to be able to select between which to include -_ auto-resolve by saying java.* wins, others ask +o need to be able to select between which to include +o auto-resolve by saying java.* wins, others ask _ get export working again _ make multiple jar files thing work.. blech @@ -77,14 +82,6 @@ _ can java get the root directory for system/win32 etc? _ processing.app -> PdeBase, PdeEditor.. -_ api for file-based renderers -_ need to work this out since it will affect other api changes -_ size(0, 0) and then ai.size(10000, 20000) -_ saveFrame(PRenderer) or saveFrame("name", PRenderer) - -_ text(String text, x, y, width, height) // based on rectMode -_ textMode() for align left, center, right (no justify.. har!) - _ implement new version of history _ make history folder, and a zip (not gz) file for each entry _ history causing trouble - super slow with a huge sketch @@ -109,7 +106,7 @@ README _ cut out some of the chatter _ processing won't start.. _ people with non-ascii chars in the folder name -_ at least try to catch this? +_ at least try to catch this? is that possible? _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1062794781;start=0 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067764732 _ or with spaces in the folder name, causes problems for serial @@ -518,4 +515,4 @@ _ that knows about aliases (jdk13) _ overall contrast/color control (genomevalence for hulk) _ mac -> vlw (or sbit?) font converter _ need to also read the fond for metrics -_ general font editor, see what chars are in font, etc \ No newline at end of file +_ general bitmap font editor, see what chars are in font, etc