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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
flow3r firmware
Commits
811a9ea5
Commit
811a9ea5
authored
1 year ago
by
alufers
Committed by
pippin
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
uctx: Document add_stop method and add linear_gradient example
parent
23ffd052
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!182
uctx: Document add_stop method and add linear_gradient example
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python_payload/mypystubs/ctx.pyi
+22
-4
22 additions, 4 deletions
python_payload/mypystubs/ctx.pyi
with
22 additions
and
4 deletions
python_payload/mypystubs/ctx.pyi
+
22
−
4
View file @
811a9ea5
try
:
from
typing
import
Protocol
from
typing
import
Protocol
,
Tuple
except
ImportError
:
from
typing_extensions
import
Protocol
# type: ignore
from
typing_extensions
import
Protocol
,
Tuple
# type: ignore
class
Context
(
Protocol
):
"""
...
...
@@ -275,13 +275,31 @@ class Context(Protocol):
TOD(q3k): document
"""
pass
def
add_stop
(
self
,
pos
:
float
,
color
:
Tuple
[
float
,
float
,
float
],
alpha
:
float
)
->
"
Context
"
:
"""
Adds a color stop for a linear or radial gradient. Pos is a position between 0.0 and 1.0.
Should be called after linear_gradient or radial_gradient.
"""
pass
def
linear_gradient
(
self
,
x0
:
float
,
y0
:
float
,
x1
:
float
,
y1
:
float
)
->
"
Context
"
:
"""
Change the source to a linear gradient from x0,y0 to x1,y1, by default
an empty gradient from black to white exists, add stops with
gradient_add_stop to specify a custom gradient.
add_stop to specify a custom gradient.
This is a simple example rendering a rainbow gradient on the right side of the screen:
TODO(q3k): check gradient_add_stop
>>>
ctx
.
linear_gradient
(
0.18
*
120
,
0.5
*
120
,
0.95
*
120
,
0.5
*
120
)
>>>
ctx
.
add_stop
(
0.0
,
[
255
,
0
,
0
],
1.0
)
>>>
ctx
.
add_stop
(
0.2
,
[
255
,
255
,
0
],
1.0
)
>>>
ctx
.
add_stop
(
0.4
,
[
0
,
255
,
0
],
1.0
)
>>>
ctx
.
add_stop
(
0.6
,
[
0
,
255
,
255
],
1.0
)
>>>
ctx
.
add_stop
(
0.8
,
[
0
,
0
,
255
],
1.0
)
>>>
ctx
.
add_stop
(
1.0
,
[
255
,
0
,
255
],
1.0
)
>>>
ctx
.
rectangle
(
-
120
,
-
120
,
240
,
240
)
>>>
ctx
.
fill
()
"""
pass
def
radial_gradient
(
...
...
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