-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathofxNotification.cpp
More file actions
34 lines (30 loc) · 862 Bytes
/
ofxNotification.cpp
File metadata and controls
34 lines (30 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "ofxNotification.h"
void ofxNotification::set(ofTrueTypeFont &_font) { font = _font; }
void ofxNotification::notice(ofColor _back, ofColor _word, string _text) {
back = _back;
word = _word;
text = _text;
drawtrigger = true;
countframe = 0;
ypos = -font.stringHeight(text);
alpha = 200;
}
void ofxNotification::draw() {
if (drawtrigger) {
countframe++;
if (countframe <= animelim) {
ypos /= 1.2;
} else {
if (animelim * 1.5 < countframe) {
drawtrigger = false;
}
alpha /= 1.2;
}
ofSetColor(back, alpha);
ofDrawRectRounded(ofRectangle(100, ypos, ofGetWidth() - 200, 64), 16);
ofSetColor(word, alpha);
font.drawString(text,
((ofGetWidth() - 200) - font.stringWidth(text)) / 2 + 100,
(64 + font.stringHeight(text)) / 2 + ypos);
}
}