We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
middle
1 parent 0d853b0 commit 1a8a670Copy full SHA for 1a8a670
src/ColorVectorSpace.jl
@@ -28,7 +28,7 @@ import Base: conj, sin, cos, tan, sinh, cosh, tanh,
28
gamma, lfact, frexp, modf, airy, airyai,
29
airyprime, airyaiprime, airybi, airybiprime,
30
besselj0, besselj1, bessely0, bessely1,
31
- eta, zeta, digamma, float
+ eta, zeta, digamma, float, middle
32
33
export dotc
34
@@ -202,6 +202,9 @@ for op in unaryOps
202
@eval ($op)(c::AbstractGray) = $op(gray(c))
203
end
204
205
+middle(c::AbstractGray) = base_colorant_type(c)(middle(gray(c)))
206
+middle(x::C, y::C) where {C<:AbstractGray} = C(middle(gray(x), gray(y)))
207
+
208
(*)(f::Real, c::AbstractGray) = base_colorant_type(c){multype(typeof(f),eltype(c))}(f*gray(c))
209
(*)(f::Real, c::TransparentGray) = base_colorant_type(c){multype(typeof(f),eltype(c))}(f*gray(c), f*alpha(c))
210
(*)(c::AbstractGray, f::Real) = (*)(f, c)
test/runtests.jl
@@ -118,6 +118,8 @@ end
118
119
@test typeof(float(Gray{N0f16}(0.5))) <: AbstractFloat
120
@test quantile( Gray{N0f16}[0.0,0.5,1.0], 0.1) ≈ 0.10000152590218968
121
+ @test middle(Gray(0.2)) === Gray(0.2)
122
+ @test middle(Gray(0.2), Gray(0.4)) === Gray((0.2+0.4)/2)
123
124
125
@testset "Comparisons with Gray" begin
0 commit comments