Tutorial
The -repeat <repeat block> -done commands form a syntactical unit that together define a repeat block of zero or more commands. -repeat takes a mathematical expression parameter that typically reduces to a repetition count, setting the number of times that the repeat block executes. The parameter may resolve to any integer value, but the repeat block never executes when such is non-positive, an implicit conditional test. |
1. | -repeat 5 count=$> -echo "The count is "$count"." -done | Count to four from zero. |
2. | -repeat 100 count=$> bigu={u} -if $bigu>0.9 break -fi -done -echo "Big U: "$bigu" at count "$count" broke things. :(" | Break on Big U. |
3. | -repeat 100 count=$> theu={u} -if $theu<0.1 -echo "The U "$theu": too small to continue..." -continue -elif $theu>0.9 -echo "The U "$theu": too big to continue..." -continue -fi -echo "The U "$theu": is just right!" -break -done -echo "Done with The U: "$theu" at count "$count". :)" | Operate only in the comfort zone. |
images/ampersand.png -to_rgb. -fill. 'c==0?255*(1-(i/255)):0' -blur. 3,1,0 -expand_x {w/2} -input 100%,100%,100%,100% -append[-2,-1] y | Ampersand by Barry Schwartz who also designed a nice Goudy font to go with it. We: (1) convert the ampersand from a gray to an RGB format, (2) reverse the ampersand, and (3) remove all but the red channel, leaving that slightly blurred. These steps prepare for a neon light ribbons effect, courtesy of the Negation compositing function. We pad the image out to give the ampersand room to twirl around the 50%, 50% image centerpoint. |
+store[0] ampersand -name. accumulator ` | A copy of the ampersand automatically serves as the first image in the upcoming "step-and-repeat" exercise. We name it accumulator, as it will receive further stamped ampersand copies during the step and repeat. store places an off-image-list copy of ampersand into an image storage variable. This image storage variable furnishes fresh copies of the ampersand during the step-and-repeat. |
-repeat {360/6} step=$> | We wish to stamp one ampersand every 6°, 60 stampings all told. Why not simplify the math expression — just write 60? Could. We mean, whatever floats peoples' boats, you know? We like the extra documentation; the round-about way signals a certain intent. |
rotate={6*($step+1)} | We compute rotate, the rotation, in degrees, that each ampersand copy need to turn before stamping. With each repeat loop, $step resolves to the current loop count, so we increment by six degree steps. |
-input[0] $ampersand -name[0] ampersand | We fetch a copy of the ampersand image from the off-list named variable, $ampersand into which the image was safe-kept upstream from here. Reinsertion uses the semantics of the input command. Tagging images via name may be over-kill for this small repeat block, but we like the extra documentation that named images affords. Names remind us of purposes and intents. |
-rotate[ampersand] {$rotate},2,1,50%,50% -normalize[ampersand] 0,255 | We harness the rotate command to step the ampersand image around the center of the image. This is a rotation of image pixels, and in principle, there is no operation here that changes pixel intensity, but in practice, a degree of re-interpolation takes place, so pixels may swing to (slight!) negative values, or assume values (slightly!) greater than 255 — however slight, outside the range that unsigned eight bit integers can accommodate. This preoccupation matters because blend is a compositor designed for this specific bit depth. Prudence, then, dictates a renormalization to the range in which eight bit unsigned integers reside. |
-fill[ampersand] "> wv=vector3(1/sqrt(3)); rot(wv,($step)°)*I" | We undertake a rotation of an entirely different character: that of color space vectors to effect color shifts fill takes for a parameter a Pixel Processor. The pixel processor operates on every pixel in ampersand and alters its color by a color space rotation. Don't confuse color space rotations with the earlier rotation of the image per se. In color space rotation, we model colors as vectors in a three dimensional space, one which has red, green and blue unit axes. The color space rotations here steps ampersand's color around the white axis, leaving wholly and nearly unsaturated pixels unchanged, but repointing more staturated colors to new (color space) orientations. With each step, the (initially red) pixels progressively repoint to orange, yellow, green, blue, purple, indigo and then back to red. |
-cut[ampersand] 0,255 | Color space can also generate vectors that are out-of-band with respect to unsigned, eight bit image channels. Here, we used cut instead of normalize. What is the difference? With -cut, pixel channel values falling below the lower bound are set to that boundary value. Similarly, pixel channel values above the upper bound are set to that value. The upside is that differences among intermediary values do not change, so channel values and the colors they form are undisturbed. The downside is that details conveyed by out of band channel values will be flattened to one or the other boundary and be lost. On the other hand, the G'MIC normalize command may be harnessed to adjust minimum and maximum values to match the minimum and maximum values of the destination file format. The channel values stored in the file will be scaled to fit within the lower and upper boundaries which will change tonal and color relationships. See Images as Data Sets. |
-blend[ampersand,accumulator] negation,0.985 | blend is a channel compositor designed for gray (G), gray-with-opacity, (GA), red-green-blue (RGB), and RGB-with-opacity (RGBA) imagery with unsigned integer, eight-bit data channels; it hosts about sixty compositing functions and is akin to layer mode operators in Gimp and similar paint programs. |
-name. accumulator | The surviving image of the blend retains the ampersand name; we rename it back to accumulator in preparation for the next round of blending. |
-normalize[accumulator] 0,255 | Prudence, again, dictates a renormalization of the blended images, also in preparation for the next round of blending. |
-done | The effect completes. |
G'MIC is an open-source software distributed under the
CeCILL free software licenses (LGPL-like and/or
GPL-compatible).
Copyrights (C) Since July 2008,
David Tschumperlé - GREYC UMR CNRS 6072, Image Team.