Skip to content

Instantly share code, notes, and snippets.

/cairo-main.swift
Created Dec 12, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.