Message Boards Message Boards

Dynamic module, locator pane, area calculation initial execution error?

Posted 8 years ago

The following code implements a grid with a polygon that can have its locator points moved and finds the area of the polygon. When initially executed the area is not calculated and gives an error message. But once you click on a locator to move it or even if it stays where it is the code executes properly. Can anyone see where my error is or how to fix the code to avoid this initial error?

DynamicModule[{pts = {{5, 0}, {9, 2}, {9, 6}, {11, 10}, {4, 10}, {3, 
     7}, {3, 5}, {2, 1}, {3, 1}}},
 Column[{
   LocatorPane[
    Dynamic[pts],
    Graphics[{
      Table[Point[{n, m}], {n, 0, 14, 1}, {m, 0, 10, 1}],
      EdgeForm[{Thick, Black}], Transparent, Polygon[Dynamic[pts]]
      }, ImageSize -> Large],
    {{0, 0}, {11, 15}, {0.5, 0.5}}, LocatorAutoCreate -> True
    ],
   Dynamic[Area[Polygon[pts]]]
   }]
 ]

Thank you.

POSTED BY: Miles Ford

Seems to be some weird bug I think...

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract