IF3Si/pde/IF3Si/drawSpectrum.pde

44 lines
1.3 KiB
Plaintext

/*
This file is part of "Interface Fractures III - Silicon".
Copyright (c) 2015 Luka Prinčič, All rights reserved.
This program is free software distributed under
GNU General Public Licence. See COPYING for more info.
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
drawSpectrum.pde - draw spectral lines
*/
void drawSpectrum(boolean render,
ArrayList<FloatList> siLinesData,
int threshold,
float afactor,
float line_height)
{
if (render) {
//float afactor = float(afactor);
afactor = map(pow(afactor, 5), 0, pow(127, 5), 0, 50 );
line_height = map(line_height, 0, 127, 0, height/2);
for (int i = 0; i < siLinesData.size(); i++) {
if (siLinesData.get(i).get(1) > threshold) {
float wavelength = siLinesData.get(i).get(0);
float intensity = siLinesData.get(i).get(1);
float red = siLinesData.get(i).get(2);
float green = siLinesData.get(i).get(3);
float blue = siLinesData.get(i).get(4);
float alpha = map(intensity, 0, 1000, 0, 255) * afactor;
color line_c = color(red, green, blue, alpha);
stroke(line_c);
line(map(wavelength, 3950, 6741, 1, width), height/2 - line_height,
map(wavelength, 3950, 6741, 1, width), height/2 + line_height);
}
}
}
}