membrane.skia
draw-to-image!
(draw-to-image! path elem)
(draw-to-image! path elem [w h :as size])
(draw-to-image! path elem [w h :as size] image-format quality clear?)
DEPRECATED: use save-image
instead.
Creates an image of elem. Returns true on success, false otherwise.
path
: the filename to write the image to
elem
: the graphical element to draw
size
: the width and height of the image. If size is nil, the bounds and origin of elem will be used.
image-format
: The image format to use. Should be one of
:membrane.skia/image-format-jpeg
:membrane.skia/image-format-png
:membrane.skia/image-format-webp
if image-format
is nil, then it will be guessed based on the path's file extension.
quality
: specifies the image quality to use for lossy image formats like jpeg. defaults to 100
clear?
: Specifies if the canvas should be cleared before drawing. defaults to true.
note: draw-to-image!
does not take into account the content scale of your monitor. ie. if you
have a retina display, the image will be lower resolution. if you'd like the same resolution
as your retina display, you can do use scale
like the following:
(skia/draw-to-image! "out@2x.png" (ui/scale 2 2 (ui/label "hello world")))
ImageFactory
protocol
gets or creates an opengl image texture given some various types
members
get-image-texture
(get-image-texture x)
IWindow
protocol
members
cleanup!
(cleanup! _)
init!
(init! _)
repaint!
(repaint! _)
reshape!
(reshape! _ width height)
should-close?
(should-close? _)
kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
logical-font->font-family
(logical-font->font-family logical-font)
Returns the font family for the given logical-font
.
logical-font
: should be one of :monospace :serif :sans-serif
run
(run view-fn)
(run view-fn {:keys [window-start-width window-start-height window-start-x window-start-y handlers], :as options})
Open a window and call view-fn
to draw. Returns a channel that is closed when the window is closed.
view-fn
should be a 0 argument function that returns an object satisfying IDraw
.
view-fn
will be called for every repaint. Repaints occur on every event. You can also trigger a repaint by calling glfw-post-empty-event
.
options
is a map that can contain the following keys
Optional parameters
window-start-width
: the starting width of the window
window-start-height
: the starting height of the window
note: The window may be resized.
window-start-x
: the starting x coordinate of the top left corner of the window
window-start-y
: the starting y coordinate of the top left corner of the window
note: The window may be moved.
handlers
: A map of callback backs for glfw events
The events correspond to the available glfw events. If no handlers
map is provided, then the defaults are used.
If a handlers key is provided, it does not replace the defaults, but get merged into the defaults.
available handler events :key args are window window-handle key scancode action mods. default is -key-callback. :char args are window window-handle codepoint. default is -character-callback. :mouse-button args are window window-handle button action mods. default is -mouse-button-callback. :reshape args are window window-handle width height. default is -reshape. :scroll args are window window-handle offset-x offset-y. default is -scroll-callback. :refresh args are window window-handle. default is -window-refresh-callback. :cursor args are window window-handle x y. default is -cursor-pos-callback.
For each handler, window
is the GlfwSkiaWindow and window-handle is a jna pointer to the glfw pointer.
run-sync
(run-sync view-fn)
(run-sync view-fn {:keys [window-start-width window-start-height window-start-x window-start-y handlers], :as options})
Open a window and call view-fn
to draw. Returns when the window is closed.
view-fn
should be a 0 argument function that returns an object satisfying IDraw
.
view-fn
will be called for every repaint. Repaints occur on every event. You can also trigger a repaint by calling glfw-post-empty-event
.
options
is a map that can contain the following keys
Optional parameters
window-start-width
: the starting width of the window
window-start-height
: the starting height of the window
note: The window may be resized.
window-start-x
: the starting x coordinate of the top left corner of the window
window-start-y
: the starting y coordinate of the top left corner of the window
note: The window may be moved.
handlers
: A map of callback backs for glfw events
The events correspond to the available glfw events. If no handlers
map is provided, then the defaults are used.
If a handlers key is provided, it does not replace the defaults, but get merged into the defaults.
available handler events :key args are window window-handle key scancode action mods. default is -key-callback. :char args are window window-handle codepoint. default is -character-callback. :mouse-button args are window window-handle button action mods. default is -mouse-button-callback. :reshape args are window window-handle width height. default is -reshape. :scroll args are window window-handle offset-x offset-y. default is -scroll-callback. :refresh args are window window-handle. default is -window-refresh-callback. :cursor args are window window-handle x y. default is -cursor-pos-callback. :mouse-enter args are window window-handle entered. default is -mouse-enter-callback. :window-close args are window window-handle. default is -window-close-callback.
For each handler, window
is the GlfwSkiaWindow and window-handle is a jna pointer to the glfw pointer.
save-image
(save-image dest elem)
(save-image dest elem [w h :as size])
(save-image dest elem [w h :as size] image-format quality clear?)
Creates an image of elem. Returns true on success, false otherwise.
dest
: the filename to write the image to
elem
: the graphical element to draw
size
: the width and height of the image. If size is nil, the bounds and origin of elem will be used.
image-format
: The image format to use. Should be one of
:membrane.skia/image-format-jpeg
:membrane.skia/image-format-png
:membrane.skia/image-format-webp
if image-format
is nil, then it will be guessed based on the dest's file extension.
quality
: specifies the image quality to use for lossy image formats like jpeg. defaults to 100
clear?
: Specifies if the canvas should be cleared before drawing. defaults to true.
note: save-image
does not take into account the content scale of your monitor. ie. if you
have a retina display, the image will be lower resolution. if you'd like the same resolution
as your retina display, you can do use scale
like the following:
(skia/save-image "out@2x.png" (ui/scale 2 2 (ui/label "hello world")))
svg
(svg svg)
Displays an svg element.
svg
can be a string representation, a java.io.File, or a utf8-encoded byte array.
SVGFactory
protocol
gets or creates an opengl image texture given some various types
members
get-svg-dom
(get-svg-dom x)