Basics - Serabe/rinzelight GitHub Wiki

What you should know first

Image struct

Image struct has four fields.

  • :image holds the BufferedImage.
  • :format holds a String identifying the current format of the image.
  • :width holds the width of the image. It is taken in first place from BufferedImage.getWidth().
  • :height holds the height of the image. It is taken in first place from BufferedImage.getHeight().

BufferedImage image type.

The image in any rinzelight image struct is assured to be of BufferedImage/TYPE_INT_ARGB. Take this into account when working with them.

Basic features.

Reading an image.

read-image multimethod in rinzelight.image namespace accepts both a String and an InputStream.

If a String is provided, it is taken as the path to the image.

Example
(read-image "samples/clojure.png")

Writing an image.

write-image multimethod in rinzelight.image namespace writes an image img to uri.

Example
(def img (read-image "samples/clojure.png"))
(write-image img "samples/clojure.jpg")

Note that it would write the image in jpg format, not png.

Displaying an image.

display-image function in rinzelight.image displays img on a JFrame.

Example
(def img (read-image "samples/clojure.png"))
(display-image img)

Cloning an image.

clone-image method retrieves a new image struct with the :image field set to a cloned BufferedImage.

Example
(def img (read-image "samples/clojure.png"))
(def img-cloned (clone-image img))

Constants

Moved to constants

Basic methods for creating your own effect.

You can find get-image-for-effect in rinzelight.effects.basic-effects. Given an image returns a new image struct with an empty BufferedImage in :image. Width and height parameters are optional.

If you are only composing effects, don’t bother about get-image-for-effect, since every effect in rinzelight creates a new image. This is so because of two reasons:

  1. Clojure way is not to modify objects.
  2. Not all effects can be made in place.
⚠️ **GitHub.com Fallback** ⚠️