Wolfram Research

Function Repository Resource:

SymbolToPolygon

Source Notebook

Return a polygon, given a symbol

Contributed by: Ed Pegg Jr

ResourceFunction["SymbolToPolygon"][symbol,dimension]

returns symbol as a polygon with vertices in dimension.

Details and Options

The value of dimension can be "2D" or "3D" (the default).
The first argument can also be a String.

Examples

Basic Examples

Label the sides of a cube:

In[1]:=
tab = {{0, {0, 1, 0}}, {Pi/2, {0, 1, 0}}, {Pi/2, {1, 0, 0}}, {-Pi/
     2, {1, 0, 0}}, {-Pi/2, {0, 1, 0}}, {Pi, {0, 1, 0}} };
Graphics3D[
 Table[Polygon[
   ResourceFunction["SymbolToPolygon"][ToString[n]][[
     1]].RotationMatrix[tab[[n, 1]],
     tab[[n, 2]]]], {n, 1, 6}]]
Out[2]=

Return a 2D polygon for 42:

In[3]:=
Graphics[{EdgeForm[Black], Red, ResourceFunction["SymbolToPolygon"]["42", "2D"]}]
Out[3]=

Scope

Different styles and fonts can be used:

In[4]:=
Graphics3D[
 ResourceFunction["SymbolToPolygon"][
  Style["8", FontFamily -> "Times", Italic]]]
Out[4]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information