Skip to content

Commit 49fb71a

Browse files
author
Thomas Preston
committed
Updated docs to fully cover Sprite functions
1 parent 4979f59 commit 49fb71a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

docs/example.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,45 @@ You can use the sprites library to quickly draw things on CodeBug's display.
6767
>>> # move it along
6868
>>> codebug.draw_sprite(-2, 0, message)
6969

70+
You can do some more interesting things with Sprites::
71+
72+
>>> import codebug_tether.sprites
73+
74+
>>> sprite = codebug_tether.sprites.Sprite(10, 10)
75+
76+
>>> # basic gets and sets
77+
>>> sprite.set_pixel(0, 0, 1)
78+
>>> sprite.get_pixel(0, 0)
79+
1
80+
>>> sprite.set_row(0, 0, 0b1111111111)
81+
>>> sprite.get_row(0)
82+
1023
83+
>>> sprite.set_col(0, 0, 0b1111111111)
84+
>>> sprite.get_col(0)
85+
1023
86+
87+
>>> # transform the sprite
88+
>>> sprite.invert_horizontal()
89+
>>> sprite.invert_vertical()
90+
>>> sprite.invert_diagonal()
91+
>>> sprite.rotate90()
92+
>>> sprite.rotate90(rotation=2) # rotate 180 degrees
93+
94+
>>> # clone or extract parts of the sprite
95+
>>> dolly_sprite = sprite.clone()
96+
>>> rectangle = sprite.get_sprite(3, 3, 5, 2)
97+
98+
>>> # draw other sprites
99+
>>> sprite.render_sprite(1, 1, rectangle)
100+
101+
You can also change the direction text is written in::
102+
103+
>>> from codebug_tether.sprites import StringSprite
104+
>>> left_to_right_msg = StringSprite('Hello CodeBug!')
105+
>>> right_to_left_msg = StringSprite('Hello CodeBug!', direction='L')
106+
>>> top_to_bottom_msg = StringSprite('Hello CodeBug!', direction='D')
107+
>>> bottom_to_top_msg = StringSprite('Hello CodeBug!', direction='U')
108+
70109

71110
Colour Tail
72111
===========

0 commit comments

Comments
 (0)