pkg/macos: RGB color space

This commit is contained in:
Mitchell Hashimoto
2022-10-07 21:07:11 -07:00
parent c48ddcecd7
commit 67bb68b39f
2 changed files with 22 additions and 0 deletions

View File

@ -11,6 +11,13 @@ pub const ColorSpace = opaque {
) orelse Allocator.Error.OutOfMemory;
}
pub fn createDeviceRGB() Allocator.Error!*ColorSpace {
return @intToPtr(
?*ColorSpace,
@ptrToInt(c.CGColorSpaceCreateDeviceRGB()),
) orelse Allocator.Error.OutOfMemory;
}
pub fn release(self: *ColorSpace) void {
c.CGColorSpaceRelease(@ptrCast(c.CGColorSpaceRef, self));
}
@ -22,3 +29,8 @@ test {
const space = try ColorSpace.createDeviceGray();
defer space.release();
}
test {
const space = try ColorSpace.createDeviceRGB();
defer space.release();
}

View File

@ -49,6 +49,16 @@ pub fn Context(comptime T: type) type {
);
}
pub fn setRGBFillColor(self: *T, r: f64, g: f64, b: 64, alpha: f64) void {
c.CGContextSetRGBFillColor(
@ptrCast(c.CGContextRef, self),
r,
g,
b,
alpha,
);
}
pub fn setTextDrawingMode(self: *T, mode: TextDrawingMode) void {
c.CGContextSetTextDrawingMode(
@ptrCast(c.CGContextRef, self),