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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
flow3r firmware
Commits
1b34d944
Verified
Commit
1b34d944
authored
Nov 12, 2023
by
dos
Browse files
Options
Downloads
Patches
Plain Diff
sim: fakes: Improve ctx binding
parent
b404908c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sim/fakes/ctx.py
+35
-11
35 additions, 11 deletions
sim/fakes/ctx.py
with
35 additions
and
11 deletions
sim/fakes/ctx.py
+
35
−
11
View file @
1b34d944
...
@@ -106,9 +106,11 @@ class Context:
...
@@ -106,9 +106,11 @@ class Context:
END
=
"
end
"
END
=
"
end
"
MIDDLE
=
"
middle
"
MIDDLE
=
"
middle
"
BEVEL
=
"
bevel
"
BEVEL
=
"
bevel
"
NONE
=
"
none
"
def
__init__
(
self
,
_ctx
):
def
__init__
(
self
,
_ctx
):
self
.
_ctx
=
_ctx
self
.
_ctx
=
_ctx
self
.
_font_size
=
0
@property
@property
def
image_smoothing
(
self
):
def
image_smoothing
(
self
):
...
@@ -152,10 +154,11 @@ class Context:
...
@@ -152,10 +154,11 @@ class Context:
@property
@property
def
font_size
(
self
):
def
font_size
(
self
):
return
Non
e
return
self
.
_font_siz
e
@font_size.setter
@font_size.setter
def
font_size
(
self
,
v
):
def
font_size
(
self
,
v
):
self
.
_font_size
=
v
self
.
_emit
(
f
"
fontSize
{
v
:
.
3
f
}
"
)
self
.
_emit
(
f
"
fontSize
{
v
:
.
3
f
}
"
)
@property
@property
...
@@ -166,23 +169,34 @@ class Context:
...
@@ -166,23 +169,34 @@ class Context:
def
global_alpha
(
self
,
v
):
def
global_alpha
(
self
,
v
):
self
.
_emit
(
f
"
globalAlpha
{
v
:
.
3
f
}
"
)
self
.
_emit
(
f
"
globalAlpha
{
v
:
.
3
f
}
"
)
@property
def
x
(
self
):
return
0
@property
def
y
(
self
):
return
0
def
_emit
(
self
,
text
):
def
_emit
(
self
,
text
):
_wasm
.
ctx_parse
(
self
.
_ctx
,
text
)
_wasm
.
ctx_parse
(
self
.
_ctx
,
text
)
def
logo
(
self
,
x
,
y
,
r
):
return
self
def
move_to
(
self
,
x
,
y
):
def
move_to
(
self
,
x
,
y
):
self
.
_emit
(
f
"
moveTo
{
int
(
x
)
}
{
int
(
y
)
}
"
)
self
.
_emit
(
f
"
moveTo
{
x
:
.
3
f
}
{
y
:
.
3
f
}
"
)
return
self
return
self
def
curve_to
(
self
,
a
,
b
,
c
,
d
,
e
,
f
):
def
curve_to
(
self
,
a
,
b
,
c
,
d
,
e
,
f
):
self
.
_emit
(
f
"
curveTo
{
int
(
a
)
}
{
int
(
b
)
}
{
int
(
c
)
}
{
int
(
d
)
}
"
)
self
.
_emit
(
f
"
curveTo
{
a
:
.
3
f
}
{
b
:
.
3
f
}
{
c
:
.
3
f
}
{
d
:
.
3
f
}
{
e
:
.
3
f
}
{
f
:
.
3
f
}
"
)
return
self
return
self
def
rel_move_to
(
self
,
x
,
y
):
def
rel_move_to
(
self
,
x
,
y
):
self
.
_emit
(
f
"
relMoveTo
{
int
(
x
)
}
{
int
(
y
)
}
"
)
self
.
_emit
(
f
"
relMoveTo
{
x
:
.
3
f
}
{
y
:
.
3
f
}
"
)
return
self
return
self
def
rel_curve_to
(
self
,
a
,
b
,
c
,
d
,
e
,
f
):
def
rel_curve_to
(
self
,
a
,
b
,
c
,
d
,
e
,
f
):
self
.
_emit
(
f
"
relCurveTo
{
int
(
a
)
}
{
int
(
b
)
}
{
int
(
c
)
}
{
int
(
d
)
}
"
)
self
.
_emit
(
f
"
relCurveTo
{
a
:
.
3
f
}
{
b
:
.
3
f
}
{
c
:
.
3
f
}
{
d
:
.
3
f
}
{
e
:
.
3
f
}
{
f
:
.
3
f
}
"
)
return
self
return
self
def
close_path
(
self
):
def
close_path
(
self
):
...
@@ -190,7 +204,7 @@ class Context:
...
@@ -190,7 +204,7 @@ class Context:
return
self
return
self
def
translate
(
self
,
x
,
y
):
def
translate
(
self
,
x
,
y
):
self
.
_emit
(
f
"
translate
{
int
(
x
)
}
{
int
(
y
)
}
"
)
self
.
_emit
(
f
"
translate
{
x
:
.
3
f
}
{
y
:
.
3
f
}
"
)
return
self
return
self
def
scale
(
self
,
x
,
y
):
def
scale
(
self
,
x
,
y
):
...
@@ -198,7 +212,7 @@ class Context:
...
@@ -198,7 +212,7 @@ class Context:
return
self
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
{
x
:
.
3
f
}
{
y
:
.
3
f
}
"
)
return
self
return
self
def
rotate
(
self
,
v
):
def
rotate
(
self
,
v
):
...
@@ -236,7 +250,7 @@ class Context:
...
@@ -236,7 +250,7 @@ class Context:
def
round_rectangle
(
self
,
x
,
y
,
width
,
height
,
radius
):
def
round_rectangle
(
self
,
x
,
y
,
width
,
height
,
radius
):
self
.
_emit
(
self
.
_emit
(
f
"
roundRectangle
{
int
(
x
)
}
{
int
(
y
)
}
{
int
(
width
)
}
{
int
(
height
)
}
{
radius
}
"
f
"
roundRectangle
{
x
:
.
3
f
}
{
y
:
.
3
f
}
{
width
:
.
3
f
}
{
height
:
.
3
f
}
{
radius
:
.
3
f
}
"
)
)
return
self
return
self
...
@@ -279,7 +293,12 @@ class Context:
...
@@ -279,7 +293,12 @@ class Context:
)
)
return
self
return
self
def
add_stop
(
self
,
pos
,
red
,
green
,
blue
,
alpha
):
def
linear_gradient
(
self
,
x0
,
y0
,
x1
,
y1
):
self
.
_emit
(
f
"
linearGradient
{
x0
:
.
3
f
}
{
y0
:
.
3
f
}
{
x1
:
.
3
f
}
{
y1
:
.
3
f
}
"
)
return
self
def
add_stop
(
self
,
pos
,
color
,
alpha
):
red
,
green
,
blue
=
color
if
red
>
1.0
or
green
>
1.0
or
blue
>
1.0
:
if
red
>
1.0
or
green
>
1.0
or
blue
>
1.0
:
red
/=
255.0
red
/=
255.0
green
/=
255.0
green
/=
255.0
...
@@ -302,9 +321,13 @@ class Context:
...
@@ -302,9 +321,13 @@ class Context:
)
)
return
self
return
self
def
begin_path
(
self
):
self
.
_emit
(
f
"
beginPath
"
)
return
self
def
arc
(
self
,
x
,
y
,
radius
,
arc_from
,
arc_to
,
direction
):
def
arc
(
self
,
x
,
y
,
radius
,
arc_from
,
arc_to
,
direction
):
self
.
_emit
(
self
.
_emit
(
f
"
arc
{
int
(
x
)
}
{
int
(
y
)
}
{
int
(
radius
)
}
{
arc_from
:
.
4
f
}
{
arc_to
:
.
4
f
}
{
1
if
direction
else
0
}
"
f
"
arc
{
x
:
.
3
f
}
{
y
:
.
3
f
}
{
radius
:
.
3
f
}
{
arc_from
:
.
4
f
}
{
arc_to
:
.
4
f
}
{
1
if
direction
else
0
}
"
)
)
return
self
return
self
...
@@ -312,7 +335,8 @@ class Context:
...
@@ -312,7 +335,8 @@ class Context:
return
_wasm
.
ctx_text_width
(
self
.
_ctx
,
text
)
return
_wasm
.
ctx_text_width
(
self
.
_ctx
,
text
)
def
clip
(
self
):
def
clip
(
self
):
return
self
.
_emit
(
f
"
clip
"
)
return
self
def
get_font_name
(
self
,
i
):
def
get_font_name
(
self
,
i
):
return
[
return
[
...
...
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