/ README.rst
README.rst
1 Introduction 2 ============ 3 4 .. image:: https://readthedocs.org/projects/adafruit-circuitpython-display_shapes/badge/?version=latest 5 :target: https://circuitpython.readthedocs.io/projects/display_shapes/en/latest/ 6 :alt: Documentation Status 7 8 .. image:: https://img.shields.io/discord/327254708534116352.svg 9 :target: https://discord.gg/nBQh6qu 10 :alt: Discord 11 12 .. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_Display_Shapes.svg?branch=master 13 :target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_Display_Shapes 14 :alt: Build Status 15 16 Various common shapes for use with displayio 17 18 19 Dependencies 20 ============= 21 This driver depends on: 22 23 * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ 24 25 Please ensure all dependencies are available on the CircuitPython filesystem. 26 This is easily achieved by downloading 27 `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. 28 29 Installing from PyPI 30 -------------------- 31 On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 32 PyPI <https://pypi.org/project/adafruit-circuitpython-display_shapes/>`_. To install for current user: 33 34 .. code-block:: shell 35 36 pip3 install adafruit-circuitpython-display_shapes 37 38 To install system-wide (this may be required in some cases): 39 40 .. code-block:: shell 41 42 sudo pip3 install adafruit-circuitpython-display_shapes 43 44 To install in a virtual environment in your current project: 45 46 .. code-block:: shell 47 48 mkdir project-name && cd project-name 49 python3 -m venv .env 50 source .env/bin/activate 51 pip3 install adafruit-circuitpython-display_shapes 52 53 Usage Example 54 ============= 55 56 ..code-block:: python 57 58 import board 59 import displayio 60 from adafruit_display_shapes.rect import Rect 61 from adafruit_display_shapes.circle import Circle 62 from adafruit_display_shapes.roundrect import RoundRect 63 64 splash = displayio.Group(max_size=10) 65 board.DISPLAY.show(splash) 66 67 color_bitmap = displayio.Bitmap(320, 240, 1) 68 color_palette = displayio.Palette(1) 69 color_palette[0] = 0xFFFFFF 70 bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, position=(0, 0)) 71 print(bg_sprite.position) 72 splash.append(bg_sprite) 73 74 rect = Rect(80, 20, 41, 41, fill=0x0) 75 splash.append(rect) 76 77 circle = Circle(100, 100, 20, fill=0x00FF00, outline=0xFF00FF) 78 splash.append(circle) 79 80 rect2 = Rect(50, 100, 61, 81, outline=0x0, stroke=3) 81 splash.append(rect2) 82 83 roundrect = RoundRect(10, 10, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6) 84 splash.append(roundrect) 85 86 while True: 87 pass 88 89 90 Contributing 91 ============ 92 93 Contributions are welcome! Please read our `Code of Conduct 94 <https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes/blob/master/CODE_OF_CONDUCT.md>`_ 95 before contributing to help this project stay welcoming. 96 97 Building locally 98 ================ 99 100 Zip release files 101 ----------------- 102 103 To build this library locally you'll need to install the 104 `circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package. 105 106 .. code-block:: shell 107 108 python3 -m venv .env 109 source .env/bin/activate 110 pip install circuitpython-build-tools 111 112 Once installed, make sure you are in the virtual environment: 113 114 .. code-block:: shell 115 116 source .env/bin/activate 117 118 Then run the build: 119 120 .. code-block:: shell 121 122 circuitpython-build-bundles --filename_prefix adafruit-circuitpython-display_shapes --library_location . 123 124 Sphinx documentation 125 ----------------------- 126 127 Sphinx is used to build the documentation based on rST files and comments in the code. First, 128 install dependencies (feel free to reuse the virtual environment from above): 129 130 .. code-block:: shell 131 132 python3 -m venv .env 133 source .env/bin/activate 134 pip install Sphinx sphinx-rtd-theme 135 136 Now, once you have the virtual environment activated: 137 138 .. code-block:: shell 139 140 cd docs 141 sphinx-build -E -W -b html . _build/html 142 143 This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to 144 view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to 145 locally verify it will pass.