clojure2d.protocols documentation (original) (raw)

ColorProto

protocol

members

blue

(blue c)

Returns blue (third channel) value. See also ch2.

green

(green c)

Returns green (second channel) value. See also ch1.

red

(red c)

Returns red (first channel) value. See also ch0.

to-awt-color

(to-awt-color c)

Convert any color representation to java.awt.Color.

to-color

(to-color c)

Convert any color representation to Vec4 vector.

ImageProto

protocol

members

save

(save i n)

Save image i to a file n.

subimage

(subimage i x y w h)

Return part of the image.

KeyEventProto

protocol

members

key-code

(key-code e)

Keycode mapped to keyword. See java.awt.event.KeyEvent documentation. Eg. VK_LEFT is mapped to :left.

key-raw

(key-raw e)

Raw value for pressed key (as integer).

ModifiersProto

protocol

Get state of keyboard modifiers.

members

alt-down?

(alt-down? e)

ALT key state as boolean.

alt-gr-down?

(alt-gr-down? e)

ALT-GR key state as boolean.

control-down?

(control-down? e)

CONTROL key state as boolean.

shift-down?

(shift-down? e)

SHIFT key state as boolean.

MouseButtonProto

protocol

Get pressed mouse button status.

members

mouse-button

(mouse-button m)

Get mouse pressed button status: :left :right :center or :none

MouseXYProto

protocol

members

mouse-pos

(mouse-pos m)

Mouse position as Vec2 type. <0,0> - top left, <-1,-1> outside window.

mouse-x

(mouse-x m)

Mouse horizontal position within window. 0 - left side. -1 outside window.

mouse-y

(mouse-y m)

Mouse vertical position. 0 - top, -1 outside window.

PixelsProto

protocol

Functions for accessing and setting channel values or colors. PixelsProto is used in following types:

members

get-channel

(get-channel pixels ch)

Return whole ints array with chosen channel

get-color

(get-color pixels x y) (get-color pixels idx)

Get color by index or position. In case of low density rendering returns current average color without alpha value.

get-value

(get-value pixels ch x y) (get-value pixels ch idx)

Get channel value by index or position.

set-channel!

(set-channel! pixels ch v)

Set whole channel (as ints array)

set-color!

(set-color! pixels x y v) (set-color! pixels idx v)

Set color value by index or position.

set-value!

(set-value! pixels ch x y v) (set-value! pixels ch idx v)

Set channel value by index or position

to-pixels

(to-pixels pixels) (to-pixels pixels cfg) (to-pixels pixels x y w h)

Convert to Pixels. For low density rendering provide configuration. Works with Image/Canvas/Window and low density renderer.

PressedProto

protocol

Key or mouse pressed status.

members

key-pressed?

(key-pressed? w)

Any key pressed? (boolean)

mouse-pressed?

(mouse-pressed? w)

Any mouse button pressed? (boolean)

RendererProto

protocol

members

add-pixel!

(add-pixel! r x y) (add-pixel! r x y c)

get-pixel

(get-pixel r x y)

ShapeProto

protocol

members

bounding-box

(bounding-box shape)

contains-point?

(contains-point? shape x y)

contains-rectangle?

(contains-rectangle? shape x y w h)

intersects-rectangle?

(intersects-rectangle? shape x y w h)