Processing Forum
- color light = color(0,104,141); color dark = color(0,33,87); color txt = color(255,255,255); int txtsize = 12; int maxlines = 16; ArrayList debugText; uiElement[] uiElements = new uiElement[35]; class uiElement { int x,y,w,h,lx,ly; String label; int active; String group; uiElement(int c_x, int c_y, int c_w, int c_h, int c_lx, int c_ly, String c_label, String c_group) { x = c_x; y = c_y; w = c_w; h = c_h; lx = x+c_lx; ly = y+c_ly; label = c_label; active = 1; group = c_group; } } void setup() { orientation(LANDSCAPE); background(0); addUiElements(); debugText = new ArrayList(); debugText.add("helloo"); debugText.add("this is some text"); //noLoop(); } void draw() { drawUiElements(); int count = debugText.size(); if(count>maxlines) debugText.remove(0); drawTextArea(40, 500, 1050, 250, 10,10); } void addUiElements() { uiElements[0] = new uiElement( 40,50,100,100,5,5,"LED 1","grid"); uiElements[1] = new uiElement(140,50,100,100,5,5,"LED 2","grid"); uiElements[2] = new uiElement(240,50,100,100,5,5,"LED 3","grid"); uiElements[3] = new uiElement(340,50,100,100,5,5,"LED 4","grid"); uiElements[4] = new uiElement(440,50,100,100,5,5,"LED 5","grid"); uiElements[5] = new uiElement(540,50,100,100,5,5,"LED 6","grid"); uiElements[6] = new uiElement( 40,150,100,100,5,5,"LED 7","grid"); uiElements[7] = new uiElement(140,150,100,100,5,5,"LED 8","grid"); uiElements[8] = new uiElement(240,150,100,100,5,5,"LED 9","grid"); uiElements[9] = new uiElement(340,150,100,100,5,5,"LED 10","grid"); uiElements[10] = new uiElement(440,150,100,100,5,5,"LED 11","grid"); uiElements[11] = new uiElement(540,150,100,100,5,5,"LED 12","grid"); uiElements[12] = new uiElement( 40,250,100,100,5,5,"LED 13","grid"); uiElements[13] = new uiElement(140,250,100,100,5,5,"LED 14","grid"); uiElements[14] = new uiElement(240,250,100,100,5,5,"LED 15","grid"); uiElements[15] = new uiElement(340,250,100,100,5,5,"LED 16","grid"); uiElements[16] = new uiElement(440,250,100,100,5,5,"LED 17","grid"); uiElements[17] = new uiElement(540,250,100,100,5,5,"LED 18","grid"); uiElements[18] = new uiElement( 40,350,100,100,5,5,"LED 19","grid"); uiElements[19] = new uiElement(140,350,100,100,5,5,"LED 20","grid"); uiElements[20] = new uiElement(240,350,100,100,5,5,"LED 21","grid"); uiElements[21] = new uiElement(340,350,100,100,5,5,"LED 22","grid"); uiElements[22] = new uiElement(440,350,100,100,5,5,"LED 23","grid"); uiElements[23] = new uiElement(540,350,100,100,5,5,"LED 24","grid"); //drawFunctionButtons(690,50,100,100,4,1,50,0); uiElements[24] = new uiElement(690,50,100,100,5,5,"F1","func"); uiElements[25] = new uiElement(840,50,100,100,5,5,"F2","func"); uiElements[26] = new uiElement(990,50,100,100,5,5,"F3","func"); uiElements[27] = new uiElement(1140,50,100,100,5,5,"F4","func"); //drawSliders(690,200,100,250,4,1,50,0); uiElements[28] = new uiElement(690,200,100,250,5,5,"Slide1","slide"); uiElements[29] = new uiElement(840,200,100,250,5,5,"Slide2","slide"); uiElements[30] = new uiElement(990,200,100,250,5,5,"Slide3","slide"); uiElements[31] = new uiElement(1140,200,100,250,5,5,"Slide4","slide"); //drawAppControl(1140,500,100,50,1,3,0,50); uiElements[32] = new uiElement(1140,500,100,50,5,5,"App1","app"); uiElements[33] = new uiElement(1140,600,100,50,5,5,"App2","app"); uiElements[34] = new uiElement(1140,700,100,50,5,5,"App3","app"); } void drawUiElements() { for (int i = 0; i < uiElements.length; i++) { if (uiElements[i].active>1) { strokeWeight(2); stroke(light); fill(light); rect(uiElements[i].x,uiElements[i].y,uiElements[i].w,uiElements[i].h); fill(txt); textSize(txtsize); textAlign(LEFT, TOP); text(uiElements[i].label,uiElements[i].lx,uiElements[i].ly); uiElements[i].active--; } if (uiElements[i].active==1) { strokeWeight(2); stroke(light); fill(dark); rect(uiElements[i].x,uiElements[i].y,uiElements[i].w,uiElements[i].h); uiElements[i].active--; fill(txt); textSize(txtsize); textAlign(LEFT, TOP); text(uiElements[i].label,uiElements[i].lx,uiElements[i].ly); } } } void drawTextArea(int x, int y, int w, int h, int px, int py) { strokeWeight(2); stroke(light); fill(dark); rect(x,y,w,h); fill(txt); textSize(txtsize); textAlign(LEFT, TOP); int count = debugText.size(); for (int i = 0; i<count; i++) { String debug = (String) debugText.get(i); text(debug, x+px,y+py+((txtsize+2)*i),w-px,h-py); } } void drawFunctionButtons(int x, int y, int bw, int bh, int nw, int nh, int sw, int sh) { strokeWeight(2); stroke(light); fill(dark); for (int w = 0; w < nw; w++) { for (int h = 0; h < nh; h++) { rect(x+((bw+sw)*w),y+((bh+sh)*h),bw,bh); } } } void drawSliders(int x, int y, int bw, int bh, int nw, int nh, int sw, int sh) { strokeWeight(2); stroke(light); fill(dark); for (int w = 0; w < nw; w++) { for (int h = 0; h < nh; h++) { rect(x+((bw+sw)*w),y+((bh+sh)*h),bw,bh); } } } void drawAppControl(int x, int y, int bw, int bh, int nw, int nh, int sw, int sh) { strokeWeight(2); stroke(light); fill(dark); for (int w = 0; w < nw; w++) { for (int h = 0; h < nh; h++) { rect(x+((bw+sw)*w),y+((bh+sh)*h),bw,bh); } } } void mousePressed() { for (int i = 0; i < uiElements.length; i++) { if ((mouseX > uiElements[i].x && mouseX < uiElements[i].x+uiElements[i].w)&&(mouseY > uiElements[i].y && mouseY < uiElements[i].y+uiElements[i].h)) { uiElements[i].active=3; debugText.add(uiElements[i].label+" pressed"); break; } } // String temp ="pressed at x:"+mouseX+" y:"+mouseY; // debugText.add(temp); //println(temp); } public void resume() { } public void pause() { }
starting at a Longitude of 0.000000 and a Latitude of 50.000000 if we travel 1.000000 km on a bearing of 90.000000 degrees (0.000157 angular distance and 1.570796 in radians) we end up at Longitude of 0.000163 and a Latitude of -0.265482
+ Added support for separate 32 and 64 bit versions of libraries.