Skip to content

Commit

Permalink
created Xcode project
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Jan 31, 2016
1 parent c85ae0a commit 4087473
Show file tree
Hide file tree
Showing 15 changed files with 795 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Xcode/Cairo.xcodeproj/project.xcworkspace/xcuserdata/
35 changes: 35 additions & 0 deletions Sources/Cairo/Context.swift
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
}
}
27 changes: 27 additions & 0 deletions Sources/Cairo/ImageFormat.swift
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
}
11 changes: 11 additions & 0 deletions Sources/Cairo/Pattern.swift
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


41 changes: 41 additions & 0 deletions Sources/Cairo/Surface.swift
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
}
}
Loading

0 comments on commit 4087473

Please sign in to comment.