If I have a function call wrapped in Dynamic can I make one or more of the parameters in the call non-dynamic?
i.e. I would like to make diskcx and diskcy in the following snippet be unaffected by changes in their values after the call while making the output of colorer and the value of rectangleCoordinates dynamic:
...Graphics[
{Dynamic[colorer[
rectangleCoordinates, {radius + diskcx, diskcy}, .4 radius]], Disk[{radius + diskcx, diskcy}, .4 radius]....
Edit: As requested, here is the relatively large block of code the problem is concerned with. Of note is that: rectangleCoordinates refers to a set of rectangles that can pass over a disk to change its color;colorer[rectangles_,center_,radius_] is a function whose output is a color that depends on whether a rectangle passes over the disk defined by the center and radius that are given as parameters; the radius variable is defined outside the module; and of course as a precondition amount_ is never greater than 5.
diskGenerator[amount_, space_] :=
Module[{z = 1, listx, listy, positionx, positiony, diskcx, diskcy,
intervals = space/11, disks = {}},
listx = {1, 3, 5, 7, 9};
listy = {1, 2, 3, 7, 8, 9, 10};
For[z = 1, z <= amount, z++,
positionx = RandomChoice[listx];
positiony = RandomChoice[listy];
listx = DeleteCases[listx, positionx];
(*listy=DeleteCases[listy,positiony];*)
diskcx = positionx*intervals;
diskcy = positiony*intervals;
disks =
AppendTo[disks,
Graphics[{
Dynamic[colorer[rectangleCoordinates, {radius + diskcx, diskcy}, .4 radius]],
Disk[{radius + diskcx, diskcy}, .4 radius],
Dynamic[colorer[rectangleCoordinates, {.5 radius + diskcx, Sqrt[3]/2 radius + diskcy}, .4 radius]],
Disk[{.5 radius + diskcx, Sqrt[3]/2 radius + diskcy}, .4 radius],
Dynamic[colorer[rectangleCoordinates, {-.5 radius + diskcx, Sqrt[3]/2 radius + diskcy}, .4 radius]],
Disk[{-.5 radius + diskcx, Sqrt[3]/2 radius + diskcy}, .4 radius],
Dynamic[colorer[rectangleCoordinates, {-radius + diskcx, diskcy}, .4 radius]],
Disk[{-radius + diskcx, diskcy}, .4 radius],
Dynamic[colorer[rectangleCoordinates, {-.5 radius + diskcx, -(Sqrt[3]/2) radius + diskcy}, .4 radius]],
Disk[{-.5 radius + diskcx, -(Sqrt[3]/2) radius + diskcy}, .4 radius],
Dynamic[colorer[rectangleCoordinates, {.5 radius + diskcx, -(Sqrt[3]/2) radius + diskcy}, .4 radius]],
Disk[{.5 radius + diskcx, -(Sqrt[3]/2) radius + diskcy}, .4 radius],
Dynamic[colorer[rectangleCoordinates, {diskcx, diskcy}, .5 radius]],
Disk[{diskcx, diskcy}, .5 radius]
}]
]
];
Return[disks]
];
I'm thinking I should just create a List of diskcx and diskcy values that the function would refer to just to avert the problem, but if this solution seems unsound I would be happy to read others. Thanks for your time, in any case.
rectangles_was part of the signature ofcolorer: the name of its parameter. Apologies for that confusion. As you suggested I'll moveintervalsoutside the variable list. You were correct, however, the issue was in the way it was being called, which is what Mr. Wizard's comment below has now addressed. I think with that solved I shouldn't have any other problems with this project I'm working on. Thank you for all your advice though. – May 06 '12 at 19:16