Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
toerb
flow3r firmware
Commits
f5053f63
Commit
f5053f63
authored
1 year ago
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
sim: implement more ctx stuff
parent
50cb87bd
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sim/fakes/ctx.py
+80
-10
80 additions, 10 deletions
sim/fakes/ctx.py
with
80 additions
and
10 deletions
sim/fakes/ctx.py
+
80
−
10
View file @
f5053f63
...
@@ -100,10 +100,45 @@ class Ctx:
...
@@ -100,10 +100,45 @@ class Ctx:
def
__init__
(
self
,
_ctx
):
def
__init__
(
self
,
_ctx
):
self
.
_ctx
=
_ctx
self
.
_ctx
=
_ctx
self
.
text_align
=
'
start
'
@property
self
.
text_baseline
=
'
alphabetic
'
def
text_align
(
self
):
self
.
font_size
=
10.0
return
None
self
.
line_join
=
'
bevel
'
@text_align.setter
def
text_align
(
self
,
v
):
self
.
_emit
(
f
"
textAlign
{
v
}
"
)
@property
def
text_baseline
(
self
):
return
None
@text_baseline.setter
def
text_baseline
(
self
,
v
):
self
.
_emit
(
f
"
textBaseline
{
v
}
"
)
@property
def
line_width
(
self
):
return
None
@line_width.setter
def
line_width
(
self
,
v
):
self
.
_emit
(
f
"
lineWidth
{
v
:
.
3
f
}
"
)
@property
def
font_size
(
self
):
return
None
@font_size.setter
def
font_size
(
self
,
v
):
self
.
_emit
(
f
"
fontSize
{
v
:
.
3
f
}
"
)
@property
def
global_alpha
(
self
):
return
None
@global_alpha.setter
def
global_alpha
(
self
,
v
):
self
.
_emit
(
f
"
globalAlpha
{
v
:
.
3
f
}
"
)
def
_emit
(
self
,
text
):
def
_emit
(
self
,
text
):
_wasm
.
ctx_parse
(
self
.
_ctx
,
text
)
_wasm
.
ctx_parse
(
self
.
_ctx
,
text
)
...
@@ -112,10 +147,34 @@ class Ctx:
...
@@ -112,10 +147,34 @@ class Ctx:
self
.
_emit
(
f
"
moveTo
{
int
(
x
)
}
{
int
(
y
)
}
"
)
self
.
_emit
(
f
"
moveTo
{
int
(
x
)
}
{
int
(
y
)
}
"
)
return
self
return
self
def
translate
(
self
,
x
,
y
):
self
.
_emit
(
f
"
translate
{
int
(
x
)
}
{
int
(
y
)
}
"
)
return
self
def
line_to
(
self
,
x
,
y
):
def
line_to
(
self
,
x
,
y
):
self
.
_emit
(
f
"
lineTo
{
int
(
x
)
}
{
int
(
y
)
}
"
)
self
.
_emit
(
f
"
lineTo
{
int
(
x
)
}
{
int
(
y
)
}
"
)
return
self
return
self
def
rotate
(
self
,
v
):
self
.
_emit
(
f
"
rotate
{
v
:
.
3
f
}
"
)
return
self
def
gray
(
self
,
v
):
self
.
_emit
(
f
"
gray
{
v
:
.
3
f
}
"
)
return
self
def
rgba
(
self
,
r
,
g
,
b
,
a
):
# TODO(q3k): dispatch by type instead of value, warn on
# ambiguous/unexpected values for type.
if
r
>
1.0
or
g
>
1.0
or
b
>
1.0
or
a
>
1.0
:
r
/=
255.0
g
/=
255.0
b
/=
255.0
a
/=
255.0
self
.
_emit
(
f
"
rgba
{
r
:
.
3
f
}
{
g
:
.
3
f
}
{
b
:
.
3
f
}
{
a
:
.
3
f
}
"
)
return
self
def
rgb
(
self
,
r
,
g
,
b
):
def
rgb
(
self
,
r
,
g
,
b
):
# TODO(q3k): dispatch by type instead of value, warn on
# TODO(q3k): dispatch by type instead of value, warn on
# ambiguous/unexpected values for type.
# ambiguous/unexpected values for type.
...
@@ -127,9 +186,6 @@ class Ctx:
...
@@ -127,9 +186,6 @@ class Ctx:
return
self
return
self
def
text
(
self
,
s
):
def
text
(
self
,
s
):
self
.
_emit
(
f
"
textAlign
{
self
.
text_align
}
"
)
self
.
_emit
(
f
"
textBaseline
{
self
.
text_baseline
}
"
)
self
.
_emit
(
f
"
fontSize
{
self
.
font_size
}
"
)
self
.
_emit
(
f
"
text
\"
{
s
}
\"
"
)
self
.
_emit
(
f
"
text
\"
{
s
}
\"
"
)
return
self
return
self
...
@@ -142,10 +198,25 @@ class Ctx:
...
@@ -142,10 +198,25 @@ class Ctx:
return
self
return
self
def
stroke
(
self
):
def
stroke
(
self
):
self
.
_emit
(
f
"
lineJoin
{
self
.
line_join
}
"
)
self
.
_emit
(
f
"
stroke
"
)
self
.
_emit
(
f
"
stroke
"
)
return
self
return
self
def
start_group
(
self
):
self
.
_emit
(
f
"
start_group
"
)
return
self
def
end_group
(
self
):
self
.
_emit
(
f
"
end_group
"
)
return
self
def
save
(
self
):
self
.
_emit
(
f
"
save
"
)
return
self
def
restore
(
self
):
self
.
_emit
(
f
"
restore
"
)
return
self
def
fill
(
self
):
def
fill
(
self
):
self
.
_emit
(
f
"
fill
"
)
self
.
_emit
(
f
"
fill
"
)
return
self
return
self
...
@@ -155,5 +226,4 @@ class Ctx:
...
@@ -155,5 +226,4 @@ class Ctx:
return
self
return
self
def
text_width
(
self
,
text
):
def
text_width
(
self
,
text
):
self
.
_emit
(
f
"
fontSize
{
self
.
font_size
}
"
)
return
_wasm
.
ctx_text_width
(
self
.
_ctx
,
text
)
return
_wasm
.
ctx_text_width
(
self
.
_ctx
,
text
)
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