using UnityEngine; using UnityEngine.UI; namespace Olympus { // Original vector symbols. Geometry stays editable and crisp at every Canvas scale. [RequireComponent(typeof(CanvasRenderer))] public sealed class TempleGlyph : MaskableGraphic { public enum Kind { Gear, Menu, Check, Cross, Plus, Book, Profile, Coin, Sound, Music, Hand, Brush, Letters, Reset, Trident, Laurel } public Kind kind; protected override void OnPopulateMesh(VertexHelper v) { v.Clear(); switch(kind) { case Kind.Gear: Ring(v,.5f,.5f,.29f,.13f);for(int i=0;i<8;i++){float a=i*Mathf.PI/4;Line(v,.5f+Mathf.Cos(a)*.23f,.5f+Mathf.Sin(a)*.23f,.5f+Mathf.Cos(a)*.43f,.5f+Mathf.Sin(a)*.43f,.13f);}break; case Kind.Menu:for(int i=0;i<3;i++)Line(v,.18f,.28f+i*.22f,.82f,.28f+i*.22f,.08f);break; case Kind.Check:Line(v,.14f,.49f,.4f,.24f,.12f);Line(v,.4f,.24f,.87f,.79f,.12f);break; case Kind.Cross:Line(v,.24f,.24f,.76f,.76f,.1f);Line(v,.24f,.76f,.76f,.24f,.1f);break; case Kind.Plus:Line(v,.18f,.5f,.82f,.5f,.12f);Line(v,.5f,.18f,.5f,.82f,.12f);break; case Kind.Book: Quad(v,.12f,.2f,.47f,.8f);Quad(v,.53f,.2f,.88f,.8f);Line(v,.5f,.16f,.5f,.84f,.035f);break; case Kind.Profile:Disc(v,.5f,.68f,.19f);Poly(v,new[]{new Vector2(.18f,.16f),new Vector2(.2f,.3f),new Vector2(.32f,.43f),new Vector2(.68f,.43f),new Vector2(.8f,.3f),new Vector2(.82f,.16f)});break; case Kind.Coin:Ring(v,.5f,.5f,.45f,.37f);Ring(v,.5f,.5f,.31f,.29f);Line(v,.5f,.25f,.5f,.75f,.08f);Line(v,.31f,.58f,.68f,.42f,.08f);break; case Kind.Sound:Quad(v,.17f,.37f,.34f,.63f);Line(v,.34f,.5f,.56f,.7f,.17f);Line(v,.34f,.5f,.56f,.3f,.17f);Line(v,.75f,.3f,.83f,.5f,.05f);Line(v,.83f,.5f,.75f,.7f,.05f);break; case Kind.Music:Line(v,.4f,.24f,.4f,.78f,.07f);Line(v,.4f,.78f,.78f,.87f,.09f);Line(v,.78f,.87f,.78f,.33f,.07f);Disc(v,.29f,.24f,.13f);Disc(v,.67f,.33f,.13f);break; case Kind.Hand:Quad(v,.3f,.22f,.7f,.58f);for(int i=0;i<4;i++)Line(v,.31f+i*.11f,.5f,.31f+i*.11f,.8f- Mathf.Abs(i-1.5f)*.08f,.08f);Line(v,.3f,.35f,.16f,.52f,.09f);break; case Kind.Brush:Line(v,.28f,.25f,.72f,.8f,.13f);Disc(v,.23f,.2f,.13f);break; case Kind.Letters:Line(v,.2f,.22f,.5f,.8f,.09f);Line(v,.5f,.8f,.8f,.22f,.09f);Line(v,.32f,.43f,.68f,.43f,.06f);break; case Kind.Reset:Ring(v,.5f,.5f,.31f,.24f);Line(v,.15f,.56f,.14f,.83f,.07f);Line(v,.14f,.83f,.42f,.78f,.07f);break; case Kind.Trident:Line(v,.5f,.1f,.5f,.87f,.065f);Line(v,.25f,.7f,.25f,.45f,.06f);Line(v,.75f,.7f,.75f,.45f,.06f);Line(v,.25f,.45f,.5f,.35f,.06f);Line(v,.75f,.45f,.5f,.35f,.06f);for(int i=0;i<3;i++){float x=.25f+i*.25f,y=i==1?.92f:.78f;Line(v,x-.07f,y-.11f,x,y,.055f);Line(v,x+.07f,y-.11f,x,y,.055f);}break; case Kind.Laurel: float aspect=rectTransform.rect.height/Mathf.Max(1,rectTransform.rect.width); for(int side=-1;side<=1;side+=2)for(int i=0;i<7;i++) { float x=(side<0?.06f:.94f)+side*Mathf.Sin(i*.38f)*.09f*aspect,y=.1f+i*.105f; float tip=x-side*.14f*aspect; var leaf=new Vector2[18]; for(int j=0;j<=8;j++) { float t=j/8f,bulge=Mathf.Sin(t*Mathf.PI)*.035f;var axis=new Vector2(Mathf.Lerp(x,tip,t),y+t*.14f);var normal=new Vector2(bulge*aspect,side*bulge); leaf[j]=axis+normal;leaf[17-j]=axis-normal; } Poly(v,leaf); }break; } } Vector2 P(float x,float y){var r=rectTransform.rect;return new Vector2(r.x+x*r.width,r.y+y*r.height);} Color Shade(float y)=>color*Color.Lerp(new Color(.64f,.39f,.16f,1),Color.white,Mathf.Clamp01(y+.2f)); void Quad(VertexHelper v,float x,float y,float xx,float yy){Poly(v,new[]{new Vector2(x,y),new Vector2(x,yy),new Vector2(xx,yy),new Vector2(xx,y)});} void Poly(VertexHelper v,Vector2[] points){int n=v.currentVertCount;foreach(var p in points)v.AddVert(P(p.x,p.y),Shade(p.y),Vector2.zero);for(int i=1;i