Skip to content

Commit 375388d

Browse files
committed
simplify
1 parent b897cc9 commit 375388d

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/UnicodePlots.jl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,6 @@ include("interface/boxplot.jl")
111111
include("interface/polarplot.jl")
112112
include("interface/imageplot.jl")
113113

114-
function init_24bit()
115-
truecolors!()
116-
USE_LUT[] ? brightcolors!() : faintcolors!()
117-
nothing
118-
end
119-
120-
function init_8bit()
121-
colors256!()
122-
faintcolors!()
123-
nothing
124-
end
125-
126114
function __init__()
127115
forced_24bit() && return init_24bit()
128116
forced_8bit() && return init_8bit()

src/common.jl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ const SUPERSCRIPT = Dict(
152152
############################################################################################
153153
# define types
154154
const MarkerType = Union{Symbol,AbstractChar,AbstractString}
155-
const StyledStringsColorType = Union{Integer,Symbol,StyledStrings.RGBTuple,UInt32}
156-
const UserColorType = Union{StyledStrings.Face,StyledStringsColorType,NTuple{3,Integer},Nothing} # allowed color type
155+
const StyledStringsColorType = Union{Symbol,StyledStrings.RGBTuple,NTuple{3,Integer},UInt32} # from StyledStrings/src/faces.jl
156+
const UserColorType = Union{StyledStrings.Face,StyledStringsColorType,Nothing} # allowed color type
157157
const ColorType = UInt32 # internal UnicodePlots color type (on canvas), 8bit or 24bit
158158

159159
############################################################################################
@@ -214,6 +214,21 @@ const DEFAULT_WIDTH = Ref(round(Int, DEFAULT_HEIGHT[] * 2ASPECT_RATIO[]))
214214
brightcolors!() = COLOR_CYCLE[] = COLOR_CYCLE_BRIGHT
215215
faintcolors!() = COLOR_CYCLE[] = COLOR_CYCLE_FAINT
216216

217+
colors256!() = COLORMODE[] = COLORMODE_8BIT
218+
truecolors!() = COLORMODE[] = COLORMODE_24BIT
219+
220+
function init_24bit()
221+
truecolors!()
222+
USE_LUT[] ? brightcolors!() : faintcolors!()
223+
nothing
224+
end
225+
226+
function init_8bit()
227+
colors256!()
228+
faintcolors!()
229+
nothing
230+
end
231+
217232
colormode() =
218233
if (cm = COLORMODE[]) COLORMODE_8BIT
219234
8
@@ -223,9 +238,6 @@ colormode() =
223238
throw(ArgumentError("color mode $cm is unsupported"))
224239
end
225240

226-
colors256!() = COLORMODE[] = COLORMODE_8BIT
227-
truecolors!() = COLORMODE[] = COLORMODE_24BIT
228-
229241
function colormode!(mode)
230242
if mode 8
231243
colors256!()
@@ -237,7 +249,6 @@ function colormode!(mode)
237249
nothing
238250
end
239251

240-
241252
# specific to UnicodePlots
242253
forced_24bit() = lowercase(get(ENV, "UP_COLORMODE", "")) ("24", "24bit", "truecolor")
243254
forced_8bit() = lowercase(get(ENV, "UP_COLORMODE", "")) ("8", "8bit")

0 commit comments

Comments
 (0)