From f4ceff986be1def0049e809f8dc8455a95d6b4cb Mon Sep 17 00:00:00 2001 From: benfry Date: Wed, 3 Oct 2001 22:22:46 +0000 Subject: [PATCH] random functions in processingapplet, notes in todo --- processing/app/ProcessingApplet.java | 65 +++++++++++++++++++--------- processing/todo.txt | 7 +++ 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/processing/app/ProcessingApplet.java b/processing/app/ProcessingApplet.java index b6d9d1432..560f01179 100644 --- a/processing/app/ProcessingApplet.java +++ b/processing/app/ProcessingApplet.java @@ -509,24 +509,11 @@ public class ProcessingApplet extends Applet // math stuff for convenience - - public final float sin(float angle) { - return (float)Math.sin(angle); - } - public final float cos(float angle) { - return (float)Math.cos(angle); + public final float abs(float n) { + return (n < 0) ? -n : n; } - public final float tan(float angle) { - return (float)Math.tan(angle); - } - - public final float atan2(float a, float b) { - return (float)Math.atan2(a, b); - } - - public final float sq(float a) { return a*a; } @@ -539,10 +526,6 @@ public class ProcessingApplet extends Applet return (float)Math.pow(a, b); } - public final float abs(float n) { - return (n < 0) ? -n : n; - } - public final float max(float a, float b) { return Math.max(a, b); @@ -561,8 +544,48 @@ public class ProcessingApplet extends Applet } - public final float random() { - return (float)Math.random(); + + public final float sin(float angle) { + return (float)Math.sin(angle); + } + + public final float cos(float angle) { + return (float)Math.cos(angle); + } + + public final float tan(float angle) { + return (float)Math.tan(angle); + } + + public final float atan2(float a, float b) { + return (float)Math.atan2(a, b); + } + + + //public final float randomf() { + //return ((float)Math.random() - 0.5f)*2.0f; + //} + + //public final float randomuf() { + //return (float)Math.random(); + //} + + public final float random(float howbig) { + return (float)Math.random() * howbig; + } + + public final float random(float howsmall, float howbig) { + float diff = howbig - howsmall; + return howsmall + (float)Math.random() * diff; + } + + public final int random(int howbig) { + return (int) (Math.random() * (double)howbig); + } + + public final int random(int howsmall, int howbig) { + double diff = howbig - howsmall; + return howsmall + (int) (Math.random() * diff); } diff --git a/processing/todo.txt b/processing/todo.txt index 9dbaf9f90..381069feb 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -3,6 +3,13 @@ iprocessing todo list // last updated 28 september 2001 for 0010 +_ make note in documentation about getting access to pixel array +_ check to see if get/set functions in applet actually work +_ fix documentation appropriately +X redone random functions in processing applet +_ update documentation on web page +_ crappy way of determining if inside a class--ignores comments +_ documentation says 'mouseDown' even though it's 'mousePressed' _ option to enable/disable frame on running applets _ compiling .java files leaves the .class files next to the .java _ make sure all the dirs in sketchbook added to classpath on startup