ronin/WORKSHOP.md
2019-07-25 13:44:28 +09:00

2.3 KiB

Workshop

This workshop is designed to go over the most commonly used functions with Ronin. The list of all available functions and their usage is located here.

  • Part 1: Images (open), (import), (crop), (export)
  • Part 2: Draw (stroke), (fill), (gradient), (clear)
  • Part 3: Filters (pixels), (saturation), (convolve), (sharpen)
  • Part 4: Events (on), (on "mouse-move"), (on "animate"), (on "/a")

Images

This section will teach the basics of opening, cropping and saving an image file. You can use the $path help to quickly get an image's path into Ronin, by writing $path and dragging a file onto the Ronin window.

Open

To import an image, and resize the canvas to fit the image size, type the following text, drag an image file onto the Ronin window and press cmd+r:

(open $path)

Import

To import an image onto the current canvas, type the following text, drag an image file onto the Ronin window and press cmd+r:

(import $path 
  (guide $rect))

The previous code will import an image, and position it at 50,100, at a size of 250x200. Alternatively, you could use a (line) to stretch the image.

(import $path 
  (guide $line))

Crop

To crop the canvas, type the following text, drag an image file onto the Ronin window press cmd+r:

(import "~/Desktop/photo.jpg" 
  (pos 50 100))
(crop (rect 50 50 300 300)

Alternatively, you could select the cropping area with the cursor with the following code, and selecting an area in the canvas:

(import "~/Desktop/photo.jpg" 
  (pos 50 100))
(crop $rect)

Export

To export the resulting image, type the following text, drag an image file onto the Ronin window, then drag a folder and add the new file's name, and press cmd+r:

(import $path 
  (pos 50 100))
(export $path)

For example, a version of that same code with file paths, might look something like:

(import "~/Desktop/photo.jpg" 
  (pos 50 100))
(export "~/Desktop/export.png")

Draw

Stroke

Fill

Gradient

Clear

Pixels

Pixels

saturation

convolve

sharpen

Events

On

MouseMove

Animate

OSC