API

Sk.main_canvas

Since the Pygame module relies heavily on the graphics and event handling, we provide several functionalities for
communicating with the module. First and the most important one is registering your canvas. Basically, Pygame module
needs to have a reference to the canvas to be used for rendering graphics. In order to register your canvas, use the following:

Sk.main_canvas = document.createElement("canvas");

or

Sk.main_canvas = document.getElementById("myCanvas");

Sk.insertEvent

Pygame module has mouse and keyboard event listeners added to canvas and window. If you want to have an additional way of
inserting the events (eg. you want to add the arrows that create keydown events) you can use Sk.insertEvent function as follows:

Sk.insertEvent("left");

Currently, the only supported events are:

"up" corresponding to KEYDOWN event with K_UP key.

"down" corresponding to KEYDOWN event with K_DOWN key.

"right" corresponding to KEYDOWN event with K_RIGHT key.

"left" corresponding to KEYDOWN event with K_LEFT key.

"quit" corresponding to QUIT event with K_ESCAPE key.

Sk.title_container

If you want to have an element where the title is going to be shown, make use of the following:

Sk.title_container = ...

Sk.quitHandler

After running the Pygame code, you want to make sure that everything got cleaned up. For that reason, there exists
Sk.quitHandler which gets called by pygame.quit() method. An possible example is:

Sk.quitHandler = function () {
$('.modal').modal('hide');
};

Implemented parts

Most useful stuff:

Color

pygame.Color.r — Gets or sets the red value of the Color.

pygame.Color.g — Gets or sets the green value of the Color.

pygame.Color.b — Gets or sets the blue value of the Color.

pygame.Color.a — Gets or sets the alpha value of the Color.

pygame.Color.cmy — Gets or sets the CMY representation of the Color.

pygame.Color.hsva — Gets or sets the HSVA representation of the Color.

pygame.Color.hsla — Gets or sets the HSLA representation of the Color.

pygame.Color.i1i2i3 — Gets or sets the I1I2I3 representation of the Color.

pygame.Color.normalize — Returns the normalized RGBA values of the Color.

pygame.Color.correct_gamma — Applies a certain gamma value to the Color.

pygame.Color.set_length — Set the number of elements in the Color to 1,2,3, or 4.

display

pygame.display.init — Initialize the display module

pygame.display.quit — Uninitialize the display module

pygame.display.get_init — Returns True if the display module has been initialized

pygame.display.set_mode — Initialize a window or screen for display

pygame.display.get_surface — Get a reference to the currently set display surface

pygame.display.flip — Update the full display Surface to the screen

pygame.display.update — Update portions of the screen for software displays

pygame.display.get_driver — Get the name of the pygame display backend

pygame.display.Info — Create a video display information object

pygame.display.get_wm_info — Get information about the current windowing system

pygame.display.list_modes — Get list of available fullscreen modes

pygame.display.mode_ok — Pick the best color depth for a display mode

pygame.display.gl_get_attribute — Get the value for an OpenGL flag for the current display