Created
December 12, 2015 02:36
-
-
Save anonymous/72c4d2db7953c0d832c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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