pkg/macos: CGColorSpace

This commit is contained in:
Mitchell Hashimoto
2022-10-07 17:59:52 -07:00
parent fd509a2cb4
commit ca7f3647ff
2 changed files with 25 additions and 0 deletions

View File

@ -1,4 +1,5 @@
pub const c = @import("graphics/c.zig");
pub usingnamespace @import("graphics/color_space.zig");
pub usingnamespace @import("graphics/font.zig");
test {

View File

@ -0,0 +1,24 @@
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const c = @import("c.zig");
pub const ColorSpace = opaque {
pub fn createDeviceGray() Allocator.Error!*ColorSpace {
return @intToPtr(
?*ColorSpace,
@ptrToInt(c.CGColorSpaceCreateDeviceGray()),
) orelse Allocator.Error.OutOfMemory;
}
pub fn release(self: *ColorSpace) void {
c.CGColorSpaceRelease(@ptrCast(c.CGColorSpaceRef, self));
}
};
test {
//const testing = std.testing;
const space = try ColorSpace.createDeviceGray();
defer space.release();
}