mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
doc/api/hubs_ev3brick: add Image class as EV3Brick.screen
This duplicates the Image class documentation In pybricks.ev3devices as EV3Bricks.screen.
This commit is contained in:
@@ -34,11 +34,31 @@
|
||||
|
||||
.. automethod:: pybricks._instances.speaker.set_voice_settings
|
||||
|
||||
.. todo:: This functionality is not yet implemented
|
||||
|
||||
.. rubric:: Using the screen
|
||||
.. rubric:: Using the screen
|
||||
|
||||
.. automethod:: pybricks.hubs::EV3Brick.screen.clear
|
||||
|
||||
.. automethod:: pybricks.hubs::EV3Brick.screen.draw_text
|
||||
|
||||
.. automethod:: pybricks.hubs::EV3Brick.screen.print
|
||||
|
||||
.. automethod:: pybricks.hubs::EV3Brick.screen.set_font
|
||||
|
||||
.. automethod:: pybricks.hubs::EV3Brick.screen.draw_image
|
||||
|
||||
.. automethod:: pybricks.hubs::EV3Brick.screen.draw_pixel
|
||||
|
||||
.. automethod:: pybricks.hubs::EV3Brick.screen.draw_line
|
||||
|
||||
.. automethod:: pybricks.hubs::EV3Brick.screen.draw_box
|
||||
|
||||
.. automethod:: pybricks.hubs::EV3Brick.screen.draw_circle
|
||||
|
||||
.. autoattribute:: pybricks.hubs::EV3Brick.screen.width
|
||||
|
||||
.. autoattribute:: pybricks.hubs::EV3Brick.screen.height
|
||||
|
||||
.. todo:: This functionality is not yet implemented
|
||||
|
||||
.. ::
|
||||
|
||||
|
||||
+29
-1
@@ -19,10 +19,12 @@
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
from sphinx.domains.python import PyClassmember
|
||||
from sphinx.domains.python import PyClassmember, PythonDomain
|
||||
sys.path.insert(0, os.path.abspath('../..'))
|
||||
|
||||
from pybricks import _version # noqa E402
|
||||
from pybricks.hubs import EV3Brick # noqa E402
|
||||
from pybricks.resources import Image # noqa E402
|
||||
|
||||
# ON_RTD is whether we are on readthedocs.org
|
||||
# this line of code grabbed from docs.readthedocs.org
|
||||
@@ -261,8 +263,34 @@ texinfo_documents = [
|
||||
]
|
||||
|
||||
|
||||
# -- Python domain hacks ---------------------------------------------------
|
||||
|
||||
def get_signature_prefix_none(self, sig):
|
||||
return ''
|
||||
|
||||
|
||||
PyClassmember.get_signature_prefix = get_signature_prefix_none
|
||||
|
||||
|
||||
# HACK: For certain hub attributes, we list the class members of the attributes
|
||||
# class as if the attribute was a nested class so that readers don't have to
|
||||
# skip around the docs as much. To make this work, we replace the attribute
|
||||
# values with the type and override PythonDomain.find_obj so that references
|
||||
# still work.
|
||||
|
||||
base_find_obj = PythonDomain.find_obj
|
||||
|
||||
|
||||
def find_obj(self, env, modname, classname, name, type, searchmode=0):
|
||||
if modname == 'pybricks.hubs':
|
||||
if classname == 'screen':
|
||||
if name.startswith('Font.') or name == 'Font':
|
||||
modname = 'pybricks.resources'
|
||||
else:
|
||||
classname = 'EV3Brick.screen'
|
||||
return base_find_obj(self, env, modname, classname, name, type, searchmode)
|
||||
|
||||
|
||||
PythonDomain.find_obj = find_obj
|
||||
|
||||
EV3Brick.screen = Image
|
||||
|
||||
+3
-1
@@ -1,11 +1,13 @@
|
||||
"""LEGO® Programmable Hubs."""
|
||||
from enum import Enum
|
||||
from .builtins import Speaker, Display, Battery, ColorLight, KeyPad
|
||||
from .resources import Image
|
||||
|
||||
|
||||
class EV3Brick():
|
||||
class EV3Brick:
|
||||
"""LEGO® MINDSTORMS® EV3 Brick."""
|
||||
Port = Enum('Port', ['A', 'B', 'C', 'D', 'S1', 'S2', 'S3', 'S4'])
|
||||
screen = Image('_screen_')
|
||||
speaker = Speaker()
|
||||
display = Display()
|
||||
battery = Battery()
|
||||
|
||||
@@ -71,7 +71,7 @@ class Image:
|
||||
"""
|
||||
pass
|
||||
|
||||
def draw_box(self, x1, y1, x2, y2, r=0, filled=False, color=Color.BLACK):
|
||||
def draw_box(self, x1, y1, x2, y2, r=0, fill=False, color=Color.BLACK):
|
||||
"""Draws a box on the image.
|
||||
|
||||
Arguments:
|
||||
@@ -80,20 +80,20 @@ class Image:
|
||||
x2 (int): The x coordinate of the right side of the box.
|
||||
y2 (int): The y coordinate of the bottom of the box.
|
||||
r (int): The radius of the corners of the box.
|
||||
filled (bool): If ``True``, the box will be filled with ``color``,
|
||||
fill (bool): If ``True``, the box will be filled with ``color``,
|
||||
otherwise only the outline of the box will be drawn.
|
||||
color (Color): The color of the box.
|
||||
"""
|
||||
pass
|
||||
|
||||
def draw_circle(self, x, y, r=0, filled=False, color=Color.BLACK):
|
||||
def draw_circle(self, x, y, r=0, fill=False, color=Color.BLACK):
|
||||
"""Draws a circle on the image.
|
||||
|
||||
Arguments:
|
||||
x (int): The x coordinate of the center of the circle.
|
||||
y (int): The y coordinate of the center of the circle.
|
||||
r (int): The radius of the circle.
|
||||
filled (bool): If ``True``, the circle will be filled with
|
||||
fill (bool): If ``True``, the circle will be filled with
|
||||
``color``, otherwise only the circumference will be drawn.
|
||||
color (Color): The color of the circle.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user