structColor
struct Color
red: float
green: float
blue: float
alpha: float
endgfx: 2D drawing in a window, with OpenGL 3.3. use "gfx.jamo"
Shapes, text and pictures collect in a batch and go to the graphics card together. Everything draws into a picture the size of the window first, which show() copies onto the window. Rectangles, circles, lines and text all come from one texture, the atlas, so they can share a batch: letters from the Segoe UI font fill the top in cells 40 wide and 48 tall, with a soft circle and a white square below them. Each letter starts 4 pixels down its cell, so its lowest parts stay clear of the letter below when text is drawn small.
struct Color
red: float
green: float
blue: float
alpha: float
endfunc rgb(red: int, green: int, blue: int): Color
Colors take numbers from 0 to 255, like most paint programs
func rgba(red: int, green: int, blue: int, alpha: int): Color
struct Image
texture: int
width: int
height: int
open: bool
endstruct Gfx
window: Window
dc: int
context: int
shader: int
screen_place: int
vertex_array: int
vertex_buffer: int
atlas: int
glyph_widths: int
batch: int
vertices: int
texture: int
framebuffer: int
color_buffer: int
depth_buffer: int
in_3d: bool
width: int
height: int
images: [Image]
open: bool
closed_by_program: bool
endfunc start_gfx(window: Window): Gfx
func gfx_c_text(text: string): int
--- Setting up ---
func gfx_compile(kind: int, source: string): int
func Gfx.make_shader()
func Gfx.make_buffers()
func gfx_texture(pixels: int, width: int, height: int, smooth: bool): int
func Gfx.make_atlas()
Windows draws each letter once, white on black, and the red of each pixel becomes how solid it is
func Gfx.fit_window()
Makes the drawing picture match the window's size
func Gfx.must_be_open()
--- The batch ---
func Gfx.flush()
func Gfx.vertex(x: float, y: float, u: float, v: float, color: Color)
func Gfx.back_to_2d()
3D drawing (g3d.jamo) changes OpenGL's settings, so 2D drawing puts its own back first
func Gfx.use_texture(texture: int)
func Gfx.quad(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, x4: float, y4: float, u1: float, v1: float, u2: float, v2: float, color: Color)
Four corners, going around, with the texture's corners matching
func Gfx.clear(color: Color)
--- Drawing ---
func Gfx.rect(x: float, y: float, width: float, height: float, color: Color)
func Gfx.circle(x: float, y: float, radius: float, color: Color)
func Gfx.line(x1: float, y1: float, x2: float, y2: float, thickness: float, color: Color)
func Gfx.text_width(words: string, size: float): float
func Gfx.text(words: string, x: float, y: float, size: float, color: Color)
size is the letters' height in pixels. Only English letters and symbols show
func Gfx.load_image(path: string): Image
func Gfx.image(image: Image, x: float, y: float)
func Gfx.image_sized(image: Image, x: float, y: float, width: float, height: float)
func Gfx.load_pixel_image(path: string): Image
Like load_image, but each pixel stays a sharp square when it's drawn bigger, which pixel art wants
func Gfx.image_from_text(rows: [string], colors: [Color]): Image
Pixel art written as text, one row of letters per line, all the same length. 0 to 9 and then a to z pick a color from colors, in order, and . or a space is see-through. The pixels stay sharp when drawn bigger:
var heart = screen.image_from_text([".11.11.", "1111111", ".11111.", "..111.."], [rgb(230, 50, 70)])
func gfx_byte(value: float): int
func Gfx.image_part(image: Image, part_x: int, part_y: int, part_width: int, part_height: int, x: float, y: float, width: float, height: float)
Draws the part of an image from (part_x, part_y), part_width by part_height pixels, at x, y and width by height. A sprite sheet keeps many frames in one image this way
func Gfx.image_part_turned(image: Image, part_x: int, part_y: int, part_width: int, part_height: int, center_x: float, center_y: float, width: float, height: float, angle: float, flipped: bool)
Like image_part, but around its middle at center_x, center_y, turned by angle (in radians, clockwise on the screen), and mirrored left to right when flipped is true, for something that faces the other way
func Gfx.image_turned(image: Image, center_x: float, center_y: float, width: float, height: float, angle: float, flipped: bool)
The whole image around its middle, turned and maybe mirrored
func Image.close()
func Gfx.show()
Puts this frame on the window
func Gfx.read_pixel(x: int, y: int): Color
func Gfx.save_bmp(path: string)
Saves what's drawn so far as a BMP picture
func Gfx.close()