# Some example sets of raster filling elements for tests and illustrations. # Last edited on 2021-09-30 13:09:27 by stolfi import raster_example_IMP # MISCELLANEOUS RASTER FILLS FOR TESTING def patch_array(cols, rows, nx,ny, islands, mp_cont,mp_fill,mp_link): # Returns (1) a list of contours {OCRS}, and (2) # a list of raster paths {OPHS} that comprise a filling for the same. # # Each element of {OPHS} is a {Path} object that consists of a single # /raster/ (horizontal trace) with parameters {mp_fill}. Both trace # and path are oriented left to right. The rasters are sorted # in /scanline order: by increasing {Y} coordinate, and # increasing {X} coordinate in each scanline. # # The rasters are arranged into a two-dimensional array of rectangular # raster stacks (/patches/), with long single rasters (/beams/) # before, between, and after the rows of that array. The array has # {rows} rows and {cols} columns. # # Every patch has {ny}, {ny-2}, or {ny-4} rasters. The trace enpoints # of each patch lie on the boundary of a rectangle whose width is # {nx*wdf} and whose heights is atmost {ny*wdf}, where {wdf} is # {move_parms.width(mp_fill)}. The number {nx} must be positive, # and {ny} must be at least 5. # # If {islands} is true, {cols} must be congruent to 1 modulo 4. Inn # column 0 of the array, every patch has {ny} rasters and makes # contach with the two adjacent beams. In column 1, every patch makes # contact with the lower beam, but has height {ny-2} so it does not # touch the upper beam. In column 2, the patches have {ny-4} rasters # and don't touch either beam. In column 3, the patches have {ny-2} # rasters too, but touch the upper beam only. The pattern then # repeats, every 4 array columns. # # If {islands} is false, cols must be congruent to 1 modulo 3. The # arrangement is the same, except that the island patch (column 2) is # omitted, and the pattern repeats every 3 columns. # # The procedure also creates a set of /link paths/, whose traces have # parameters {mp_link}, that can be used to connect the filler # elements. Each link connects two endpoints of two rasters in # adjacent scan-lines that are vertically aligned. The links that # connect to a filler path {oph} can be accessed through # {path.get_links(oph)} and {path_hp.get_links(rev(oph))}. # # Each raster will be assigned {path_hp.set_group} to a separate # group. The group indices will be consecutive, starting at zero. # # The contours in the list {OCRS} will use parameters {mp_cont}. # They will be properly oriented (ccw for islands, cw for holes) and # their nesting will be available through {path.inner_contours} and # {path.outer_contours} return raster_example_IMP.patch_array(cols, rows, nx,ny, islands, mp_cont,mp_fill,mp_link) def rasters_A(mp_fill, xdir, ydir, yphase, eps): # Returns a list of nine raster filling elements parallel to direction # {xdir}, in scanline order. The traces have parameters {mp_fill} # and lie on four scanlines whose mean spacing is close to the common # width {wd} of those traces, with scanline phase {yphase} (mm). # The rasters are slightly perturbed from the ideal scanline positions # by up to {eps} millimeters. return raster_example_IMP.rasters_A(mp_fill, xdir, ydir, yphase, eps)