From 1b7f3cc8bb966ec0c308532695d58adb642dad04 Mon Sep 17 00:00:00 2001 From: githubert Date: Mon, 27 May 2013 00:04:29 +0200 Subject: flipdots malen mit Processing --- flipdot/flipdot.pde | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 flipdot/flipdot.pde (limited to 'flipdot/flipdot.pde') diff --git a/flipdot/flipdot.pde b/flipdot/flipdot.pde new file mode 100644 index 0000000..6738128 --- /dev/null +++ b/flipdot/flipdot.pde @@ -0,0 +1,58 @@ +import processing.net.*; + +int x, y; +int scale = 8; +int i, j; +boolean[][] flipped; +Client c; +boolean change; + +int h = 16, w = 112; + + +void setup() +{ + size(112*scale, 16*scale); + flipped = new boolean[w][h]; + c = new Client(this, "192.168.23.222", 6210); + c.write("c"); +} + +void draw() { + background(0); + noStroke(); + + x = (mouseX - (mouseX % scale)) / scale; + y = (mouseY - (mouseY % scale))/ scale; + + println("x, y: " + x + " " + y); + + if( mousePressed && + (x < w && x >= 0) && + (y < h && y >= 0) ) { + flipped[x][y] = mouseButton == LEFT; + + + if ( flipped[x][y] ) { + c.write("1" + char(x) + char(y)); + } else { + c.write("0" + char(x) + char(y)); + } + } + + for(i = 0; i < w; i++) { + for(j = 0; j < h; j++) { + if( flipped[i][j] ) { + fill(204, 255, 0); + } else { + fill(0, 0, 0); + } + + rect(i*scale, j*scale, scale, scale); + } + } + + fill(92, 92, 92); + rect(x*scale, y*scale, scale, scale); +} + -- cgit