Mechanical Properties And Phase Transitions In Hard Polygons And The Origin Of Colloidal Crystal Photonic Band Gaps