MICILE EZ_Graphics Documentation
version: 0.9
A few notes about our documentation:
  • The intentions of this documentation are to keep things simple.
  • Please see the examples at the end of each section for concrete examples of how to use each function.
  • If in doubt how to use a function, experiment!
  • We don't believe in writing more words just to make the documentation look more substantial
  • Quick Reference
    Function List
    Compatible Devices
    LCD Screen built into every tablet

    * Please contact us for information on adding support for a device.


    Drawing Functions
    draw_circle(x, y, r, [color])
    Draws the outline of a circle with center at coordinates (x, y) and a radius of r in the current color.

    An optional parameter color can be specified which will be the color the circle is drawn in.
    fill_circle(x, y, r, [fill_color], [border_color])
    Draws a filled circle with center at coordinates (x, y) and a radius of r in the current color.

    An optional parameter fill_color can be specified which will be the color the circle is filled with.
    An optional parameter border_color can be specified which will cause a border to be drawn around the circle in the specified border color.
    draw_ellipse(left, top, width, height, [color])
    Draws an ellipse bounded by an imaginary rectangle with upper left coordinate at (left, top) and with the specified width and height in the current color.

    An optional parameter color can be specified which will be the color the ellipse is drawn in.
    fill_ellipse(left, top, width, height, [fill_color], [border_color])
    Draws a filled ellipse bounded by an imaginary rectangle with upper left coordinate at (left, top) and with the specified width and height in the current color.

    An optional parameter fill_color can be specified which will be the color the ellipse is filled with.
    An optional parameter border_color can be specified which will cause a border to be drawn around the ellipse in the specified border color.
    draw_line(x1, y1, x2, y2, [color])
    Draws a line from coordinates (x1, y1) to (x2, y2) in the current color.

    An optional parameter color can be specified which will be the color the line is drawn in.
    draw_rect(left, top, width, height, [color])
    Draws the outline of a rectangle with upper left coordinate at (left, top) and with specified width and height in the current color.

    An optional parameter color can be specified which will be the color the rectangle is drawn in.
    fill_rect(left, top, width, height, [color], [border_color])
    Draws a filled rectangle with upper left coordinate at (left, top) and with specified width and height in the current color.

    An optional parameter fill_color can be specified which will be the color the rectangle is filled with.
    An optional parameter border_color can be specified which will cause a border to be drawn around the rectangle in the specified border color.
    get_color()
    Returns the current color.
    The color is returned as a 24 bit color in the format RGB format.
    To extract the red, green, and blue components out you can use the following code:
    c     = get_color()
    red   = (c >> 16) & 255
    green = (c >>  8) & 255
    blue  = (c >>  0) & 255
     
    get_pixel_color(x, y)
    Returns the color of the pixel on the screen located at the coordinates specified by x and y.
    The color is returned as a 24 bit color in the format RGB format.
    To extract the red, green, and blue components out you can use the following code:
    c     = get_pixel_color(100100)
    red   = (c >> 16) & 255
    green = (c >>  8) & 255
    blue  = (c >>  0) & 255
     
    get_screen_height()
    Returns the height of the screen in pixels.
    get_screen_width()
    Returns the width of the screen in pixels.
    set_color(color)
    Sets the new current drawing color. color should be the name of a color as defined in the color table at the bottom of this page or color can be a 24 bit number specifying a color where the lowest 8 bits are the blue component, next 8 bits are the green component, and the next 8 bits are the red component.
    set_color(red, green, blue)
    Sets the new current drawing color by expliticly setting the red, green, and blue components. The ranges of the color components can be from 0 to 255. For example to set a yellow color you would use set_color(255, 255, 0) since red and green light mixed together make yellow.
    draw_arc(left, top, width, height ,starta, enda, [color])
    Draws an arc based on a partial ellipse. The ellipse is bounded an imaginary rectangle with upper left coordinate at (left, top) and with the specified width and height. starta and enda specify the starting angle and ending angle of the arc to draw in degrees. The starta angle must be less than the enda angle, but the angles can be greater than 360 degrees. For example a starta angle of 270 degrees and an enda angle of 405 degrees.

    An optional parameter color can be specified which will be the color the line is drawn in.
    Warning! Drawing outside the bounds of the screen will cause your program to crash!
    It is the programmers responsibility to not draw at x or y coordinates less than zero or greater than the width or height of the screen!
    # --------------------------------------------------
    # drawing_demo.py
    # --------------------------------------------------
     
    # import the ez_graphics libary v0.9
    from ez_graphics_09 import * 
     
    # clear the screen by drawing a big black filled rectangle
    clear_screen('black')
     
    # draw a red circle outline and a filled circle next to it
    set_color('red')
    draw_circle(1505020)
    fill_circle(2005020)
     
    # draw a yellow ellipse outline and a filled ellipse next to it
    # set the color by specifying RGB
    set_color(2552550)
    draw_ellipse(250308040)
    fill_ellipse(350308040)
     
    # draw a blue rectangle outline and a filled rectangle next to it
    set_color('blue')
    draw_rect(450308040)
    fill_rect(550308040)
     
    # draw a diagonal line across the screen
    # specify the color by using a long
    set_color(0x8080)
    draw_line(00799479)
     
    # draw some arcs
    set_color('white')
    draw_arc(501001001000270)
    draw_arc(50225100100270405)
    draw_arc(50350100100-9090)

    Screen Shot
    Text Functions
    draw_text(text, x, y,[color])
    Draws the text at coordinates (x, y).

    An optional parameter color can be specified which will be the color the line is drawn in.
    get_text_height(text) {
    Returns the height of the text if it were drawn.
    get_text_width(text) {
    Returns the width of the text if it were drawn.
    set_text_alignment(alignment) {
    Changes the reference point when drawing text.

    alignment values are one of the following:
    LEFT_TOP, LEFT_CENTER, LEFT_BOTTOM, CENTER_TOP, CENTER_CENTER, CENTER_BOTTOM, RIGHT_TOP, RIGHT_CENTER, RIGHT_BOTTOM
    from ez_graphics_09 import *
     
    set_color('black')
    fill_rect(00800480)
    set_color('white')
    set_text_size(20)
    set_text_alignment(CENTER_BOTTOM)
    draw_text('ABCD'400240)
    set_text_alignment(CENTER_TOP)
    draw_text('EFGH'400240)
    set_text_size(size) {
    Changes the size of the text to be drawn.
    init_text_window(window_number, top, left, width, height, text_color, background_color) {
    Initializes a text window to be used with print_text_to_text_window.

    The window_number parameter must be between 0 and 15, which gives a total of 16 available text windows.

    The text window will be drawn as a rect with bounds of top, left, width, and height with a background of
    the color specified in background_color and a border and text of the color specified by text_color.
    print_text_in_text_window(window_number, text, [color]) {
    Prints the text specified by text to a text window previously initialized with a call to init_text_window.

    The window_number parameter must be between 0 and 15, which gives a total of 16 available text windows.

    The text printed should fit within the width of the text window

    Text will be printed on the next available line, and if no room is left at the bottom of the text window, the window will scroll.
    Warning! Drawing outside the bounds of the screen will cause your program to crash!
    It is the programmers responsibility to not draw at x or y coordinates less than zero or greater than the width or height of the screen!
    # --------------------------------------------------
    # text_demo.py
    # --------------------------------------------------
     
    # import the ez_graphics libary v0.9
    from ez_graphics_09 import * 
     
    # clear teh screen
    clear_screen('black')
     
    # draw some text at different sizes
    set_color('white')
    set_text_size(10)
    draw_text('Size 10'10100)
    set_text_size(20)
    draw_text('Size 20'10150)
     
    # Center some text by measuring it
    set_text_size(40)
    w = get_text_width('ABCDDCBA')
    h = get_text_height('ABCDDCBA')
    draw_text('ABCDDCBA'(800 - w) / 2(480 + h) / 2) # 800 x 480 screen
     
    # Draw some centering lines
    draw_line(0240799240)
    draw_line(4000400479)

    Screen Shot
    Image Functions
    load_image(filename)
    Returns an image loaded from a jpg file.
    resize_image(image, new_width, new_height)
    Returns a new resized image of the specified with and height.
    save_image(image, filename)
    Saves the image to the filename given in jpg format
    extract_image(image, left, top, width, height)
    Creates a new image which is a cropped version of the original image passed in by the image parameter.
    The bounding rectangle of the cropping is defined by the left, top, width, and height parameters.
    This cropped image is returned by this function.
    Warning! Drawing outside the bounds of the screen will cause your program to crash!
    It is the programmers responsibility to not draw at x or y coordinates less than zero or greater than the width or height of the screen!

    You will need to upload the F-15.jpg image to your project in order for this demo to work.
    You can download the F-15.jpg image from
    here.
    Make sure to right click on the link and select "save as" and then upload the file to your project.
    # --------------------------------------------------
    # image_demo.py
    # --------------------------------------------------
     
    # import the ez_graphics libary v0.9
    from ez_graphics_09 import * 
     
    # clear the screen
    clear_screen('black')
     
    # draw a jet fighter
    image = load_image('F-15.jpg')
    draw_image(image00)
     
    # resize the picture to half it's original size
    w = get_image_width(image)
    h = get_image_height(image)
    small_image = resize_image(imagew / 2h / 2)
     
    # draw the small picture
    draw_image(small_image450200)
     
    # capture a small section of the screen
    img = capture_image(300100100100)
     
    # draw the captured image
    draw_image(img50050)

    Screen Shot
    Color Table
         aliceblue      darkorange      khaki      mediumspringgreen      saddlebrown
         antiquewhite      darkorchid      lavender      mediumturquoise      salmon
         aqua      darkred      lavenderblush      mediumvioletred      sandybrown
         aquamarine      darksalmon      lawngreen      midnightblue      seagreen
         azure      darkseagreen      lemonchiffon      mintcream      seashell
         beige      darkslateblue      lightblue      mistyrose      sienna
         bisque      darkslategray      lightcoral      moccasin      silver
         black      darkturquoise      lightcyan      navajowhite      skyblue
         blanchedalmond      darkviolet      lightgoldenrodyellow      navy      slateblue
         blue      deeppink      lightgreen      oldlace      slategray
         blueviolet      deepskyblue      lightgrey      olive      snow
         brown      dimgray      lightpink      olivedrab      springgreen
         burlywood      dodgerblue      lightsalmon      orange      steelblue
         cadetblue      firebrick      lightseagreen      orangered      tan
         chartreuse      floralwhite      lightskyblue      orchid      teal
         chocolate      forestgreen      lightslategray      palegoldenrod      thistle
         coral      fuchsia      lightsteelblue      palegreen      tomato
         cornflowerblue      gainsboro      lightyellow      paleturquoise      turquoise
         cornsilk      ghostwhite      lime      palevioletred      violet
         crimson      gold      limegreen      papayawhip      wheat
         cyan      goldenrod      linen      peachpuff      white
         darkblue      gray      magenta      peru      whitesmoke
         darkcyan      green      maroon      pink      yellow
         darkgoldenrod      greenyellow      mediumaquamarine      plum      yellowgreen
         darkgray      honeydew      mediumblue      powderblue
         darkgreen      hotpink      mediumorchid      purple
         darkkhaki      indianred      mediumpurple      red
         darkmagenta      indigo      mediumseagreen      rosybrown
         darkolivegreen      ivory      mediumslateblue      royalblue