From e6c5fe56c53acf7d71b890f4f0b5e729c325ab93 Mon Sep 17 00:00:00 2001 From: Nova deViator Date: Fri, 11 Sep 2015 16:37:56 +0200 Subject: [PATCH] ported procLinesFunc to processing --- pde/IF3Si/IF3Si.pde | 13 +++++--- pde/IF3Si/functions.pde | 5 --- pde/IF3Si/getLinesData.pde | 68 ++++++++++++++++++++++++++++++++++---- 3 files changed, 70 insertions(+), 16 deletions(-) diff --git a/pde/IF3Si/IF3Si.pde b/pde/IF3Si/IF3Si.pde index 759d1b0..b27616f 100644 --- a/pde/IF3Si/IF3Si.pde +++ b/pde/IF3Si/IF3Si.pde @@ -63,11 +63,13 @@ int tilesOverlap; boolean testPictureToggle = false; PFont testFont; +// testPattern +boolean testPatternToggle = false; + + // fps PFont fpsFont; -// testPattern -boolean testPatternToggle = false; // siLines ArrayList siLinesData; @@ -152,12 +154,13 @@ void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fpsFont = createFont("Ubuntu Mono", 16); - // siLines - } + + + ////////////////////////////////////////////////////////////////////////////// void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -206,6 +209,8 @@ void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // test pattern```````````````````````````````````````````````````| + + testPattern(testPatternToggle, // boolean(0), // on/off 2, 0, // img bank & ID 255, // image alpha diff --git a/pde/IF3Si/functions.pde b/pde/IF3Si/functions.pde index 62b00e1..8f86ed0 100644 --- a/pde/IF3Si/functions.pde +++ b/pde/IF3Si/functions.pde @@ -215,8 +215,3 @@ void textureSphere(PGraphics pg, float rx, float ry, float rz, PImage t) { - - - -// TOOLS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pde/IF3Si/getLinesData.pde b/pde/IF3Si/getLinesData.pde index c9e4131..2a491b8 100644 --- a/pde/IF3Si/getLinesData.pde +++ b/pde/IF3Si/getLinesData.pde @@ -12,7 +12,20 @@ ArrayList getLinesData() { + float[][] colors = { // these are taken from http://astro.u-strasbg.fr/~koppen/discharge/discharge.html + { 3800.0, 0, 0, 0}, + { 4000.0, 150, 0, 150}, + { 4400.0, 120, 0, 255}, // violet + { 4500.0, 0, 0, 255}, // blue + { 4800.0, 0, 255, 255}, // cyan + { 5200.0, 0, 255, 0}, // green + { 5800.0, 255, 255, 0}, // yellow + { 6500.0, 255, 0, 0}, // red + { 7000.0, 80, 0, 0}, + { 7300.0, 0, 0, 0} }; + String[] siLinesData; + int threshold = 400; siLinesData = loadStrings(dataPath(sketchPath + "/silicon_lines.txt")); ArrayList siLinesList = new ArrayList(); @@ -28,17 +41,58 @@ ArrayList getLinesData() { data_x.append(float(datatemp[i])); } } + + // process data - add rgb values + + //println(data_x.get(0)); + float wavelength = data_x.get(0); + for (int i = 0; i < colors.length; i++){ + float thisboundary = colors[i][0]; + if (i+1 < colors.length){ + float nextboundary = colors[i+1][0]; + if(wavelength > thisboundary && wavelength < nextboundary) { + int red = round(colors[i][1] + ( ( (colors[i+1][1] - colors[i][1]) / (colors[i+1][0] - colors[i][0]) ) + * (wavelength - colors[i][0]) )); + int green = round(colors[i][2] + ( ( (colors[i+1][2] - colors[i][2]) / (colors[i+1][0] - colors[i][0]) ) + * (wavelength - colors[i][0]) )); + int blue = round(colors[i][3] + ( ( (colors[i+1][3] - colors[i][3]) / (colors[i+1][0] - colors[i][0]) ) + * (wavelength - colors[i][0]) )); + data_x.append(red); + data_x.append(green); + data_x.append(blue); + + + } + } + } + printArray(data_x); + + siLinesList.add(data_x); - - } - - for(int i = 0; i < siLinesList.size(); i ++) { - println(siLinesList.get(i).get(0)); - float wavelength = siLinesList.get(i).get(0); - float intensity = siLinesList.get(i).get(1); + } + + + + + + // for(int i = 0; i < siLinesList.size(); i ++) { + // //println(siLinesList.get(i).get(0)); + // float wavelength = siLinesList.get(i).get(0); + // float intensity = siLinesList.get(i).get(1); + + // if(intensity > threshold && wavelength < 6741 && wavelength > 3950) { + // // (item[1].asInt > threshold) && (item[0].asInt < 6741) && (item[0].asInt > 3950), { + + // println(wavelength + " " + intensity); + + // } + + + + // } //printArray(siLinesList);