This repository was archived by the owner on Feb 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_style.py
More file actions
executable file
·38 lines (30 loc) · 1.45 KB
/
demo_style.py
File metadata and controls
executable file
·38 lines (30 loc) · 1.45 KB
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
#!/usr/bin/env python
from datetime import datetime
from rich.console import Console
from recomponents.style.gradient import GradientPurpleYellow, GradientBlackWhite, GradientRedGreen
from recomponents.style.range import StyleRange, SelectorTime, SelectorLogarithmic, SelectorLinear
def main():
style_range = StyleRange(GradientRedGreen, SelectorLinear(0, 20))
console = Console()
console.print(style_range.apply("-1"))
console.print(style_range.apply("0"))
console.print(style_range.apply("1"))
console.print(style_range.apply("9"))
console.print(style_range.apply("10"))
console.print(style_range.apply("19"))
console.print(style_range.apply("20"))
console.print(style_range.apply("21"))
style_range = StyleRange(GradientBlackWhite, SelectorLogarithmic(1, 100))
console.print(style_range.apply("0"))
console.print(style_range.apply("1"))
console.print(style_range.apply("10"))
console.print(style_range.apply("100"))
console.print(style_range.apply("101"))
style_range = StyleRange(GradientPurpleYellow, SelectorTime(datetime(2021, 1, 1), datetime(2021, 12, 31)))
console.print(style_range.apply("2020-12-31 23:59:59"))
console.print(style_range.apply("2021-01-01 00:00:00"))
console.print(style_range.apply("2021-06-15 12:00:00"))
console.print(style_range.apply("2021-12-31 23:59:59"))
console.print(style_range.apply("2022-01-01 00:00:00"))
if __name__ == "__main__":
main()