clojure2d.protocols
Categories
- events: key-pressed? mouse-pressed?
- window: key-pressed? mouse-pressed?
Other vars: add-pixel! alpha alt-down? alt-gr-down? blue bounding-box contains-point? contains-rectangle? control-down? convolve get-channel get-color get-image get-pixel get-value green height intersects-rectangle? key-char key-code key-raw luma meta-down? mouse-button mouse-pos mouse-x mouse-y red resize save set-channel! set-color! set-value! shift-down? subimage to-awt-color to-color to-pixels width
ColorProto
protocol
Basic color operations
members
alpha
(alpha c)Returns alpha value.
luma
(luma c)Returns luma
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
Image Protocol
members
get-image
(get-image i)Return BufferedImage
height
(height i)Height of the image.
resize
(resize i w h)Resize image.
save
(save i n)Save image i to a file n.
subimage
(subimage i x y w h)Return part of the image.
width
(width i)Width of the image.
KeyEventProto
protocol
Access to key event data
members
key-char
(key-char e)Key as char.
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.
meta-down?
(meta-down? e)META 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
Mouse position.
members
PixelsProto
protocol
Functions for accessing and setting channel values or colors. PixelsProto is used in following types:
Pixels- all functionsImage,Canvas,Window- Only get-value and get-color for given position and conversion to Pixels. Accessing color or channel value is slow.Log density renderer- Only set-color!, get-color and conversion to Pixels.
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)