diff --git a/pkg/macos/graphics/color_space.zig b/pkg/macos/graphics/color_space.zig index 91fc18994..a381f4c6d 100644 --- a/pkg/macos/graphics/color_space.zig +++ b/pkg/macos/graphics/color_space.zig @@ -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(); +} diff --git a/pkg/macos/graphics/context.zig b/pkg/macos/graphics/context.zig index 5a2f8dd3c..c3516ba7e 100644 --- a/pkg/macos/graphics/context.zig +++ b/pkg/macos/graphics/context.zig @@ -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),