Skip to content

Commit

Permalink
First Release without README
Browse files Browse the repository at this point in the history
First Release without README and Examples

First Release without README
  • Loading branch information
ShinghoiXu committed Jan 16, 2023
1 parent d8e95db commit 4db10b1
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/core.jar"/>
<classpathentry kind="lib" path="E:/Grainy/core.jar"/>
<classpathentry kind="output" path="resources/code"/>
</classpath>
File renamed without changes.
23 changes: 23 additions & 0 deletions examples/GrainyCircle/GrainyCircle.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import grainy.graphics.*;
PGraphics canv;
GrainyPainter myGP;

void setup(){
size(600,600);
//background(0);
canv = createGraphics(600,600);

myGP = new GrainyPainter(canv);
}

void draw(){
canv.beginDraw();
canv.background(0);
canv.stroke(#72ABE3);
canv.endDraw();
myGP.setPaintingMode(3);
for(int i = 0; i <= 4 ; i++){
myGP.grainyCircle(300,300,200);
}
image(canv,0,0);
}
19 changes: 0 additions & 19 deletions examples/Hello/Hello.pde

This file was deleted.

2 changes: 1 addition & 1 deletion resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Some folders like `examples` or `src` might be missing. After Library ##library.

### Troubleshooting

If you're having trouble, have a look at the [Processing Wiki](https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library) for more information, or contact the author [##author.name##](##author.url##).
If you're having trouble, have a look at the [Processing Wiki](https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library) for more information, or contact the author [##author.name##](##author.url##).
6 changes: 3 additions & 3 deletions resources/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ${user.home}/My Documents/Processing (make adjustments below)

#sketchbook.location=${user.home}/My Documents/Processing
sketchbook.location=C:\Users\\u5F90\u8BDA\u5F00\Documents\Processing
sketchbook.location=C:/Users/\u5F90\u8BDA\u5F00/Documents/Processing


# Where are the jar files located that are required for compiling your Library
Expand All @@ -28,8 +28,8 @@ sketchbook.location=C:\Users\\u5F90\u8BDA\u5F00\Documents\Processing
# For OS X,the following path will direct you into Processing's application
# package, in case you put Processing inside your Applications folder.

classpath.local.location=E:\Grainy\lib
#classpath.local.location=/Applications/Processing.app/Contents/Java/core/library
#classpath.local.location=E:\Grainy\lib
classpath.local.location=E:/Program Files/processing-4.1.1/core/library


# Add all jar files that are required for compiling your project to the local
Expand Down
126 changes: 92 additions & 34 deletions src/grainy/graphics/GrainyPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class GrainyPainter {
private float rStepStep = 0.1f;

private boolean silentMode = false;
private int paintingMode = 1;
public final static String VERSION = "##library.prettyVersion##";

/**
Expand All @@ -43,7 +44,6 @@ public GrainyPainter(PGraphics myCanvas, String extraCommand) {
}
}


private void welcome() {
System.out.println("##library.name## ##library.prettyVersion## by ##author##");
System.out.println("The Target PGraphics is "+canvas.toString());
Expand All @@ -69,6 +69,39 @@ public PGraphics getCanvas() {
return this.canvas;
}

public void setPaintingMode(int modeNum) {
if(modeNum > 0 && modeNum <= 4) {
this.paintingMode = modeNum;
}
else {
System.out.println("This Painting Mode doesn't Exist. Please set it to a Integer between 1 and 4");
}
}

public int getPaintingMode() {
return this.paintingMode;
}

public String outputPaintingMode() {
switch(this.paintingMode) {
case 1:
System.out.println("EaseInExpo");
return "EaseInExpo";
case 2:
System.out.println("Liner");
return "Linear";
case 3:
System.out.println("EaseInOutSine");
return "EaseInOutSine";
case 4:
System.out.println("EaseOutCirc");
return "EaseOutCirc";
default:
System.out.println("EaseInExpo");
return "EaseInExpo";
}
}

/////////////////////////////////////////////

public void setStepScale(float stepScale) {
Expand Down Expand Up @@ -115,7 +148,7 @@ public float getMetaStepR() {

///////////////////////////////////

void grainyLine(float startX,float startY,float endX,float endY){
public void grainyLine(float startX,float startY,float endX,float endY){
float myStep = stepScale;
float x = startX;
float y = startY;
Expand All @@ -139,7 +172,7 @@ void grainyLine(float startX,float startY,float endX,float endY){
}
}

void grainyLine(float startX,float startY,float endX,float endY,PGraphics canvas){
public void grainyLine(float startX,float startY,float endX,float endY,PGraphics canvas){
this.canvas = canvas;
float myStep = stepScale;
float x = startX;
Expand All @@ -164,7 +197,7 @@ void grainyLine(float startX,float startY,float endX,float endY,PGraphics canvas
}
}

boolean notReachEnd(float x,float start,float end){
private boolean notReachEnd(float x,float start,float end){
if(start<=end){
if(x<=end) return true; else return false;
}
Expand All @@ -173,7 +206,7 @@ boolean notReachEnd(float x,float start,float end){
}
}

void dropPoints(float x,float y){
private void dropPoints(float x,float y){
float rStep = 0.0f;
float r = rIni;
do{
Expand All @@ -186,17 +219,29 @@ void dropPoints(float x,float y){
tempY = (float) (Math.random()-0.5f);
tempX *= r; tempY *= r;
}
this.canvas.beginDraw();
this.canvas.point(x+tempX,y+tempY);
this.canvas.endDraw();
}
rStep+=rStepStep;
//r=rStep;
//r=easeOutCirc(rStep)*endR;
r=easeInExpo(rStep)*endR;
//r=easeInOutSine(rStep)*endR;

switch(this.paintingMode) {
case 1:
r=easeInExpo(rStep)*endR;
case 2:
r=rStep;
case 3:
r=easeInOutSine(rStep)*endR;
case 4:
r=easeOutCirc(rStep)*endR;
default:
r=easeInExpo(rStep)*endR;
}
}while(r<endR);
}

void dropPoints(float x,float y,PGraphics canvas){
private void dropPoints(float x,float y,PGraphics canvas){
this.canvas = canvas;
float rStep = 0.0f;
float r = rIni;
do{
Expand All @@ -209,66 +254,79 @@ void dropPoints(float x,float y,PGraphics canvas){
tempY = (float) (Math.random()-0.5f);
tempX *= r; tempY *= r;
}
canvas.point(x+tempX,y+tempY);
this.canvas.beginDraw();
this.canvas.point(x+tempX,y+tempY);
this.canvas.endDraw();
}
rStep+=rStepStep;
//r=rStep;
//r=easeOutCirc(rStep)*endR;
r=easeInExpo(rStep)*endR;
//r=easeInOutSine(rStep)*endR;

switch(this.paintingMode) {
case 1:
r=easeInExpo(rStep)*endR;
case 2:
r=rStep;
case 3:
r=easeInOutSine(rStep)*endR;
case 4:
r=easeOutCirc(rStep)*endR;
default:
r=easeInExpo(rStep)*endR;
}
}while(r<endR);
}

void grainyPoint(float x,float y){
public void grainyPoint(float x,float y){
grainyLine(x,y,x,y);
}

void grainyPoint(float x,float y,PGraphics canvas){
public void grainyPoint(float x,float y,PGraphics canvas){
grainyLine(x,y,x,y,canvas);
}

void grainyRect(float x,float y,float myWidth,float myHeight){
public void grainyRect(float x,float y,float myWidth,float myHeight){
grainyLine(x,y,x+myWidth,y);
grainyLine(x,y,x,y+myHeight);
grainyLine(x+myWidth,y,x+myWidth,y+myHeight);
grainyLine(x,y+myHeight,x+myWidth,y+myHeight);
}

void grainyEllipse(float x,float y,float myWidth,float myHeight){
public void grainyEllipse(float x,float y,float myWidth,float myHeight){
for (int i=0; i<Math.round(Math.max(myWidth,myHeight)*2f); i++) {
float a = (float) (i * 2 * Math.PI/Math.round(Math.max(myWidth,myHeight)*2f));
float x1 = (float) (myWidth * 0.5f * Math.cos(a));
float y1 = (float) (myHeight * 0.5f * Math.sin(a));
grainyPoint(x1, y1);
grainyPoint(x+x1, y+y1);
}
}

void grainyCircle(float x,float y,float r){
grainyEllipse(x,y,r,r);
public void grainyCircle(float x,float y,float r){
grainyEllipse(x,y,r*2,r*2);
}

////////////////////////////////////////

private float dist(float x1, float y1, float x2, float y2) {
return (float) Math.sqrt( (x2-x1)*(x2-x1)+ (y2-y1)*(y2-y1));
}

private float easeInExpo(float x){//mode 1
if(x==0){
return 0;
}
else{
return (float) Math.pow(2, 10 * x - 10);
}
}

private float easeInOutSine(float x){//mode 3
return (float) (-(Math.cos(Math.PI * x) - 1) / 2);
}

private float easeOutCirc(float x){
private float easeOutCirc(float x){//mode 4
return (float) Math.sqrt(1 - Math.pow(x - 1, 2));
}

float easeInExpo(float x){
if(x==0){
return 0;
}
else{
return (float) Math.pow(2, 10 * x - 10);
}
}

float easeInOutSine(float x){
return (float) (-(Math.cos(Math.PI * x) - 1) / 2);
}
}


Expand Down

0 comments on commit 4db10b1

Please sign in to comment.