mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-13 03:38:37 +03:00
pkg/macos: RGB color space
This commit is contained in:
@ -11,6 +11,13 @@ pub const ColorSpace = opaque {
|
|||||||
) orelse Allocator.Error.OutOfMemory;
|
) 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 {
|
pub fn release(self: *ColorSpace) void {
|
||||||
c.CGColorSpaceRelease(@ptrCast(c.CGColorSpaceRef, self));
|
c.CGColorSpaceRelease(@ptrCast(c.CGColorSpaceRef, self));
|
||||||
}
|
}
|
||||||
@ -22,3 +29,8 @@ test {
|
|||||||
const space = try ColorSpace.createDeviceGray();
|
const space = try ColorSpace.createDeviceGray();
|
||||||
defer space.release();
|
defer space.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
const space = try ColorSpace.createDeviceRGB();
|
||||||
|
defer space.release();
|
||||||
|
}
|
||||||
|
@ -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 {
|
pub fn setTextDrawingMode(self: *T, mode: TextDrawingMode) void {
|
||||||
c.CGContextSetTextDrawingMode(
|
c.CGContextSetTextDrawingMode(
|
||||||
@ptrCast(c.CGContextRef, self),
|
@ptrCast(c.CGContextRef, self),
|
||||||
|
Reference in New Issue
Block a user