[Microbit-Python] Image class constructors question

Damien George damien.p.george at gmail.com
Wed May 11 17:59:08 EDT 2016


The docs are wrong.  There are 5 constructors:

Image() - return the blank image
Image(chr) - return an image with the character rendered to the image
Image(string) - return an image described by the string (eg 01110:00000 etc)
Image(width, height) - create a blank image of given size
Image(width, height, buffer) - create an image of the given size,
initialsed by the buffer



On Fri, May 6, 2016 at 6:14 PM, Joe Glancy <joe.t.glancy at gmail.com> wrote:
> In the documentation, the image class defines the two following constructors
> (or their equivalent):
>
> classmicrobit.Image(string) classmicrobit.Image(width=None, height=None,
> buffer=None)
>
> Does that not mean that I could initialise a new class:
>
>     img = microbit.Image(foo_variable)
>
> And it could be interpreted as either giving a string or giving a width? Or
> does MicroPython have something that stops this (like checking the type of
> `foo_variable`)? Quote the documentation:
>
> Optionally buffer can be an array of width``×``height integers in range 0-9
> to initialize the image.
>
> So are width and height optional too, or not (so shouldn't have the
> `=None`)? Or can I choose one or the other?
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>


More information about the Microbit mailing list