codeskulptor_lib — some miscellaneous functions¶
(Version saved in CodeSkulptor https://py3.codeskulptor.org/#user305_SXBsmszNiUxIeoV.py .)
codeskulptor_lib module.
Some miscellaneous functions to help in CodeSkulptor.
Piece of SimpleGUICS2Pygame. https://bitbucket.org/OPiMedia/simpleguics2pygame
license: | GPLv3 — Copyright (C) 2013-2014, 2020 Olivier Pirson |
---|---|
author: | Olivier Pirson — http://www.opimedia.be/ |
version: | May 19, 2020 |
-
SimpleGUICS2Pygame.codeskulptor_lib.
__CODESKULPTOR_IS
= None¶ Used to memoization by codeskulptor_is().
-
SimpleGUICS2Pygame.codeskulptor_lib.
__CODESKULPTOR_VERSION
= None¶ Used to memoization by codeskulptor_version().
-
SimpleGUICS2Pygame.codeskulptor_lib.
assert_position
(position, non_negative=False, non_zero=False)[source]¶ Assertions to check valid position.
If non_negative then each int or float must be >= 0.
If non_zero then each int or float must be != 0.
Parameters: - position – (int or float, int or float) or [int or float, int or float]
- 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.
codeskulptor_version
()[source]¶ If run in CodeSkulptor environment then return 2 if CodeSkulptor or 3 if CodeSkulptor3 else return False.
Returns: False, 2 or 3
-
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]