Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mensactrl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
stratum0
mensactrl
Commits
c0479b40
Commit
c0479b40
authored
10 years ago
by
Jan Luebbe
Browse files
Options
Downloads
Patches
Plain Diff
Add python font rendering and an example clock
parent
73418556
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/clock.py
+12
-0
12 additions, 0 deletions
python/clock.py
python/font_client.py
+69
-0
69 additions, 0 deletions
python/font_client.py
with
81 additions
and
0 deletions
python/clock.py
0 → 100755
+
12
−
0
View file @
c0479b40
#!/usr/bin/python
import
font_client
from
datetime
import
datetime
import
dateutil.tz
while
True
:
#font_client.draw(datetime.now().isoformat(), points=30)
font_client
.
draw
(
datetime
.
now
(
dateutil
.
tz
.
tzlocal
()).
isoformat
(),
points
=
25
)
This diff is collapsed.
Click to expand it.
python/font_client.py
0 → 100755
+
69
−
0
View file @
c0479b40
#!/usr/bin/python
import
sys
,
client
import
pygame
pygame
.
init
()
screen
=
pygame
.
Surface
((
client
.
WIDTH
,
client
.
HEIGHT
),
depth
=
8
)
def
send
(
screen
):
w
=
screen
.
get_width
()
h
=
screen
.
get_height
()
pxarray
=
pygame
.
PixelArray
(
screen
)
pixels
=
[]
for
y
in
range
(
h
):
for
x
in
range
(
w
):
pixels
.
append
(
pxarray
[
x
][
y
])
del
pxarray
client
.
blit
(
0
,
0
,
w
,
h
,
pixels
)
prev_mx
=
None
font
=
None
def
draw
(
text
,
mark
=
None
,
points
=
None
):
global
prev_mx
,
font
points
=
points
if
points
else
35
if
mark
else
60
font
=
pygame
.
font
.
SysFont
(
"
DejaVu Sans Mono
"
,
points
,
bold
=
True
)
count
=
len
(
text
)
text
=
font
.
render
(
text
,
True
,
(
255
,
255
,
255
),
(
0
,
0
,
0
))
screen
.
set_palette
(
text
.
get_palette
())
screen
.
fill
((
0
,
0
,
0
))
w
=
text
.
get_width
()
h
=
text
.
get_height
()
x
=
(
client
.
WIDTH
-
w
)
/
2
y
=
(
client
.
HEIGHT
-
h
)
/
2
if
mark
:
cw
=
w
/
count
mx
=
x
+
cw
*
(
mark
+
0.5
)
if
not
mx
==
prev_mx
:
for
size
in
range
(
240
,
5
,
-
15
):
pygame
.
draw
.
line
(
screen
,
255
,
(
mx
,
0
),
(
mx
,
client
.
HEIGHT
-
1
),
size
)
send
(
screen
)
pygame
.
draw
.
line
(
screen
,
0
,
(
mx
,
0
),
(
mx
,
client
.
HEIGHT
-
1
),
size
)
prev_mx
=
mx
pygame
.
draw
.
line
(
screen
,
255
,
(
mx
,
0
),
(
mx
,
client
.
HEIGHT
-
1
),
5
)
screen
.
blit
(
text
,
(
x
,
y
))
send
(
screen
)
if
__name__
==
"
__main__
"
:
if
len
(
sys
.
argv
)
>=
3
:
text
=
sys
.
argv
[
2
].
decode
(
'
utf-8
'
)
else
:
text
=
"
Hello World!
"
if
len
(
sys
.
argv
)
>=
4
:
mark
=
int
(
sys
.
argv
[
3
])
else
:
mark
=
None
draw
(
text
,
mark
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment