From 811a9ea5a060aa1adb7a9a69c3dd3de6411ccc7c Mon Sep 17 00:00:00 2001
From: alufers <alufers@wp.pl>
Date: Thu, 17 Aug 2023 22:25:01 +0200
Subject: [PATCH] uctx: Document add_stop method and add linear_gradient
 example

---
 python_payload/mypystubs/ctx.pyi | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/python_payload/mypystubs/ctx.pyi b/python_payload/mypystubs/ctx.pyi
index bbd830b376..ca41ab9a7d 100644
--- a/python_payload/mypystubs/ctx.pyi
+++ b/python_payload/mypystubs/ctx.pyi
@@ -1,7 +1,7 @@
 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(
-- 
GitLab