跳转到主要内容

适用于displayio的各种常用形状

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

适用于displayio的各种常用形状

依赖关系

此驱动程序依赖于

请确保所有依赖项都可在CircuitPython文件系统中使用。这可以通过下载Adafruit库和驱动程序捆绑包轻松实现。

从PyPI安装

在支持GNU/Linux系统(如Raspberry Pi)上,您可以从PyPI本地安装驱动程序。为当前用户安装

pip3 install adafruit-circuitpython-display_shapes

为系统范围安装(在某些情况下可能需要)

sudo pip3 install adafruit-circuitpython-display_shapes

在当前项目中的虚拟环境中安装

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-display_shapes

使用示例

import board
import displayio
from adafruit_display_shapes.rect import Rect
from adafruit_display_shapes.circle import Circle
from adafruit_display_shapes.arc import Arc
from adafruit_display_shapes.roundrect import RoundRect

splash = displayio.Group()
board.DISPLAY.root_group = splash

color_bitmap = displayio.Bitmap(320, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, position=(0, 0))
print(bg_sprite.position)
splash.append(bg_sprite)

triangle = Triangle(170, 50, 120, 140, 210, 160, fill=0x00FF00, outline=0xFF00FF)
splash.append(triangle)

rect = Rect(80, 20, 41, 41, fill=0x0)
splash.append(rect)

circle = Circle(100, 100, 20, fill=0x00FF00, outline=0xFF00FF)
splash.append(circle)

arc = Arc(x=100, y=100, radius=25, angle=45, direction=90, segments=10, outline=0x00FF00)
splash.append(arc)

rect2 = Rect(50, 100, 61, 81, outline=0x0, stroke=3)
splash.append(rect2)

roundrect = RoundRect(10, 10, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6)
splash.append(roundrect)

while True:
    pass

文档

此库的API文档可在Read the Docs上找到。

有关构建库文档的信息,请参阅本指南

贡献

欢迎贡献!在为该项目做出贡献之前,请阅读我们的行为准则,以帮助保持该项目的友好性。

本地构建

Zip发布文件

要本地构建此库,您需要安装circuitpython-build-tools包。

python3 -m venv .venv
source .venv/bin/activate
pip install circuitpython-build-tools

安装完成后,请确保您处于虚拟环境中

source .venv/bin/activate

然后运行构建

circuitpython-build-bundles --filename_prefix adafruit-circuitpython-display_shapes --library_location .

Sphinx 文档

Sphinx 用于根据 rST 文件和代码中的注释构建文档。首先,安装依赖项(您可以使用上面创建的虚拟环境)

python3 -m venv .venv
source .venv/bin/activate
pip install Sphinx sphinx-rtd-theme

现在,一旦您激活了虚拟环境

cd docs
sphinx-build -E -W -b html . _build/html

这将输出文档到 docs/_build/html。在浏览器中打开 index.html 以查看它们。它还会(由于 -W)在出现任何警告时出错,就像 Travis 一样。这是在本地验证它是否会通过的好方法。

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分发

构建分发

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面