Ext.data.JsonP.command_slice({"title":"Image Slicing for IE","guide":"
Contents
\nThe sencha fs slice
command performs general image slicing and manipulation driven by\nthe contents of a JSON manifest file. This manifest is typically generated automatically\nby sencha package build
for a package or sencha app build
for an application, but for\ndiagnostic purposes the \"theme-capture.json\"
is left on disk in the build folder. This\nguide describes the format of this manifest.
The manifest file contains an array of image area definitions that further contain a set\nof \"slices\" to produce.
\n\n[\n {\n // The border-width of the box.\n //\n \"border\": {\n \"b\": 1,\n \"l\": 1,\n \"r\": 1,\n \"t\": 1\n },\n\n // The box or coordinates of the area within the image file being\n // processed.\n //\n \"box\": {\n \"h\": 22,\n \"w\": 46,\n \"x\": 10,\n \"y\": 51\n },\n\n // The direction of the background gradient if there is one.\n //\n \"gradient\": \"top\",\n\n // The border radii for top-left, top-right, bottom-right and\n // bottom-left corners.\n //\n \"radius\": {\n \"bl\": 3,\n \"br\": 3,\n \"tl\": 3,\n \"tr\": 3\n },\n\n // The side of the image to stretch for sliding-doors. This is currently\n // hard-coded to stretch to 800px.\n //\n \"stretch\": \"bottom\",\n\n // The slice operations to perform and the relative path to the\n // desired image.\n //\n \"slices\": {\n \"bg\": \"images/btn/btn-default-small-bg.gif\",\n \"corners\": \"images/btn/btn-default-small-corners.gif\",\n \"sides\": \"images/btn/btn-default-small-sides.gif\"\n }\n }\n]\n
\n\nThe keys of the \"slices\"
object can be any of these:
bg
: Extracts the box background (inside the border)frame_bg
: Extracts the box background (inside the border and border radius)corners
: A sprite consisting of the 4 rounded corners and 2 sides.sides
: A sprite consisting of the 2 sides that are not in the ccrners
.For each of the above, there is also a \"_rtl\" form that operates on the base\nwidget after first flipping the widget horizontally (e.g., \"bg_rtl\").
\n\nThere are two special sprites produced by the slicer: corners and sides. These contain\ndifferent sub-images based on the presence and type of the background gradient.
\n\nThe \"corners\" sprite actually contains more than just the 4 (rounded) corners: it also\nhas two of the sides. The two sides contained in the \"corners\" sprite are the two sides\nthat are repeated.
\n\nThe \"sides\" sprite contains the remaining two side sub-images. These may or may not be\nrepeated, depending on the presence of a background gradient.
\n\nTo understand the slicing operation, consider the starting frame:
\n\n +----+--------------------------------------------------+----+\n | TL | TC | TR |\n +----+--------------------------------------------------+----+\n | | | |\n | | | |\n | | | |\n | ML | | MR |\n | | | |\n | | | |\n | | | |\n +----+--------------------------------------------------+----+\n | BL | BC | BR |\n +----+--------------------------------------------------+----+\n
\n\nThe width and height of the cells of the sprites is equal to the maximum of the four\nborder radii and border widths. Typically these are symmetric on some axis, but in all\ncases the sprite cells are square and use the maximum required size.
\n\nWhen there is no gradient or if the gradient direction is vertical (that is, either \"top\"\nor \"bottom\"), the \"corners\" sprite produced is 1x6 with the following layout:
\n\n +------+\n | TC | (top center side of frame)\n +------+\n | BC | (bottom center side of frame)\n +------+\n | TL | (top left corner)\n +------+\n | TR | (top right corner)\n +------+\n | BL | (bottom left corner)\n +------+\n | BR | (bottom right corner)\n +------+\n
\n\nThe \"TC\" and \"BC\" cells are used with repeat-x
styling to fill the desired width.
The \"sides\" sprite is then a 2x1 sprite with this layout:
\n\n +------+------+\n | | |\n | | |\n | ML | MR |\n | | |\n | | |\n +------+------+\n
\n\nIf there is no gradient, the cells are used with repeat-y
styling. Otherwise, the whole\nsprite is stretched to 800px and one edge is repeated based on the stretch
property in\nthe manifest. If 'stretch' is \"bottom\"
then the bottom row is repeated until the sprite\nhas 800px height. Otherwise, the captured gradient is placed at the bottom of the cell the\ntop row is repeated to fill the space above the gradient.
If there is a horizontal gradient (that is, either \"left\" or \"right\"), the corners sprite\nproduced is 3x4 with this layout:
\n\n +------+------+------+\n | TL | | |\n +------+ | |\n | TR | | | ML = middle left side of frame\n +------+ ML | MR |\n | BL | | | MR = middle right side of frame\n +------+ | |\n | BR | | |\n +------+------+------+\n
\n\nThe \"ML\" and \"MR\" cells are styled with repeat-y
to fill the desired height.
The \"sides\" sprite is a 1x2 sprite:
\n\n +------+\n | TC |\n +------+\n | BC |\n +------+\n
\n\nBecause this layout is only used in the presence of a gradient, these sprites are always\nstretched to 800px width. The value of the stretch
property on the manifest determines\nwhere the column of pixels is repeated. A value of \"right\"
means the right-most column\nof pixels is repeated to fill 800px. A value of \"left\"
will produce a cell where the\ngradient is copied to the right-most end and the left-most column of pixels is repeated\nto fill the space.