diff --git a/README.md b/README.md index bc50d56..b351f9e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # PThreading -PThreading: A simple multithreaded framework for Processing. +PThreading: A framework for multithreaded drawing in [Processing](https://processing.org/). --- -The framework consists of two classes: `PThread` and `PThreadManager`. Override the `PThread` class with your code and then add instances of your new class to a PThreadManager to run the instances as threads that draw into your Processing sketch in a multithreaded manner. +The framework consists of two classes: `PThread` and `PThreadManager`. Override the `PThread` class with Processing code and then add instances of your new class to a PThreadManager; this will run the instances as threads that draw into your Processing sketch in a multithreaded manner. ## Motivation @@ -15,7 +15,7 @@ Processing does indeed provide a quick and dirty way to implement a simple threa ... leaving *thread()* suitable only for CPU-bound sketches, at best. -In contrast, PThreading provides a way to do multithreaded drawing -- not just calculation -- and does so in an easy-to-use and well-synchronized manner. It exploits the fact that PGraphics objects can be drawn into safely from other threads. +In contrast, PThreading provides a way to do **multithreaded drawing** -- not just calculation -- and does so in an easy-to-use and well-synchronized manner. It exploits the fact that *PGraphics* objects can be drawn into safely from other threads. ## Setup @@ -34,7 +34,7 @@ Download *pthreading.jar* from [releases](https://github.com/micycle1/PThreading ### 1. Extending PThread -Create a new class that extends PThread. You have to override the PThread's *draw()* method; overriding *calc()* is optional. In *draw()*, put Processing drawing code that you wish to be executed as a thread. A very simple example is shown below: +Create a new class that extends PThread. You have to override the PThread's *draw()* method; overriding *calc()* and *setup()* is optional. In *draw()*, put Processing drawing code that you wish to be executed as a thread. A very simple example is shown below: #### PDE Example: @@ -77,8 +77,9 @@ class myThread extends PThread { ``` **Important**: -* Prefix every call to a Processing draw method with g -- for example: *g.rect(10,10,10,10)* (relevant in all environments). -* Prefix every call to a Processing variable with p -- for example: *p.mousePressed* (relevant in non-PDE environments only). +* Prefix every call to a Processing **draw method** with **g** -- for example: *g.rect(10,10,10,10)* (relevant in all environments). +* Prefix every call to a Processing **variable** with **p** -- for example: *p.mousePressed* (relevant in non-PDE environments only). +* By default, *smooth()* is enabled for threads. Put *g.noSmooth();* in the thread consructor to disable anti-aliasing and thereby improve draw FPS. ### 2. Creating a PThreadManager Create a thread manager and add threads to it. A [variety](micycle1.github.io/PThreading/pthreading/PThreadManager.html) of constructors are available. In this example the most simple constructor has been chosen. You can add multiple types of threads to a single thread manager. @@ -104,8 +105,7 @@ Alternatively, you can call `threadManager.bindDraw()` once -- in `setup` for ex --- -That's it: now `a` and `b` will run as threads, drawing into the sketch. See /examples for more sophisticated behaviour. +That's it: now `a` and `b` will run as threads, drawing into the sketch. See the repo [examples](https://github.com/micycle1/PThreading/tree/master/examples) for the framework in action and more sophisticated behaviour. ## Limitations Each thread uses the `Java2D` renderer, since this is the only renderer that allows PGraphics objects to be instantiated and drawn into from other threads. As a consequence you cannot **thread** `OPENGL` drawing, or any 3D draw functions -- note that you can still use the framework with a 3D sketch but any drawing with the PThreads is limited to 2D. -Not all sketches are suitable: diff --git a/docs/allclasses-index.html b/docs/allclasses-index.html index 9a5eefb..5cc7d65 100644 --- a/docs/allclasses-index.html +++ b/docs/allclasses-index.html @@ -2,10 +2,10 @@ - + All Classes - + diff --git a/docs/allpackages-index.html b/docs/allpackages-index.html index e777489..0bab793 100644 --- a/docs/allpackages-index.html +++ b/docs/allpackages-index.html @@ -2,10 +2,10 @@ - + All Packages - + diff --git a/docs/constant-values.html b/docs/constant-values.html index b4a2470..29a38dc 100644 --- a/docs/constant-values.html +++ b/docs/constant-values.html @@ -2,10 +2,10 @@ - + Constant Field Values - + diff --git a/docs/deprecated-list.html b/docs/deprecated-list.html index 206a67d..7382e19 100644 --- a/docs/deprecated-list.html +++ b/docs/deprecated-list.html @@ -2,10 +2,10 @@ - + Deprecated List - + diff --git a/docs/help-doc.html b/docs/help-doc.html index fdbd591..7025014 100644 --- a/docs/help-doc.html +++ b/docs/help-doc.html @@ -2,10 +2,10 @@ - + API Help - + diff --git a/docs/index-files/index-1.html b/docs/index-files/index-1.html index 4404863..940b781 100644 --- a/docs/index-files/index-1.html +++ b/docs/index-files/index-1.html @@ -2,10 +2,10 @@ - + A-Index - + diff --git a/docs/index-files/index-10.html b/docs/index-files/index-10.html index 0b22a25..b8a40e2 100644 --- a/docs/index-files/index-10.html +++ b/docs/index-files/index-10.html @@ -2,10 +2,10 @@ - + S-Index - + @@ -81,6 +81,10 @@

