Skip to content

Commit 812fa2b

Browse files
committed
change docstring, add example code.
1 parent e474df3 commit 812fa2b

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

shared-bindings/bitmaptools/__init__.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,43 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_line_obj, 0, bitmaptools_obj_draw_li
532532
//| """Draw a polygon conecting points on provided bitmap with provided value
533533
//|
534534
//| :param bitmap dest_bitmap: Destination bitmap that will be written into
535-
//| :param int xs: x-pixel position of the polygon's vertices
536-
//| :param int ys: y-pixel position of the polygon's vertices
535+
//| :param ReadableBuffer xs: x-pixel position of the polygon's vertices
536+
//| :param ReadableBuffer ys: y-pixel position of the polygon's vertices
537537
//| :param int value: Bitmap palette index that will be written into the
538538
//| line in the destination bitmap
539539
//| :param bool close: (Optional) Wether to connect first and last point. (True)
540+
//|
541+
//| .. code-block:: Python
542+
//|
543+
//| import board
544+
//| import displayio
545+
//| import bitmaptools
546+
//|
547+
//| display = board.DISPLAY
548+
//| main_group = displayio.Group()
549+
//| display.root_group = main_group
550+
//|
551+
//| palette = displayio.Palette(3)
552+
//| palette[0] = 0xffffff
553+
//| palette[1] = 0x0000ff
554+
//| palette[2] = 0xff0000
555+
//|
556+
//| bmp = displayio.Bitmap(128,128, 3)
557+
//| bmp.fill(0)
558+
//|
559+
//| xs = bytes([4, 101, 101, 19])
560+
//| ys = bytes([4, 19, 121, 101])
561+
//| bitmaptools.draw_polygon(bmp, xs, ys, 1)
562+
//|
563+
//| xs = bytes([14, 60, 110])
564+
//| ys = bytes([14, 24, 90])
565+
//| bitmaptools.draw_polygon(bmp, xs, ys, 2)
566+
//|
567+
//| tilegrid = displayio.TileGrid(bitmap=bmp, pixel_shader=palette)
568+
//| main_group.append(tilegrid)
569+
//|
570+
//| while True:
571+
//| pass
540572
//| """
541573
//| ...
542574
//|

0 commit comments

Comments
 (0)