In[]:=
ClearAll[drawPolygon]​​Options[drawPolygon]=Options[Graphics];​​drawPolygon::msg1="Second argument must be a RGBColor.";​​drawPolygon::msg2="First argument must be larger than 2.";​​drawPolygon::msg3="First argument must be an integer larger than 2.";​​drawPolygon[sides_Integer/;sides>2,color_RGBColor:Orange,opts:OptionsPattern[]]:=Graphics[{color,Polygon@CirclePoints[sides]},FilterRules[{opts},Options[Graphics]]]​​drawPolygon[_,color_/;!MatchQ[color,_RGBColor],___]:=""/;Message[drawPolygon::msg1]​​drawPolygon[sides_Integer/;sides≤2,___]:=""/;Message[drawPolygon::msg2]​​drawPolygon[sides_/;!IntegerQ[sides],___]:=""/;Message[drawPolygon::msg3]
In[]:=
drawPolygon[3]
Out[]=
In[]:=
drawPolygon[7,Blue,ImageSize->Small]
Out[]=
In[]:=
drawPolygon[16,RGBColor[0.7,0.5,0.9],ImageSizeTiny]
Out[]=
In[]:=
drawPolygon[2]
drawPolygon
::msg2
:First argument must be larger than 2.
​
Out[]=
drawPolygon[2]
In[]:=
drawPolygon[3,"Green"]
drawPolygon
::msg1
:Second argument must be a RGBColor.
​
Out[]=
drawPolygon[3,Green]
In[]:=
drawPolygon[3.5,17]
drawPolygon
::msg1
:Second argument must be a RGBColor.
​
drawPolygon
::msg3
:First argument must be an integer larger than 2.
​
Out[]=
drawPolygon[3.5,17]
In[]:=
drawPolygon[1.7,RGBColor[0.7,0.5,0.9]]
drawPolygon
::msg3
:First argument must be an integer larger than 2.
​
Out[]=
drawPolygon1.7,

In[]:=
drawPolygon[-5,Blue]
drawPolygon
::msg2
:First argument must be larger than 2.
​
Out[]=
drawPolygon-5,
