Skip to content

Commit

Permalink
added version numer to sketch
Browse files Browse the repository at this point in the history
  • Loading branch information
cansik committed Nov 16, 2016
1 parent 8d53018 commit f4307cf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
6 changes: 4 additions & 2 deletions src/ch/bildspur/ledforest/sketch/RenderSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Created by cansik on 16/08/16.
*/
public class RenderSketch extends PApplet {

public final static String VERSION = "2.1";
public final static String CONFIG_NAME = "config.json";

public final static int OUTPUT_WIDTH = 640;
Expand Down Expand Up @@ -81,7 +81,9 @@ public void settings() {
}

public void setup() {
surface.setTitle("LED Forest 2");
println("LED Forest 2 - " + VERSION);
surface.setTitle("LED Forest 2 - " + VERSION);

setupInterceptor();
prepareExitHandler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ void initUI() {
int editControlHeight = 30;
int editControlWidth = 50;

cp5.addLabel("LED Forest 2 - Rod Edit")
.setPosition(10, 10)
.setFont(sketch.createFont("Arial", 10));
cp5.addLabel("LED Forest 2 - " + RenderSketch.VERSION)
.setPosition(10, 10);

// list controls

Expand Down
32 changes: 11 additions & 21 deletions src/ch/bildspur/ledforest/ui/visualisation/TubeVisualizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
/**
* Created by cansik on 18/09/16.
*/
public class TubeVisualizer
{
public class TubeVisualizer {
public int rodColumnCount = 3;
public int rodRowCount = 5;

Expand All @@ -34,34 +33,29 @@ public class TubeVisualizer

PApplet sketch;

public TubeVisualizer(PApplet sketch)
{
public TubeVisualizer(PApplet sketch) {
this.sketch = sketch;
output2d = sketch.createGraphics(640, 480, PConstants.P2D);
rods = new ArrayList<>();
}

public void render3d()
{
for (Rod r : rods)
{
public void render3d() {
for (Rod r : rods) {
r.render();
}
}

public PGraphics render2d()
{
public PGraphics render2d() {
PGraphics p = output2d;

p.beginDraw();
p.background(0);
for (int i = 0; i < rods.size(); i++)
{
for (int i = 0; i < rods.size(); i++) {
Rod rod = rods.get(i);
Tube t = rod.tube;

// calculate height
if(t.leds.size() != 0)
if (t.leds.size() != 0)
height2d = (p.height - (2f * hoffset) - (t.leds.size() * hspace2d)) / t.leds.size();

p.noStroke();
Expand All @@ -72,8 +66,7 @@ public PGraphics render2d()
hoffset - (30));

// draw leds
for (int j = 0; j < t.leds.size(); j++)
{
for (int j = 0; j < t.leds.size(); j++) {
LED l = t.leds.get(t.leds.size() - 1 - j);
p.fill(l.getColor().getColor());
p.rect(i * (wspace2d + width2d) + woffset,
Expand All @@ -86,17 +79,14 @@ public PGraphics render2d()
return p;
}

public void initRods(ArrayList<Tube> tubes)
{
public void initRods(ArrayList<Tube> tubes) {
rods = new ArrayList<>();

float deltaX = (rodSpaceWidthDistance * rodRowCount) / 2f - (rodSpaceWidthDistance / 2);
float deltaZ = (rodSpaceDepthDistance * rodColumnCount) / 2f - (rodSpaceDepthDistance / 2);

for (int z = 0; z < rodColumnCount; z++)
{
for (int x = 0; x < rodRowCount; x++)
{
for (int z = 0; z < rodColumnCount; z++) {
for (int x = 0; x < rodRowCount; x++) {
PVector pos = new PVector(x * rodSpaceWidthDistance - deltaX, rodHeight, z * rodSpaceDepthDistance - deltaZ);
rods.add(new Rod(sketch.g, tubes.get((z * rodRowCount) + x), pos));
}
Expand Down

0 comments on commit f4307cf

Please sign in to comment.