codeskulptor_lib — some miscellaneous functions

(Version saved in CodeSkulptor http://www.codeskulptor.org/#user38_ZmhOVHGm2lhVRhk.py .)

codeskulptor_lib (October 4, 2014)

Some miscellaneous functions to help in CodeSkulptor.

Piece of SimpleGUICS2Pygame. https://bitbucket.org/OPiMedia/simpleguics2pygame

GPLv3 — Copyright (C) 2013, 2014 Olivier Pirson http://www.opimedia.be/

SimpleGUICS2Pygame.codeskulptor_lib.assert_position(position, non_negative=False, non_zero=False)[source]

Assertions to check valid position: (int or float, int or float) or [int or float, int or float].

If non_negative then each int or float must be >= 0.

If non_zero then each int or float must be != 0.

Parameters:
  • position – object
  • non_negative – bool
SimpleGUICS2Pygame.codeskulptor_lib.codeskulptor_is()[source]

If run in CodeSkulptor environment then return True, else return False.

Returns:bool
SimpleGUICS2Pygame.codeskulptor_lib.hex2(n, uppercase=True)[source]

Return 2 characters corresponding to the hexadecimal representation of n.

Parameters:
  • n – 0 <= int < 256
  • uppercase – bool
Returns:

str (length == 2)

SimpleGUICS2Pygame.codeskulptor_lib.hex_fig(n, uppercase=True)[source]

Return the hexadecimal figure of n.

Parameters:
  • n – 0 <= int < 16
  • uppercase – bool
Returns:

str (one character from 0123456789ABCDEF or 0123456789abcdef)

SimpleGUICS2Pygame.codeskulptor_lib.hsl(hue, saturation, lightness)[source]

Return the string HTML representation of the color in ‘hsl(hue, lightness, saturation)’ format.

Parameters:
  • hue – float or int
  • saturation – 0 <= float or int <= 100
  • lightness – 0 <= float or int <= 100
Returns:

str

SimpleGUICS2Pygame.codeskulptor_lib.hsla(hue, saturation, lightness, alpha=1)[source]

Return the string HTML representation of the color in ‘hsla(hue, lightness, saturation, alpha)’ format.

Parameters:
  • hue – float or int
  • saturation – 0 <= float or int <= 100
  • lightness – 0 <= float or int <= 100
  • alpha – 0 <= float or int <= 1
Returns:

str

SimpleGUICS2Pygame.codeskulptor_lib.rgb(red, green, blue)[source]

Return the string HTML representation of the color in ‘rgb(red, blue, green)’ format.

Parameters:
  • red – 0 <= int <= 255
  • green – 0 <= int <= 255
  • blue – 0 <= int <= 255
Returns:

str

SimpleGUICS2Pygame.codeskulptor_lib.rgba(red, green, blue, alpha=1)[source]

Return the string HTML representation of the color in ‘rgba(red, blue, green, alpha)’ format.

Parameters:
  • red – 0 <= int <= 255
  • green – 0 <= int <= 255
  • blue – 0 <= int <= 255
  • alpha – 0 <= float or int <= 1
Returns:

str

[source]