IF3Si/pde/IF3Si/drawSpectrum.pde

60 lines
2.0 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,
int line_height,
int rect_width,
float alpha_width)
{
if (render) {
// if((frameCount%60) < 1) { println("width: " + width); }; // DEBUG
//float afactor = float(afactor);
afactor = map(pow(afactor, 5), 0, pow(127, 5), 0, 50 );
line_height = int(map(line_height, 0, 127, 0, height/2));
threshold = int(map(pow(threshold, 3), 0, pow(127, 3), 0, 1000));
line_height = int(map(line_height, 0, 127, 0, height * 0.5));
rect_width = int(map(rect_width, 0, 127, 1, 400));
alpha_width = map(alpha_width, 0, 127, 0, 0.1);
// DEBUG:
// if((frameCount%60) < 1) { println("width: " + width); }; // DEBUG
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);
fill(line_c); noStroke();
rectMode(CENTER);
rect(map(wavelength, 3950, 6741, 1, width), height / 2, rect_width + (alpha * alpha_width), line_height/2 );
// stroke(line_c);
// line(map(wavelength, 3950, 6741, 1, width), height/2 - line_height,
// map(wavelength, 3950, 6741, 1, width), height/2 + line_height);
}
}
}
}