@@ -158,28 +158,23 @@ It is advised to use `width, height` arguments for large matrices otherwise
158158plots using functions like e.g. `heatmap` could be misleading.
159159"""
160160function grayscale (R, bwcode:: Tuple{TT,T} = (0.0 ,1.0 );
161- exactsize= false , kwargs... ) where {TT<: Real , T<: Real }
161+ width = nothing , height = nothing , exactsize= false
162+ ) where {TT<: Real , T<: Real }
162163
163164 dims = size (R)
164- kwargs = Dict (kwargs)
165- if haskey (kwargs, :width ) && ! haskey (kwargs, :height )
166- width = Int (kwargs[:width ])
165+ if ! isnothing (width) && isnothing (height)
167166 height = round (Int, width* dims[2 ]/ dims[1 ])
168167 return grayscale (R, bwcode; width= width, height= height)
169- elseif haskey (kwargs, :height ) && ! haskey (kwargs, :width )
170- height = Int (kwargs[:height ])
168+ elseif isnothing (width) && ! isnothing (height)
171169 width = round (Int, height* dims[1 ]/ dims[2 ])
172- return grayscale (R, bwcode; width= width, height= height)
173- elseif ! haskey (kwargs, :width ) || ! haskey (kwargs, :height )
174- width, height = Int .(dims)
175- return grayscale (R, bwcode; width= width, height= height)
170+ elseif isnothing (width) && isnothing (height)
171+ width, height = dims
176172 end
177- if exactsize
178- width, height = Int (kwargs[:width ]), Int (kwargs[:height ])
179- else
180- width, height = checkgridsize (Int (kwargs[:width ]),
181- Int (kwargs[:height ]), dims)
173+
174+ if ! exactsize
175+ width, height = checkgridsize (width, height, dims)
182176 end
177+
183178 # initial and final values of the horizontal and vertical blocks
184179 rows = overlapgrid (width, dims[1 ])
185180 cols = overlapgrid (height, dims[2 ])
@@ -194,5 +189,5 @@ function grayscale(R, bwcode::Tuple{TT,T}=(0.0,1.0);
194189 p .= bwcode[1 ]. * p .+ bwcode[2 ]. * (1 .- p)
195190 pt = (T<: Integer ) ? round .(T, p) : T .(p)
196191 # need to flip `y` so that diagonal is in the correct way...
197- return reverse (pt; dims = 2 )
192+ return reverse (pt; dims = 1 )
198193end
0 commit comments