Creating A Grid Macro With ColorX |
This gives you two grid macros. The first one uses ColorX, and is therefore a little slow, and is also unavailable to ShakeVideo users. However, it is very accurate, and gives you control over line width in the grid. The second versions creates a Checker, Embosses it, Solarizes it, and then puts it at extreme contrast with ContrastLum. It is very fast, but there are some inherent inaccuracies, and you can't control the line width. Certain nodes allow you to create complex expressions to create an effect. See if you can spot the common element in the following nodes: ColorX, WarpX, LayerX, and TimeX. HmmmmX. WhatX couldX itX beX? Each of these does an operation according to an expression that you apply. Generally, they are slower than other operators, which are applied to an entire image. These, however, apply themselves to each pixel, and can be extremely powerful.
|
In this example, which is a macro to create a grid, you can set the grid spacing and the grid line width. You create local variables inside your expressions, u and v, to locate and evaluate a pixel position to determine if that pixel should be in the grid or not: |
image Grid( int width, int height, int bytes int gridSpacing, int lineWidth ) { blck = Color( width, height, bytes, 0,0,0,0,0 ); zozoX = ColorX(blck, {{ u=(x%gridSpacing)<lineWidth, v=(y%gridSpacing)<lineWidth, nr=u+v }}, g,b,a,z ); return Reorder(zozoX,"rrrr"); }; johnnyrico = Grid(143, 131, 26, 4); |
To speed things up, we only work on the red channel, which we then apply to the other channels with the faster Reorder command. Because we are using a multi-line expression for the red channel, we have to enclose it in double curly-brackets. Is there a name for those, by the way? Also, each line is separated by a comma inside the expression. Anyway, if you, for some reason, decided to type this in the GUI, shake would automatically place those for you; you wouldn't insert them in the GUI. I put this in the scripting tutorials because its kind of messy. Here is the second, faster version: image Grid2( int width, int height, int bytes, int gridHeight, int gridWidth ) { Checker2 = Checker(width, height, bytes, gridHeight, gridWidth); Emboss1 = Emboss(Checker2, 10, 45, 30); Solarize1 = Solarize(Emboss1, 0.2, 1); ContrastLum1 = ContrastLum(Solarize1, 10, 0.5, 0); return Reorder(ContrastLum1, "rgbr"); }
|