Skip to content

Commit

Permalink
added javadoc to builder package
Browse files Browse the repository at this point in the history
  • Loading branch information
cansik committed Apr 4, 2017
1 parent 23e01b7 commit 531f426
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/main/java/ch/bildspur/postfx/builder/PostFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,41 @@
import processing.core.PGraphics;

/**
* Created by cansik on 01.04.17.
* Basic PostFX api with builder pattern.
*/
public class PostFX {
PApplet sketch;
PostFXSupervisor supervisor;
PostFXBuilder builder;

/**
* Create a new PostFX context.
*
* @param sketch Processing context.
*/
public PostFX(PApplet sketch) {
this.sketch = sketch;
supervisor = new PostFXSupervisor(sketch);
builder = new PostFXBuilder(this, supervisor);
}

/**
* @param sketch Processing context.
* @param width Width of the pass buffer.
* @param height Height of the pass buffer.
*/
public PostFX(PApplet sketch, int width, int height) {
this.sketch = sketch;
supervisor = new PostFXSupervisor(sketch, width, height);
builder = new PostFXBuilder(this, supervisor);
}

/**
* Start rendering a texture.
*
* @param graphics Texture used to render.
* @return PostFXBuilder pattern object.
*/
public PostFXBuilder render(PGraphics graphics) {
supervisor.render(graphics);
return builder;
Expand Down
41 changes: 40 additions & 1 deletion src/main/java/ch/bildspur/postfx/builder/PostFXBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Map;

/**
* Created by cansik on 01.04.17.
* PostFX builder pattern.
*/
public class PostFXBuilder {
private PostFXSupervisor supervisor;
Expand Down Expand Up @@ -49,20 +49,43 @@ private <T extends BasePass> T getPass(Class<T> type) {
return pass;
}

/**
* Compose and finalize rendering onto sketch texture.
*/
public void compose() {
supervisor.compose();
}

/**
* Compose and finalize rendering.
*
* @param graphics Texture to render onto.
*/
public void compose(PGraphics graphics) {
supervisor.compose(graphics);
}

/**
* Run a blur pass on the texture.
*
* @param blurSize Size of the blur.
* @param sigma Sigma of the blur.
* @return Builder object.
*/
public PostFXBuilder blur(int blurSize, float sigma) {
blur(blurSize, sigma, false);
blur(blurSize, sigma, true);
return this;
}

/**
* Run a blur pass on the texture.
*
* @param blurSize Size of the blur.
* @param sigma Sigma of the blur.
* @param horizontal Indicates if the pass runs horizontal or vertical.
* @return Builder object.
*/
public PostFXBuilder blur(int blurSize, float sigma, boolean horizontal) {
BlurPass pass = getPass(BlurPass.class);

Expand All @@ -74,6 +97,12 @@ public PostFXBuilder blur(int blurSize, float sigma, boolean horizontal) {
return this;
}

/**
* Run a bright pass pass on the texture.
*
* @param threshold Threshold of the brightness.
* @return Builder object.
*/
public PostFXBuilder brightPass(float threshold) {
BrightPass pass = getPass(BrightPass.class);

Expand All @@ -83,12 +112,22 @@ public PostFXBuilder brightPass(float threshold) {
return this;
}

/**
* Run a sobel edge detection pass on the texture.
*
* @return Builder object.
*/
public PostFXBuilder sobel() {
SobelPass pass = getPass(SobelPass.class);
supervisor.pass(pass);
return this;
}

/**
* Run a toon pass on the texture.
*
* @return Builder object.
*/
public PostFXBuilder toon() {
ToonPass pass = getPass(ToonPass.class);
supervisor.pass(pass);
Expand Down

0 comments on commit 531f426

Please sign in to comment.