blob: 37b2fc4163c2818b13e14f284b743c5346faab48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include "marquee.h"
#include <string.h>
marquee_t make_marquee(char* str) {
marquee_t marquee;
marquee.textLength = strlen(str);
marquee.text = malloc(sizeof(char) * (marquee.textLength + 1));
strcpy(marquee.text, str);
marquee.scrolledBy = 0;
int pixelLength = marquee.textLength * 21;
marquee.scrollMax = 5 + pixelLength;
marquee.doesScroll = pixelLength > 128;
return marquee;
}
void scroll_marquee(marquee_t* marquee, int increment) {
//define the wrap point
int scrollMax = 5 + (marquee->textLength * 21);
//calculate the new scroll amount
int newScroll = marquee->scrolledBy + increment;
marquee->scrolledBy = newScroll <= marquee->scrollMax ? newScroll : 0;
}
|