예제 #1
0
        public static UIRectVO Rect(this UICanvas canvas, float x, float y, float width, float height)
        {
            var vo = new UIRectVO();

            vo.rect        = new Rect(x, y, width, height);
            vo.fill        = canvas.strokeStyle.fill;
            vo.fillColor   = canvas.strokeStyle.fillColor;
            vo.thickness   = canvas.strokeStyle.thickness;
            vo.strokeColor = canvas.strokeStyle.strokeColor;
            vo.stroke      = canvas.strokeStyle.stroke;
            canvas.DrawingGraphics.Add(vo);
            return(vo);
        }
예제 #2
0
        public static void DrawRect(this UICanvas canvas, List <UIVertex> vertices, List <int> indices, UIRectVO rectVO)
        {
            Rect    rect = rectVO.rect;
            Vector2 TL   = rect.position;
            Vector2 TR   = new Vector2(rect.xMax, rect.yMin);
            Vector2 BR   = new Vector2(rect.xMax, rect.yMax);
            Vector2 BL   = new Vector2(rect.xMin, rect.yMax);

            if (rectVO.fill)
            {
                var polygon = new List <Vector2>()
                {
                    TL, TR, BR, BL
                };
                canvas.FillPolygon(vertices, indices, polygon, rectVO.fillColor, rectVO.name);
            }
            if (rectVO.stroke)
            {
                var polygon = new List <Vector2>()
                {
                    TL, TR, BR, BL, TL
                };
                canvas.StrokePolygon(vertices, indices, polygon, rectVO.thickness, rectVO.strokeColor);
            }
        }