From 1151a0eb500586be49f142512cbe14549f36ebf6 Mon Sep 17 00:00:00 2001 From: Daniel Tull Date: Fri, 13 Dec 2024 18:05:41 +0000 Subject: [PATCH] Conform Color to View --- Sources/TerminalUI/{ => Views}/Color.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) rename Sources/TerminalUI/{ => Views}/Color.swift (78%) diff --git a/Sources/TerminalUI/Color.swift b/Sources/TerminalUI/Views/Color.swift similarity index 78% rename from Sources/TerminalUI/Color.swift rename to Sources/TerminalUI/Views/Color.swift index 31eafe5..1da746c 100644 --- a/Sources/TerminalUI/Color.swift +++ b/Sources/TerminalUI/Views/Color.swift @@ -1,8 +1,17 @@ -public struct Color: CustomStringConvertible, Equatable, Sendable { +public struct Color: Builtin, CustomStringConvertible, Equatable, Sendable, View { public let description: String let foreground: ControlSequence let background: ControlSequence + + func render(in canvas: any Canvas, size: Size, environment: EnvironmentValues) { + let pixel = Pixel(" ", background: self) + for x in 1...size.width { + for y in 1...size.height { + canvas.draw(pixel, at: Position(x: x, y: y)) + } + } + } } // MARK: - ANSI colors