Mercurial > hg > screen-ui
view src/Voice.cpp @ 22:4dcc4312b5fa
Bit of a tidy up, adding text display, added full screen toggle and window resize handler.
author | samer |
---|---|
date | Thu, 02 Feb 2012 18:17:24 +0000 |
parents | 055d7524bae4 |
children | 460c05dd74d0 |
line wrap: on
line source
/* * Voice.cpp * MelodyTriangle * * Created by Henrik Ekeus on 12/01/2012. * Copyright 2012 Queen Mary University of London. All rights reserved. * */ #include "Voice.h" inline static double min(double x,double y) { return (x<y) ? x : y; } Voice::Voice(int id): radius(12), isActive(true), inTriangle(false), octave(0), highlight(false), amplitude(0.6), status(clear), id(id), posx(0), posy(0) {} void Voice::draw(){ int r,g,b; switch (status) { case clear: r=1; g=0; b=0; break; default: r=1; g=1; b=0; break; // case pending: r=1; g=1; b=0; break; // case waiting: r=1; g=0; b=0; break; // case moved: r=1; g=0; b=1; break; // default: r=0; g=1; b=0; } if (isActive) { r=2*r; g=2*g; b=2*b; } ofSetColor(100*r,60*g,60*b); ofFill(); ofCircle(posx, posy, radius); //ofNoFill(); //ofCircle(posx, posy, radius); if (highlight) { ofSetColor(230, 230, 230); ofNoFill(); ofCircle(posx, posy, radius); } else { ofNoFill(); ofCircle(posx, posy, radius); } } double Voice::louder() { return amplitude=min(1,amplitude*1.0625); } double Voice::quieter() { return amplitude/=1.0625; }