Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

YAML configuration file for ruby-processing

View .rp5rc
1 2 3 4 5
#RP5_HOME: "" # windoes users should set this
PROCESSING_ROOT: "/usr/share/processing" # Works for ArchLinux
#PROCESSING_ROOT: "/home/tux/processing-2.2.1" # Other linux distros with user tux
#PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java" # Path for Mac
#PROCESSING_ROOT: "C:\Java\processing-2.2.1" # if you follow PhiLhos suggestion for windoes
View .rp5rc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
import java.io.File;
 
Button enter, nojruby;
String processingRoot = "enter your processing root here"; // edit this line in the sketch
String done = "Done";
String OS = System.getProperty("os.name").toLowerCase();
String home, suggestion, separator, root;
PFont font;
float rectX, rectX2, rectY; // Position of buttons
float rectHeight = 30; // height of rect
float rectWidth = 90; // width of rect
int rectColor, rectColor2;
int rectHighlight, rectHighlight2;
int currentColor;
int selectedColor;
boolean acceptOver = false;
boolean noJruby = false;
boolean selected = false;
boolean no_jruby = false;
// The JSON object
JSONObject json;
 
void setup() {
size(600, 200);
home = System.getProperty("user.home");
File f = new File(home);
json = new JSONObject();
root = f.getParent();
separator = System.getProperty("file.separator");
font = createFont("Helvetica", 18);
if (OS.contains("mac")) {
suggestion = "/Applications/Processing.app/Contents/Resources/Java";
} else {
suggestion = home + separator + "processing-2.2.1";
}
rectColor = color(140);
rectColor2 = color(140);
rectHighlight = color(100);
rectHighlight2 = color(100);
selectedColor = color(0);
rectX = rectWidth + 20;
rectX2 = rectWidth + 150;
rectY = height * 0.8 - rectHeight / 4;
enter = new Button(rectX2, rectY, rectWidth, rectHeight, "enter");
nojruby = new Button(rectX, rectY, rectWidth, rectHeight, "nojruby");
}
 
void draw() {
background(200);
fill(0, 0, 200);
text("Suggestion:", 35, 28);
text(suggestion, 35, 56);
textFont(font, 18);
fill(255, 0, 0);
// this adds a blinking cursor after your text, at the expense of redrawing everything every frame
text(processingRoot + (frameCount / 10 % 2 == 0 ? "_" : ""), 35, 100);
fill(0, 0, 200);
text("Select nojruby to use jruby-complete by default", 35, 140);
update(mouseX, mouseY);
//background(200);
 
if (acceptOver) {
enter.draw(rectHighlight);
nojruby.draw(rectHighlight2);
} else {
enter.draw(rectColor);
nojruby.draw(rectColor2);
}
}
 
void writeRoot() {
rectColor = selectedColor;
rectHighlight = selectedColor;
json.setString("PROCESSING_ROOT", processingRoot);
json.setBoolean("JRUBY", !no_jruby);
json.setInt("X_OFF", floor(displayWidth * 0.1));
json.setInt("Y_OFF", floor(displayHeight * 0.1));
// to explictly set sketchbook path un-comment line below
// replacing 'location' = [File][Preferences][Sketchbook Location:]
// json.setString("sketchbook_path", "location");
saveJSONObject(json, home + separator + ".rp5rc");
processingRoot = done;
}
 
 
void keyReleased() {
if (key != CODED) {
switch (key) {
case BACKSPACE:
processingRoot = processingRoot.substring(0, max(0, processingRoot.length() - 1));
break;
case ENTER: // save the processing root to the config file
case RETURN:
writeRoot();
break;
case ESC:
case DELETE:
break;
default:
processingRoot += key;
}
}
}
 
void update(float x, float y) {
acceptOver = enter.overRect();
noJruby = nojruby.overRect();
}
 
 
void mouseClicked() {
update(mouseX, mouseY);
if (acceptOver) {
rectColor = selectedColor;
rectHighlight = selectedColor;
writeRoot();
}
if (noJruby) {
rectColor2 = selectedColor;
rectHighlight2 = selectedColor;
no_jruby = true;
}
}
 
class Button {
 
float x, y, w, h;
String text;
 
Button(float x, float y, float w, float h, String text) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.text = text;
}
 
void draw(int col) {
fill(col);
rect(x, y, w, h, 20, 20, 20, 20);
fill(255);
text(text, x + 8, y + 20);
}
 
boolean overRect() {
return (mouseX >= x && mouseX <= x + w
&& mouseY >= y && mouseY <= y + h);
}
}
Owner

SetProcessingRoot.pde generates .rp5rc for your system, using an installed processing ide which you need!!!

Correction: The Mac PROCESSING_ROOT is '/Applications/Processing.app/Contents/Java'

Owner

Changed after seeing @jkisor note was /Applications/Processing.app/Contents/Resources/Java

Owner

Updated to latest version of processing-2.2, if I forget to do this you will know what to do?

Owner

Updated for ruby-processing-2.6.2, also make use of processing JSONObject (JSON is a subset of yaml after-all). Added commented out ability to set sketchbook. Corrected JRUBY logic false/true.

Hi! The .rp5rc file that was generated for me (Mac) didn't work initially! The line:

"JRUBY": false,

had to be changed to

"JRUBY": "false",

Seems to be no problem now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.