0
$\begingroup$

Background. I have a function ( stored in a package ) that creates 2D graphic images, its prototype looks like this:

  question[wi_, he_, co_] :=
   DynamicModule[{},
    Manipulate[
      Graphics[{Translate[{color, Rectangle[{0, 0}, {.8, .4}]}, 
        Tuples[{Range[width], Range[heigth]}]]}],
     {color, Red}, {width, 1, 5}, {heigth, 1, 5}, 
     Initialization :> {color = co, width = wi, heigth = he}]] 

In the actual function the Graphics function is enclosed in a Dynamic[]. The function works as expected.

Something that I don't understand happens when I do the following: 1) right-click ( Windows ) on an image and paste the image to elsewhere in the notebook; 2) repeat this for several different width / height combinations. 3) save the notebook 4) open the notebook 5) execute the function but with a different color, THEN: the color of the pasted images changes as well.

Question: How can I permanently copy and paste ( not, in any way, linked to code ) a graphic created in a Notebook with Graphics2D?

EDIT(2) per request of halirutan :

Cell[BoxData[ GraphicsBox[GeometricTransformationBox[GeometricTransformationBox[ DynamicBox[TypesetToBoxes[ MapThread[FEY2Y2Privatefun$$93, {FE`Y2`Y2`Private`ptlst$$93, FE`Y2`Y2`Private`tplst$$93, FE`Y2`Y2`Private`colst$$93}], StandardForm, Graphics], ImageSizeCache->{{89.7606933090101, 182.2393066909899}, {81.76069330901011, 169.2393066909899}}], {{{{1, 0}, {0, 1}}, {0, 0}}, {{{-1, 0}, {0, 1}}, {1, 0}}, {{{1, 0}, {0, -1}}, {0, 1}}, {{{-1, 0}, {0, -1}}, {1, 1}}}], {{{0, 0}}, {{-0.7071067811865475, 0.7071067811865475}}, {{0.7071067811865475, 0.7071067811865475}}, {{0, 1.4142135623730951}}}], PlotRegion->Automatic]], "Input"]

$\endgroup$
8
  • $\begingroup$ Does not happen here (MacOSX). Can you go on such a pasted graphics, press Ctrl+Shift+E (Cell -> Show Expression) and post the output here? And it would be helpful if you would specify the system you are using (OperatingSystem, Mma Version, ..) $\endgroup$
    – halirutan
    Jun 7, 2012 at 12:46
  • $\begingroup$ @halirutan - I use Windows 7, Mathematica 8. $\endgroup$ Jun 7, 2012 at 13:00
  • $\begingroup$ Then someone with Windows has to fix this, because your Cell-data still contains the dynamically updated front-end variables. This is not the case here. It seems you are not copying the image only. $\endgroup$
    – halirutan
    Jun 7, 2012 at 13:02
  • $\begingroup$ Question: You click first with left-click on the image, then the image gets a frame. Then you make right-click and go on copy-graphic. If you insert this and press Ctrl+Shit+E you such a long cell-expression like the above one? $\endgroup$
    – halirutan
    Jun 7, 2012 at 13:05
  • 2
    $\begingroup$ I'm on Windows 7 and Mathematica 8 too, and I can't reproduce this. Copy/paste of the graphic produced by e.g. question[3, 5, Red] yields for me a cell lacking the DynamicBox and without reference to any FE variables. $\endgroup$ Jun 7, 2012 at 17:56

1 Answer 1

5
$\begingroup$

I can't reproduce this either but assuming that what you want is for your copied graphic to stop updating ...right? In that case when you copy and paste just highlight the cell bracket in the pasted cell and from the menu Evaluation > Convert Dynamic To Literal. This will remove the dynamic updating. You could also try pasting the graphic into an input cell:

pasted graphic /. Dynamic -> Identity

and evaluate and see if that works (I've had success with that in the past).

$\endgroup$
1
  • $\begingroup$ Convert Dynamic To Literal is what I was looking for. All I could find about it in the document was a one sentence cryptic description. "Convert Dynamic to Literal - replaces each selected dynamic object with its most recent static value." How was I was supposed to know this ? $\endgroup$ Jun 8, 2012 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.