# Dynamically transform one Graphics to another

I would like to have two Graphics objects displayed side by side such that:

• they are mirror images of each other
• if I change the left-hand one interactively using Drawing Tools, the other one is updated automatically.

I can't seem to convince Dynamic, Manipulate and friends to do this for me. How can I do it?

A more basic question would be: how do I create a variable which holds a Graphics object and such that its value can be changed interactively using Drawing Tools?

• Assuming you mean Graphics not Graph ... is Combining manipulated plots of any help? – user9660 Aug 13 '14 at 16:07
• Did I write "Graph" anywhere by accident? – Andrej Bauer Aug 13 '14 at 16:12
• No, that question just asks how to have to dynamic Graphics objects next to each other. I want one of them to reflect the content of the other, dynamically, so that if I edit interactively the one, the other changes. – Andrej Bauer Aug 13 '14 at 16:14
• I was pointing to the second answer, good luck. – user9660 Aug 13 '14 at 16:19
• I think it is likely that this is impossible. Variables get their values from the kernel, but Drawing Tools works entirely in the front end. There isn't any variable that holds the updates that you do to the image. – C. E. Aug 14 '14 at 2:40

This solution may generate a storm of criticisms but may also give you an idea of a path to follow to get where you want. Note that this solution works perfectly in Mathematica 9 but in Mathematica 10 there is a problem that is preventing the last Graphics object added to copy to the right side with the right colors.

    g = Graphics[{Yellow, Disk[]}, ImageSize -> 200];
rightSide = Style["Left side will be copied here.", Gray, Italic];
Deploy@Panel@
Grid[{{
Labeled[Button["Copy to Right Side",
rs =
cellContents[[Sequence @@
Position[cellContents, GridBox[{{_, _}}, ___]][[2]]]][[1,
1, 1, 1, 2]];
rightSide =
ReplaceAll[DisplayForm@rs, GraphicsBox -> Graphics];
]
, ImageSize -> Automatic
], Style[g, Deployed -> False]]
,
Labeled[
"Copy of Left Side"
, Dynamic@rightSide
]
}}
, Alignment -> Left
]


This is how it looks after the first evaluation:

And this is how it looks after adding two Graphics elements and pressing the "Copy to Right Side" button.

Another apporach is to make a Manipulate that does what you want. For example, here is one that draws a polygon. Whenever you move the points of the left polygon, the one on the right moves in mirror symmetry.

Manipulate[Graphics[{Polygon[p], Red, Polygon[ConstantArray[{10, 0}, 4] - p]}],
{{p, {{1, 1}, {2, 2}, {-1, 1}, {-2, -2}}}, Locator}]


• The main point is that the solution works when Drawing Tools is used. – Ariel Sepulveda Aug 25 '14 at 1:24
• Well, I read the OPs comment "If I have to give up on the Drawing tools then I could at least make a simple drawing canvas. That would work" and thought an alternative approach (ie., a "simple drawing canvas") might be useful. – bill s Aug 25 '14 at 1:26
• How could I do this but have two Graphics objects, so the shapes can't get mixed up? If I place the red object into another Graphics and then combine them with Grid, I think the locators are screwed up (they are relative to the entire grid, not just the left-hand Graphics). – Andrej Bauer Aug 25 '14 at 6:24

Well, despite Drawing tools only works in FrontEnd, you can always get the CellExpression directly:

Grid[{
{"draw here:", "watch it here:"},
{Graphics[],
Dynamic[Refresh[
Cases[