S

+
setup() - Method in class pthreading.PThread
+
+
An optional override.
+
stopThread(PThread...) - Method in class pthreading.PThreadManager
Stops a given thread or threads (varargs) and removes it from the thread diff --git a/docs/index-files/index-11.html b/docs/index-files/index-11.html index ad08d9a..746b9ae 100644 --- a/docs/index-files/index-11.html +++ b/docs/index-files/index-11.html @@ -2,10 +2,10 @@ - + U-Index - + diff --git a/docs/index-files/index-2.html b/docs/index-files/index-2.html index 914becc..ab3ded0 100644 --- a/docs/index-files/index-2.html +++ b/docs/index-files/index-2.html @@ -2,10 +2,10 @@ - + B-Index - + diff --git a/docs/index-files/index-3.html b/docs/index-files/index-3.html index 01f2dc1..27c0ec1 100644 --- a/docs/index-files/index-3.html +++ b/docs/index-files/index-3.html @@ -2,10 +2,10 @@ - + C-Index - + @@ -84,7 +84,7 @@

C

calc() - Method in class pthreading.PThread
An optional override (you can do calculation-related code in - PThread.draw().
+ PThread.draw(), but putting it here may make more sense).
A B C D E G I P R S U 
All Classes All Packages diff --git a/docs/index-files/index-4.html b/docs/index-files/index-4.html index ea3fac4..a72d9f1 100644 --- a/docs/index-files/index-4.html +++ b/docs/index-files/index-4.html @@ -2,10 +2,10 @@ - + D-Index - + diff --git a/docs/index-files/index-5.html b/docs/index-files/index-5.html index 4cfdf1d..d510f22 100644 --- a/docs/index-files/index-5.html +++ b/docs/index-files/index-5.html @@ -2,10 +2,10 @@ - + E-Index - + diff --git a/docs/index-files/index-6.html b/docs/index-files/index-6.html index 9b060f1..a683024 100644 --- a/docs/index-files/index-6.html +++ b/docs/index-files/index-6.html @@ -2,10 +2,10 @@ - + G-Index - + diff --git a/docs/index-files/index-7.html b/docs/index-files/index-7.html index 95332c2..9fc7c37 100644 --- a/docs/index-files/index-7.html +++ b/docs/index-files/index-7.html @@ -2,10 +2,10 @@ - + I-Index - + diff --git a/docs/index-files/index-8.html b/docs/index-files/index-8.html index fecc373..a1ec4f1 100644 --- a/docs/index-files/index-8.html +++ b/docs/index-files/index-8.html @@ -2,10 +2,10 @@ - + P-Index - + diff --git a/docs/index-files/index-9.html b/docs/index-files/index-9.html index 91db146..e60b6c0 100644 --- a/docs/index-files/index-9.html +++ b/docs/index-files/index-9.html @@ -2,10 +2,10 @@ - + R-Index - + diff --git a/docs/index.html b/docs/index.html index 63edd4a..7718c6e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,10 +2,10 @@ - + Generated Documentation (Untitled) - +