-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c85ae0a
commit 4087473
Showing
15 changed files
with
795 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
Xcode/Cairo.xcodeproj/project.xcworkspace/xcuserdata/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Context.swift | ||
// Cairo | ||
// | ||
// Created by Alsey Coleman Miller on 1/31/16. | ||
// Copyright © 2016 PureSwift. All rights reserved. | ||
// | ||
|
||
import CCairo | ||
|
||
/// Cairo Context | ||
public final class Context { | ||
|
||
// MARK: - Properties | ||
|
||
public let surface: Surface | ||
|
||
// MARK: - Internal Properties | ||
|
||
internal var internalPointer: COpaquePointer | ||
|
||
// MARK: - Initialization | ||
|
||
public init(surface: Surface) { | ||
|
||
// create | ||
let internalPointer = cairo_create(surface.internalPointer) | ||
|
||
assert(internalPointer != nil, "Could not create internal pointer") | ||
|
||
// set values | ||
self.internalPointer = internalPointer | ||
self.surface = surface | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// ImageFormat.swift | ||
// Cairo | ||
// | ||
// Created by Alsey Coleman Miller on 1/31/16. | ||
// Copyright © 2016 PureSwift. All rights reserved. | ||
// | ||
|
||
/// Used to identify the memory format of image data. | ||
public enum ImageFormat: CInt { | ||
|
||
/// Each pixel is a 32-bit quantity, with | ||
/// alpha in the upper 8 bits, then red, then green, then blue. | ||
/// The 32-bit quantities are stored native-endian. Pre-multiplied alpha is used. | ||
/// (That is, 50% transparent red is 0x80800000, not 0x80ff0000.) | ||
case ARGB32 = 0 | ||
|
||
case RGB24 | ||
|
||
case A8 | ||
|
||
case A1 | ||
|
||
case RGB16565 | ||
|
||
case RGB30 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
// Pattern.swift | ||
// Cairo | ||
// | ||
// Created by Alsey Coleman Miller on 1/31/16. | ||
// Copyright © 2016 PureSwift. All rights reserved. | ||
// | ||
|
||
import CCairo | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Surface.swift | ||
// Cairo | ||
// | ||
// Created by Alsey Coleman Miller on 1/31/16. | ||
// Copyright © 2016 PureSwift. All rights reserved. | ||
// | ||
|
||
import CCairo | ||
|
||
public final class Surface { | ||
|
||
// MARK: - Internal Properties | ||
|
||
internal var internalPointer: COpaquePointer | ||
|
||
// MARK: - Initialization | ||
|
||
deinit { | ||
|
||
assert(internalPointer != nil, "Internal pointer of deallocating object is nil") | ||
|
||
cairo_surface_destroy(internalPointer) | ||
} | ||
|
||
public convenience init(format: ImageFormat, width: Int, height: Int) { | ||
|
||
let internalFormat = cairo_format_t(rawValue: format.rawValue) | ||
|
||
let pointer = cairo_image_surface_create(internalFormat, Int32(width), Int32(height)) | ||
|
||
self.init(pointer) | ||
} | ||
|
||
internal init(_ internalPointer: COpaquePointer) { | ||
|
||
assert(internalPointer != nil, "Internal pointer is nil") | ||
|
||
self.internalPointer = internalPointer | ||
} | ||
} |
Oops, something went wrong.