class

Cairo::Script

Inherits Cairo::Device / Reference / Object

The script surface provides the ability to render to a native script that matches the cairo drawing model. The scripts can be replayed using tools under the util/cairo-script directory, or with cairo-perf-trace.

Constructors

new(write_func : LibCairo::WriteFuncT, closure : Pointer(Void))

Creates a output device for emitting the script, used when creating the individual surfaces.

###Parameters

  • write_func callback function passed the bytes written to the script
  • closure user data to be passed to the callback

###Returns The newly created device. The caller owns the surface and should call Script#finalze when done with it.

This function always returns a valid pointer, but it will return a pointer to a nil device if an error such as out of memory occurs. You can use Context#status to check for this.

Source
new(filename : String)

Creates a output device for emitting the script, used when creating the individual surfaces.

###Parameters

  • filename the name (path) of the file to write the script to

###Returns The newly created Script-Surface. The caller owns the surface and should call Script#finalize when done with it.

This function always returns a valid pointer, but it will return a pointer to a nil device if an error such as out of memory occurs. You can use Context#status to check for this.

Source

Instance methods

create_script_surface(content : Content, width : Float64, height : Float64) : Surface

Create a new surface that will emit its rendering through script.

###Parameters

  • content the content of the surface
  • width width in pixels
  • height height in pixels

###Returns A pointer to the newly created Surface. The caller owns the surface and should call Surface#finalize when done with it.

This function always returns a valid pointer, but it will return a pointer to a nil surface if an error such as out of memory occurs. You can use Surface#status to check for this.

Source
create_script_surface_for_target(target : Surface) : Surface

Create a pxoy surface that will render to target and record the operations to device.

###Parameters

  • target a target surface to wrap

###Returns A pointer to the newly created Surface. The caller owns the surface and should call Surface#finalize when done with it.

This function always returns a valid pointer, but it will return a pointer to a nil surface if an error such as out of memory occurs. You can use Surface#status to check for this.

Source
from_recording_surface(recording_surface : Surface) : Status

Converts the record operations in recording_surface into a script.

###Parameters

  • script the script (output device)
  • recording_surface the recording surface to replay

###Returns Status::Success on successful completion or an error code.

Source
mode

Queries the script for its current output mode.

###Returns The current output mode of the script.

Source
mode=(mode : ScriptMode)

Change the output mode of the script.

###Parameters

  • mode the new mode
Source
write_comment(comment : String, len : Int32 = -1)

Emit a string verbatim into the script.

###Parameters

  • comment the string to emit
  • len the length of the sting to write, or -1 to use comment.size
Source