1 /** This file is part of Shapes.
3 ** Shapes is free software: you can redistribute it and/or modify
4 ** it under the terms of the GNU General Public License as published by
5 ** the Free Software Foundation, either version 3 of the License, or
8 ** Shapes is distributed in the hope that it will be useful,
9 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ** GNU General Public License for more details.
13 ** You should have received a copy of the GNU General Public License
14 ** along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 ** Copyright 2009, 2014, 2015 Henrik Tidefelt
19 ##echo To run this example you need to download the PngSuite by Willem van Schaik, and extract the files in the raster_data/PngSuite directory.
22 ** The PngSuite can be downloaded from
23 ** http://www.schaik.com/pngsuite/pngsuite.html
27 ** This example contains some code that is commented out since I didn't want to add too many raster image files to the repository.
28 ** Knowing that they all were loaded fine once upon the time, I think that the remaining selection of examples from the PngSuite
29 ** is large enough to give reasonable coverage.
31 ** Since Shapes does not support the PNG gamma correction feature, no such examples from the suite are included by this file.
32 ** Similarly, background colors will never be used by Shapes, so these examples are also ignored.
36 ##lookin ..Shapes..Layout
44 square: @nonstroking:[gray 0.9] | [Graphics..fill [Geometry..rectangle (0m,0m) (side,side)]]
45 ( @nonstroking:[gray 0.7] | [Graphics..fill [Geometry..rectangle (0m,0m) (dx,dy)]] )
47 [[Data..range 0m dx-0.5*side side].foldl
48 \ p x → [[Data..range [if [Numeric..Math..mod x+0.5*side 2*side] < side 0m side] dx-0.5*side 2*side].foldl
49 \ p y → ( p & ( square >> [shift (x,y)] ) )
52 } >> center >> [scale 0.7]
54 colorStrs: [Data..vector `-bw´ `´]
55 depthStrs: [Data..vector '1 '2 '4 '8 '16]
59 [Layout..center checkers & [Layout..center img] (0,~1)]
60 & [Layout..center ( Text..newText << ( String..newString << img.space << ` ´ << img.depth ) ) (0,1)]
64 |** [[Data..range '0 colorStrs.size-'1].foldl
66 |** ( p & [[shift (0,~i*dy)] [[Data..range '0 depthStrs.size-'1].foldl
68 |** & [[shift (j*dx,0)] [helper [Graphics..import_raster (String..newString << `logo´ << [colorStrs i] << [String..sprintf `-%d´ [depthStrs j]] << `.png´ ) resolution:0.2bp]]] )
72 suite_helper: \ filename resolution:2bp →
74 img: [Graphics..import_raster `raster_data/PngSuite/´ + filename + `.png´ resolution:resolution override:false]
75 [Layout..center checkers & [Layout..center img] & (@dash:[dashpattern 1mm 1mm] | [Graphics..stroke [Layout..bbox [Layout..center img]]])(0,~1)]
76 & [Layout..center ( Text..newText << ( String..newString << img.space << ` ´ << img.depth << "{n} << filename << "{n} ) ) (0,1)]
79 |** IO..•page << [suite_helper `palette_text_1´ resolution:0.5bp] >> [shift (0*dx,~3*dy)]
80 |** IO..•page << [suite_helper `alpha_text_8´ resolution:0.5bp] >> [shift (1*dx,~3*dy)]
82 IO..•page << [suite_helper `bgai4a08´] >> [shift (0*dx,~4*dy)]
83 IO..•page << [suite_helper `bgai4a16´] >> [shift (1*dx,~4*dy)]
84 IO..•page << [suite_helper `bgan6a08´] >> [shift (2*dx,~4*dy)]
85 IO..•page << [suite_helper `bgan6a16´] >> [shift (3*dx,~4*dy)]
87 IO..•page << [suite_helper `basn0g01´] >> [shift (0*dx,~5*dy)]
88 IO..•page << [suite_helper `basn2c08´] >> [shift (1*dx,~5*dy)]
89 IO..•page << [suite_helper `basn2c16´] >> [shift (2*dx,~5*dy)]
91 IO..•page << [suite_helper `basn0g02´] >> [shift (0*dx,~6*dy)]
92 IO..•page << [suite_helper `basn0g04´] >> [shift (1*dx,~6*dy)]
93 IO..•page << [suite_helper `basn0g08´] >> [shift (2*dx,~6*dy)]
94 IO..•page << [suite_helper `basn0g16´] >> [shift (3*dx,~6*dy)]
96 IO..•page << [suite_helper `basn3p01´] >> [shift (0*dx,~7*dy)]
97 IO..•page << [suite_helper `basn3p02´] >> [shift (1*dx,~7*dy)]
98 IO..•page << [suite_helper `basn3p04´] >> [shift (2*dx,~7*dy)]
99 IO..•page << [suite_helper `basn3p08´] >> [shift (3*dx,~7*dy)]
101 IO..•page << [suite_helper `basn4a08´] >> [shift (0*dx,~8*dy)]
102 IO..•page << [suite_helper `basn4a16´] >> [shift (1*dx,~8*dy)]
103 IO..•page << [suite_helper `basn6a08´] >> [shift (2*dx,~8*dy)]
104 IO..•page << [suite_helper `basn6a16´] >> [shift (3*dx,~8*dy)]
106 IO..•page << [suite_helper `cdfn2c08´] >> [shift (0*dx,~9*dy)]
107 IO..•page << [suite_helper `cdhn2c08´] >> [shift (1*dx,~9*dy)]
108 IO..•page << [suite_helper `cdsn2c08´] >> [shift (2*dx,~9*dy)]
109 IO..•page << [suite_helper `cdun2c08´] >> [shift (3*dx,~9*dy)]