-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.go
50 lines (39 loc) · 1.23 KB
/
parser.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
Package parser is the foundation for all content parsers on textmod.es.
Defaults
Although many parsers have different options and variants, the parser expects
the parsers to output an Image, Animation or Scroller with sensible defaults.
Some parser variants will provide additional parameters such as delay; it is
up to the implementer to check for most-specific to least specific rendition
interface where applicable.
*/
package parser
import (
"image"
"image/gif"
"time"
)
// Parser base interface.
type Parser interface{}
// Image can generate images.
type Image interface {
Image() (image.Image, error)
}
// Animation can generate animations.
type Animation interface {
Animate() (*gif.GIF, error)
}
// AnimationDelay is like Animation with custom frame delay.
type AnimationDelay interface {
AnimateDelay(time.Duration) (*gif.GIF, error)
}
// Scroller can generate scrolling animations. In the context of a text file,
// a scroller is different in that it will scroll the text within the
// limitations of the emulated display buffer.
type Scroller interface {
Scroller() (*gif.GIF, error)
}
// ScrollerDelay is like Scroller with custom frame delay.
type ScrollerDelay interface {
ScrollerDelay(time.Duration) (*gif.GIF, error)
}