Wolfram Research

Function Repository Resource:

RegionInputField (1.0.0) current version: 1.1.0 »

Source Notebook

User interface for drawing 2D mesh regions

Contributed by: Jon McLoone  |  Jon McLoone

ResourceFunction["RegionInputField"][Dynamic[var]]

creates a user interface for drawing a MeshRegion which updates var.

Details and Options

ResourceFunction["RegionInputField"] supports all options for RegionPlot.
Clicking the Undo button in the interface undoes the most recent edit to the region.

Examples

Basic Examples (4) 

Draw the outline of the desired region:

In[1]:=
ResourceFunction["RegionInputField"][Dynamic[x]]
Out[1]=

Draw additional areas which will be included in the same region:

Set the SetterBar to "Remove" to subtract drawn areas from the region:

The Dynamic variable is updated with the drawn region:

In[2]:=
x
Out[2]=

Options (2) 

RegionInputField supports the options of RegionPlot. These affect the appearance of interface but not the output Region:

In[3]:=
ResourceFunction["RegionInputField"][Dynamic[x], PlotStyle -> Red]
Out[3]=

The default PlotRange is {{0,1},{0,1}}, which limits the coordinates that you can draw over. To create regions with larger coordinates, set the PlotRange for the RegionInputField:

In[4]:=
ResourceFunction["RegionInputField"][Dynamic[x], Frame -> True, PlotRange -> {{-100, 100}, {-100, 100}}]
Out[4]=

Applications (1) 

Calculate geometric properties of your region in real-time as it updates:

In[5]:=
DynamicModule[{x}, Column[{ResourceFunction["RegionInputField"][Dynamic[x], ImageSize -> {300, 300}],
   TextGrid[{{"Area: ", Dynamic[Area[x]]}, {"Perimeter: ", Dynamic[Perimeter[x]]}}]}]]
Out[5]=

Version History

  • 1.1.0 – 20 May 2022
  • 1.0.0 – 16 October 2019

License Information