# How to draw the outline of an icon made of several polygons?

I have an icon defined like that:

speakerIcon = Graphics[{
Triangle[{{0, -1}, {1,1},{-1,1}}],
Rectangle[{-1, -1},{1, 0}]
}, ImageSize->20]


I can display that icon in an arbitrary color by wrapping it inside Show:

Show[Graphics[FaceForm[Pink]], speakerIcon]


But how to draw only the outline of the icon? Using EdgeForm does not work since it displays the outline of each component of the graphic object:

Show[
Graphics[FaceForm[]],
Graphics[EdgeForm[{Thick,Blue}]],
speakerIcon, ImageSize->100
]


FWIW, I suspect I didn't follow the "right" path by defining my region as a Graphics. Maybe using Region would have been better? I'm open to any suggestions.

With Mathematica 12 a possible approach is OuterPolygon:

pol = Polygon[{{{0, -1}, {1, 1}, {-1, 1}}, {{-1, -1}, {1, -1}, {1,
0}, {-1, 0}}}]
Graphics[{FaceForm[], EdgeForm[{Thick, Blue}], pol}]


Graphics[{FaceForm[], EdgeForm[{Thick, Blue}], OuterPolygon[pol]}]


• Merci beaucoup André! I still have to try it, but I think I will follow that path (pun intended) because, as I explained in a comment to the @kglr's answer, I'm somewhat uncomfortable in constantly converting from graphics to regions and back. Commented Feb 24, 2020 at 11:55

You can use BoundaryDiscretizeGraphics:

bdg = BoundaryDiscretizeGraphics @ speakerIcon


Graphics[{EdgeForm[{Black, Thin}], FaceForm[], MeshPrimitives[bdg, 2]}, ImageSize -> 30]


Alternatively, you can use BoundaryDiscretizeRegion + RegionUnion:

bdr = BoundaryDiscretizeRegion[
RegionUnion[Triangle[{{0, -1}, {1, 1}, {-1, 1}}], Rectangle[{-1, -1}, {1, 0}]]]


• Thanks, @kglr. One side comment: when drawing shapes, I noticed I often have to convert between Graphics objects and Region, in one direction or the other. I read regions are a recent addition to Mathematica. Does that mean a rule of thumb would be to use them exclusively and considering Graphics only to render the output? On the other hand, it seems quite a waste of resources to convert even the simplest polygons to mesh objects. Commented Feb 24, 2020 at 11:51
• @SylvainLeroux, TIL from andre's answer that it may not be necessary to go through Region for some shapes.
– kglr
Commented Feb 24, 2020 at 17:54