From 8f28d1044fb83153fde4505421b75072930d6fb9 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Mon, 9 Feb 2026 22:00:33 -0500 Subject: layout: add background color option --- layout/options.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 layout/options.go (limited to 'layout/options.go') diff --git a/layout/options.go b/layout/options.go new file mode 100644 index 0000000..2ea0c81 --- /dev/null +++ b/layout/options.go @@ -0,0 +1,34 @@ +package layout + +import ( + "image/color" +) + +var ( + defaultBg = color.Transparent +) + +// Option is a function option for layout constructors. +type Option func(*options) + +type options struct { + bg color.Color // background color +} + +// Background sets the background color of a layout. +func Background(bg color.Color) Option { + return func(o *options) { + o.bg = bg + } +} + +// EvalOptions evaluates a list of option functions, returning the final set. +func evalOptions(o ...Option) options { + opts := options{ + bg: defaultBg, + } + for i := range o { + o[i](&opts) + } + return opts +} -- cgit v1.2.3