Änderungen

Rundbunt Mini Emulator

1.955 Byte hinzugefügt, 07:58, 7. Okt. 2015
/* Emulator Programm */
== Emulator Programm ==
[[Datei:Rundbunt mini Emulator screenshot 1.PNG|thumb]]
* Programm für Der Emulator simuliert die 64 LED des [[Rundbunt_Mini]] * Programmiert unter Processing 2.x (getestet unter Windows)
* Das eindimensionale Array ''hsvbuf1[]'' wird durch die Funktion ''render_lamp()'' auf dem Bildschirm gerendert.
* die Potis für ''para[1]'' und '''para[2]'' können am unteren Bildschirm-Rand mit der Maus gesteuert werden.
 
 
== Limits ==
== Quellcode mit Beispiel-Muster ==
<pre>
// -------------------------------------------------------------------------------
// Rundbunt Mini Emulator
// -------------------------------------------------------------------------------
// 005 - 2015-10-07 - corrected hue calculation with modulo
// -------------------------------------------------------------------------------
 
 
/*
The MIT License (MIT)
 
Copyright (c) 2015, Axel Föhr (axl [AT] realaxl.de)
 
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
 
 
CHSV[] hsvbuf1 = new CHSV[64];
para[i] = 512;
}
draw_para(1);
draw_para(2);
}
 
void draw() {
{
// ============================================= // ==== rotating color dots dot ===== // ==== para[1] - base color ===== // ==== para[2] - color distribution ===== // =============================================
float mx, my;
ts = sqrt(sq(dx) + sq(dy));
ts = exp(-sq(ts ) * .5133);
pos = x * 8 + y;
hsvbuf1[pos].h = para1 / 4 + para2 * sin(ts); // y * 32.0 + 255 * sin(millis() / 10000.0);
hsvbuf1[pos].s = 255 * ts;
hsvbuf1[pos].v = ts * 255;
render_lamp();
}
 
void mouseDragged() {
if (my < 80) {
if (my < 40) {
para[2] = min(1023, max(0, round(map(mx, 0, width, 0, 1023)); fill(0); rect(0, height - 40, width, 40); filldraw_para(#4682B4); rect(0, height - 40, mx, 40); fill(255); text("para[2] = " + para[2], 10, height - 15);
} else {
para[1] = min(1023, max(0, round(map(mx, 0, width, 0, 1023)); fill(0); rect(0, height - 80, width, 40); filldraw_para(#3E484F); rect(0, height - 80, mx, 40); fill(255); text("para[1] = " + para[1], 10, height - 55);
}
}
}
 
void draw_para(int n) {
if (n == 1) {
noStroke();
fill(0);
rect(0, height - 80, width, 40);
fill(#3E484F);
rect(0, height - 80, map(para[n], 0, 1023, 0, width), 40);
fill(255);
text("para[1] = " + para[1], 10, height - 55);
}
if (n == 2) {
noStroke();
fill(0);
rect(0, height - 40, width, 40);
fill(#4682B4);
rect(0, height - 40, map(para[n], 0, 1023, 0, width), 40);
fill(255);
text("para[2] = " + para[2], 10, height - 15);
}
}
void render_lamp() {
//fill(led[pos]);
fill(color(float h = hsvbuf1[pos].h % 256; fill(color(h, hsvbuf1[pos].s, hsvbuf1[pos].v));
rect (x0, y0, 38, 38);
}
1.383
Bearbeitungen