@@ -24,7 +24,7 @@ function apply(crop::Crop, item::Item; randstate = getrandstate(crop))
2424 return apply (
2525 Project (CoordinateTransformations. IdentityTransformation ()) |> crop,
2626 item;
27- randstate = (nothing , randstate))
27+ randstate = (nothing , ( randstate,) ))
2828end
2929
3030
5050
5151
5252
53- struct CroppedProjectiveTransform{P<: ProjectiveTransform , C<: AbstractCrop } <: ProjectiveTransform
53+ struct CroppedProjectiveTransform{P<: ProjectiveTransform , C<: Tuple } <: ProjectiveTransform
5454 tfm:: P
55- crop :: C
55+ crops :: C
5656end
5757
5858
5959function getrandstate (cropped:: CroppedProjectiveTransform )
60- return (getrandstate (cropped. tfm), getrandstate (cropped. crop ))
60+ return (getrandstate (cropped. tfm), getrandstate . (cropped. crops ))
6161end
6262
6363
@@ -69,49 +69,55 @@ function getprojection(
6969 return getprojection (cropped. tfm, bounds; randstate = tfmstate)
7070end
7171
72-
7372function projectionbounds (
74- cropped:: CroppedProjectiveTransform{PT, C} ,
73+ cropped:: CroppedProjectiveTransform ,
7574 P,
7675 bounds;
77- randstate = getrandstate (cropped)) where {PT, C <: Crop }
78- tfmstate, cropstate = randstate
76+ randstate = getrandstate (cropped))
77+ tfmstate, cropstates = randstate
7978 bounds_ = projectionbounds (cropped. tfm, P, bounds; randstate = tfmstate)
80- return offsetcropbounds (cropped. crop. size, bounds_, cropstate)
79+ for (crop, cropstate) in zip (cropped. crops, cropstates)
80+ bounds_ = cropbounds (crop, bounds_; randstate = cropstate)
81+ end
82+ return bounds_
8183end
8284
85+ compose (tfm:: ProjectiveTransform , crop:: AbstractCrop ) = CroppedProjectiveTransform (tfm, (crop,))
86+ compose (tfm:: ProjectiveTransform , cropped:: CroppedProjectiveTransform ) =
87+ CroppedProjectiveTransform (tfm |> cropped. tfm, cropped. crops)
8388
84- function projectionbounds (
85- cropped:: CroppedProjectiveTransform{PT, PadDivisible} ,
86- P,
87- bounds;
88- randstate = getrandstate (cropped)) where {PT}
89- tfmstate, cropstate = randstate
90- bounds_ = projectionbounds (cropped. tfm, P, bounds; randstate = tfmstate)
91- ranges = bounds_. rs
89+ function compose (composed:: ComposedProjectiveTransform , cropped:: CroppedProjectiveTransform )
90+ return CroppedProjectiveTransform (composed |> cropped. tfm, cropped. crops)
91+ end
9292
93- sz = length .(ranges)
94- pad = (cropped. crop. by .- (sz .% cropped. crop. by)) .% cropped. crop. by
93+ function compose (cropped:: CroppedProjectiveTransform , crop:: AbstractCrop )
94+ return CroppedProjectiveTransform (cropped. tfm, (cropped. crops... , crop))
95+ end
9596
96- start = minimum .(ranges)
97- end_ = start .+ sz .+ pad .- 1
98- rs = UnitRange .(start, end_)
99- return Bounds (rs)
97+ function compose (cropped:: CroppedProjectiveTransform , projective:: ProjectiveTransform )
98+ return Sequence (cropped, projective)
10099end
101100
101+ function compose (cropped:: CroppedProjectiveTransform , composed:: ComposedProjectiveTransform )
102+ return Sequence (cropped, composed)
103+ end
102104
103105
104- compose (tfm:: ProjectiveTransform , crop:: AbstractCrop ) = CroppedProjectiveTransform (tfm, crop)
105- compose (tfm:: ProjectiveTransform , crop:: CroppedProjectiveTransform ) =
106- CroppedProjectiveTransform (tfm |> crop. tfm, crop. crop)
106+ cropbounds (crop:: Crop , bounds:: Bounds ; randstate= getrandstate (crop)) = offsetcropbounds (crop. size, bounds, randstate)
107107
108- function compose (composed:: ComposedProjectiveTransform , cropped:: CroppedProjectiveTransform )
109- return CroppedProjectiveTransform (composed |> cropped. tfm, cropped. crop)
108+ function cropbounds (
109+ crop:: PadDivisible ,
110+ bounds:: Bounds ;
111+ randstate = getrandstate (crop))
112+ ranges = bounds. rs
110113
111- end
114+ sz = length .(ranges)
115+ pad = (crop. by .- (sz .% crop. by)) .% crop. by
112116
113- function compose (cropped:: CroppedProjectiveTransform , projective:: ProjectiveTransform )
114- return Sequence (cropped, projective)
117+ start = minimum .(ranges)
118+ end_ = start .+ sz .+ pad .- 1
119+ rs = UnitRange .(start, end_)
120+ return Bounds (rs)
115121end
116122
117123
0 commit comments