From 0893176c02193b57dd7c3e0ec6f0bbf1a16af104 Mon Sep 17 00:00:00 2001 From: Nova deViator Date: Fri, 11 Sep 2015 17:35:11 +0200 Subject: [PATCH] spectrum is online! --- pde/IF3Si/IF3Si.pde | 12 +++++++++- pde/IF3Si/getLinesData.pde | 48 ++++---------------------------------- 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/pde/IF3Si/IF3Si.pde b/pde/IF3Si/IF3Si.pde index b27616f..6631e36 100644 --- a/pde/IF3Si/IF3Si.pde +++ b/pde/IF3Si/IF3Si.pde @@ -109,7 +109,7 @@ void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - println("~~~ getting and processing lines data ..."); //siLinesData = new ArrayList(); siLinesData = getLinesData(); // function, returns an ArrayList - + //printArray(siLinesData); // ---------------------------------------------------------------------- @@ -172,9 +172,19 @@ void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + // SCENENGINES / / / / / / / / / / / / / / / / / / / / / / / / / / | + + + // drawSpectrum + drawSpectrum(boolean(1), + siLinesData); + // draw spheress```````````````````````````````````````````````````| drawSpheres(boolean(0) diff --git a/pde/IF3Si/getLinesData.pde b/pde/IF3Si/getLinesData.pde index 2a491b8..76dc119 100644 --- a/pde/IF3Si/getLinesData.pde +++ b/pde/IF3Si/getLinesData.pde @@ -12,6 +12,7 @@ ArrayList getLinesData() { + String[] siLinesData; 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}, @@ -24,27 +25,23 @@ ArrayList getLinesData() { { 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(); for (String lineData : siLinesData ) { + String[] datatemp = split(lineData, " "); - FloatList data_x; data_x = new FloatList(); + // clean up from that messy split for (int i = 0; i < datatemp.length; i++) { if (!datatemp[i].equals("")) { // if not empty (spaces): data_x.append(float(datatemp[i])); } } - // process data - add rgb values - - //println(data_x.get(0)); + // iterate through colors and find RGB values for each line float wavelength = data_x.get(0); for (int i = 0; i < colors.length; i++){ float thisboundary = colors[i][0]; @@ -57,49 +54,14 @@ ArrayList getLinesData() { * (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]) )); + // add them to the array 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); - - // if(intensity > threshold && wavelength < 6741 && wavelength > 3950) { - // // (item[1].asInt > threshold) && (item[0].asInt < 6741) && (item[0].asInt > 3950), { - - // println(wavelength + " " + intensity); - - // } - - - - // } - - //printArray(siLinesList); - - - - - return siLinesList; - }