Пример #1
0
        public override void PreRender()
        {
            var lines = text.ToString().Split('\n');

            int anchorY = 0;

            switch (verticalAlignment)
            {
            case VerticalAlignment.Top:
                anchorY = 0;
                break;

            case VerticalAlignment.Middle:
                var halfWidth     = Node.Bounds.Height / 2;
                var halfTextCount = lines.Length / 2;
                anchorY = halfWidth - halfTextCount;
                break;

            case VerticalAlignment.Bottom:
                anchorY = Node.Bounds.Height - lines.Length;
                break;
            }

            for (int i = 0; i < lines.Length; i++)
            {
                var line = lines[i];

                int anchorX = 0;

                switch (horizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    anchorX = 0;
                    break;

                case HorizontalAlignment.Center:
                    var halfWidth     = Node.Bounds.Width / 2;
                    var halfTextCount = (line.Length % 2 == 0)? line.Length / 2 : (line.Length - 1) / 2;
                    anchorX = halfWidth - halfTextCount;
                    break;

                case HorizontalAlignment.Right:
                    anchorX = Node.Bounds.Width - line.Length;
                    break;
                }

                for (int j = 0; j < line.Length; j++)
                {
                    var offset = new Math.Vector2Int(anchorX + j, anchorY + i);
                    Node.ParentCanvas.SetPixel(line[j], Node.Bounds.Position + offset);
                }
            }
        }
Пример #2
0
 public virtual void OnNodePositionChanged(Math.Vector2Int pos)
 {
 }
Пример #3
0
 public virtual void OnNodeSizeChanged(Math.Vector2Int size)
 {
 }