Skip to content

Instantly share code, notes, and snippets.

Created December 12, 2015 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/72c4d2db7953c0d832c7 to your computer and use it in GitHub Desktop.
Save anonymous/72c4d2db7953c0d832c7 to your computer and use it in GitHub Desktop.
import CCairo
public class Surface {
public let surface: COpaquePointer
public let cr: COpaquePointer
public init(format: cairo_format_t, width: Int, height: Int) {
self.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 421, 410)
self.cr = cairo_create(surface)
}
public func lineTo(x: Double, y: Double) {
cairo_line_to(cr, x, y)
}
public func scale(x: Double, y: Double) {
cairo_scale(cr, x, y)
}
public func moveTo(x: Double, y: Double) {
cairo_move_to (cr, x, y)
}
public func setLineWidth(width: Double) {
cairo_set_line_width(cr, width)
}
public func stroke() {
cairo_stroke(cr)
}
public func surfaceWriteToPNG(filename: String) {
cairo_surface_write_to_png(surface, filename)
}
deinit {
cairo_destroy(cr)
cairo_surface_destroy(surface)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment