From b91fb31c3ce713b00ff980bd3c10adf5d35ce04d Mon Sep 17 00:00:00 2001 From: kimikage Date: Sun, 25 Oct 2026 23:02:59 +0900 Subject: [PATCH] Reduce the exposed `length(r)` methods for ranges --- src/ColorVectorSpace.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ColorVectorSpace.jl b/src/ColorVectorSpace.jl index b7201e1..5f4fa55 100644 --- a/src/ColorVectorSpace.jl +++ b/src/ColorVectorSpace.jl @@ -457,8 +457,10 @@ function stdmult(op, itr; kwargs...) return isa(result, Union{Real,Colorant,RGBRGB}) ? _sqrt(result) : _sqrt.(result) end -Base.length(r::StepRange{<:AbstractGray,<:AbstractGray}) = length(StepRange(gray(r.start), gray(r.step), gray(r.stop))) -Base.length(r::StepRange{<:AbstractGray}) = length(StepRange(gray(r.start), r.step, gray(r.stop))) +function Base.length(r::StepRange{<:AbstractGray}) + step = r.step isa AbstractGray ? gray(r.step) : r.step + return length(StepRange(gray(r.start), step, gray(r.stop))) +end Base.abs2(c::Union{AbstractGray,AbstractRGB}) = c ⋅ c