You are looking at the screen of a Girardeau
personal workstation running the Cedar programming environment.
In the left column of the screen is a Gargoyle graphical editing
window.
In the right column is the Match tool,
a fill-in-the-form-style interface for specifying
graphical search and replace operations.
At the bottom of the Gargoyle window, we have a freeway map.
We will use the Match tool to change some of the Highway 17
signs to Interstate 880 signs.
We want to search for all Highway 17 signs,
so I select one of them and copy it
into the Search pane of the Match tool.
I select an 880 sign and copy it over to the Highway 17 sign
to show the Match tool how the new shape should be placed
relative to the old shape.
I copy the properly placed 880 sign
to the Replace pane of the Match tool.
Further down the Match tool are four buttons--
Search, Yes, No, and Change All.
I will use these buttons to make replacements.
In the Gargoyle window, I place my software cursor, the carrot,
above the highway map.
The Match tool begins its search at the carrot
and proceeds downward.
Now I click the Search button.
The Match tool finds the top-most Highway 17 sign
and selects it.
If I click the Yes button, the Match tool
makes the replacement and finds the next sign.
Again, I click Yes to make a second replacement.
Highway 17 has only been renamed north of 280.
I click the No button to leave the last sign as it is.
Let's use the Match tool to make a fractal snowflake.
We are going to replace each segment of this triangle
with four smaller segments, as shown at the top of the window.
The arrows drawn on top of the lines
show the direction in which they were drawn.
We will use this information to guide the replacement
operation.
I copy the line segment into the Match tool
as the search pattern.
For this search, I must specify some additional search
parameters.
Because I want to search for rotated versions of the line
segment, I activate Rotation and Variance.
Because I want to search for versions of the line segment
at different sizes, I activate Scale and Variance.
In addition, I activate the Polarity option,
which tells the Match tool to match
two shapes aligning the directions in which they
were drawn.
Because we are searching for individual segments
of an object rather than an entire object,
I use the finest search granularity.
Now I align the replacement shape with the search shape
and copy it into the Match tool's Replace pane.
I place the carrot above the triangle
and hit the Change All button.
Each of the three segments of the triangle
is replaced by the four-segment pattern.
To get a fancier snowflake, I repeat the replacement.
Because Scale and Variances is on,
the Match tool finds the new, shorter line segments
and replaces each of them with a smaller copy of the replacement
pattern.
The Match tool can be used to change
some properties of the match shapes
while leaving others intact.
To make a multicolored fractal snowflake,
we might start with a multicolored triangle
and have the Match tool replace the shape of each segment
but leave the line color alone.
To do this, we use the Search and Replace columns
of the Match tool.
In the Search column, black boxes
indicate what properties of the search pattern
must match corresponding properties in the scene.
We are currently looking for objects
of the same shape, object class, and curve type
as the search pattern.
We do not care what line color the scene objects have.
Hence, our search pattern will match
all of our differently colored segments.
The black boxes in the Replace column
indicate what properties of the shapes in the Replace pane
will be transferred to the match shapes.
Currently, all properties of the replacement shapes
will be transferred.
However, if we turn off Line Color and Line Width,
then these properties will be left alone.
I placed the carrot above the triangle
and hit Change All in the Match tool.
Shape is replaced as before.
But this time, the line colors are left alone.
This method of creating recursive shapes
using replacement rules is called graphical grammars.
The snowflake curve made earlier is a recursive shape
made of line segments.
The Match tool can also make recursive shapes
with filled regions.
I will search for a black-bordered rectangle
and replace it with a solid black rectangle and two
black-bordered rectangles.
I tell the Match tool that area color and line color
are important and that it should match rectangles
at different rotations and scales.
I begin with a single black-bordered rectangle
and click Change All to perform the substitution.
I have activated Scale and Variance and Rotation
and Variance, so repeating Change
All causes the Match tool to find the new, smaller
rectangles and replace them with still smaller rectangles,
producing a binary tree.
As this example shows, graphical grammars
use the ability to search for object color
as well as object shape.
Graphical search and replace is also
useful for getting more use out of old pictures.
Here, we begin with a set of line patterns--
a spiral, a hexagon, a regular array of line segments,
and a random collection of line segments.
We have set up the Match tool to replace each segment
with a star.
With the Match tool and a library of line patterns,
we can easily position arbitrary shapes in any number
of patterns, regular or random.
We call this technique graphical templates.
Graphical search can be combined with operations
other than replacement.
For instance, we have built a graphical macro facility
that performs user-specified editing operations
on each set of matched objects.
Here, the Match tool is searching
for a box or an ellipse.
When it finds one, it performs a macro operation
that copies it, turns the copy gray,
and moves the copy underneath to give the object a drop shadow.
In summary, graphical search and replace
can be used to make coherent changes
to a picture with repeated scene elements,
can create recursive shapes using graphical grammars,
and can position shapes in predetermined patterns using
graphical templates.
Shapes can be found at arbitrary orientations and sizes.
The user can select which graphical properties of a scene
are important for each search and which
graphical properties of matched objects will be replaced.
Graphical search can also be combined
with a set of remembered operations
to produce a graphical macro facility.