Exemplo n.º 1
0
        protected override void UpdateDrawable()
        {
            base.UpdateDrawable();

            SFMLVertices.Clear();

            var finalColors = new List <Color>()
            {
                Color.None,
                Color.None,
                Color.None,
                Color.None
            };

            for (int i = 0; i < baseColors.Count; i++)
            {
                finalColors[i]    = new Color(baseColors[i]);
                finalColors[i].A *= Alpha;
            }

            SFMLVertices.Append(new Vertex(new Vector2f(0, 0), finalColors[0].SFMLColor));
            SFMLVertices.Append(new Vertex(new Vector2f(Width, 0), finalColors[1].SFMLColor));
            SFMLVertices.Append(new Vertex(new Vector2f(Width, Height), finalColors[2].SFMLColor));
            SFMLVertices.Append(new Vertex(new Vector2f(0, Height), finalColors[3].SFMLColor));
        }
Exemplo n.º 2
0
        protected override void UpdateDrawable()
        {
            base.UpdateDrawable();

            SFMLVertices.Clear();

            foreach (var layer in TileLayers.Reverse())
            {
                foreach (var tile in layer.Value)
                {
                    tile.Alpha = Alpha;
                    tile.AppendVertices(SFMLVertices);
                }
            }
        }
Exemplo n.º 3
0
        protected override void UpdateDrawable()
        {
            base.UpdateDrawable();

            SFMLVertices.Clear();

            foreach (var layer in TileLayers.Reverse())
            {
                //for (int i = TileLayers.Count - 1; i >= 0; i--) {
                //    var layer = TileLayers.Values[i];
                foreach (var tile in layer.Value)
                {
                    //tile.Alpha = Alpha;
                    tile.tilemapColor.R = Color.R;
                    tile.tilemapColor.G = Color.G;
                    tile.tilemapColor.B = Color.B;
                    tile.tilemapColor.A = Color.A;
                    tile.AppendVertices(SFMLVertices);
                }
            }
        }
Exemplo n.º 4
0
        protected override void UpdateDrawable()
        {
            base.UpdateDrawable();

            SFMLVertices.Clear();

            float maxX = float.MinValue;
            float minX = float.MaxValue;
            float maxY = float.MinValue;
            float minY = float.MaxValue;

            foreach (var img in images)
            {
                img.UpdateDrawableIfNeeded();

                for (uint i = 0; i < img.GetVertices().VertexCount; i++)
                {
                    var v = img.GetVertices()[i];

                    var transform = SFML.Graphics.Transform.Identity;
                    transform.Translate(img.X - img.OriginX, img.Y - img.OriginY);
                    transform.Rotate(img.Angle, img.OriginX, img.OriginY);
                    transform.Scale(img.ScaleX, img.ScaleY, img.OriginX, img.OriginY);

                    var p = transform.TransformPoint(v.Position.X, v.Position.Y);

                    maxX = Util.Max(maxX, p.X);
                    minX = Util.Min(minX, p.X);
                    maxY = Util.Max(maxY, p.Y);
                    minY = Util.Min(minY, p.Y);

                    SFMLVertices.Append(p.X, p.Y, img.Color, v.TexCoords.X, v.TexCoords.Y);
                }
            }

            Width  = Math.Abs((int)Util.Ceil(maxX - minX));
            Height = Math.Abs((int)Util.Ceil(maxY - minY));
        }
Exemplo n.º 5
0
        protected override void UpdateDrawable()
        {
            base.UpdateDrawable();

            if (isCircle)
            {
                var circle = new CircleShape(radius);
                circle.OutlineThickness = OutlineThickness;
                circle.OutlineColor     = OutlineColor.SFMLColor;
                circle.FillColor        = Color.SFMLColor;
                circle.SetPointCount((uint)CirclePointCount);
                SFMLDrawable = circle;
                Width        = (int)circle.GetLocalBounds().Width;
                Height       = (int)circle.GetLocalBounds().Height;
            }
            else
            {
                if (isShape)
                {
                    var rect = new RectangleShape(new Vector2f(rectWidth, rectHeight));
                    rect.OutlineColor     = OutlineColor.SFMLColor;
                    rect.OutlineThickness = OutlineThickness;
                    rect.FillColor        = Color.SFMLColor;
                    SFMLDrawable          = rect;
                    Width  = (int)rect.GetLocalBounds().Width;
                    Height = (int)rect.GetLocalBounds().Height;
                }
                else
                {
                    SFMLVertices.Clear();

                    float x1, y1, x2, y2, u1, v1, u2, v2, cx1, cy1, cx2, cy2;

                    cx1 = ClippingRegion.Left;
                    cy1 = ClippingRegion.Top;
                    cx2 = ClippingRegion.Right;
                    cy2 = ClippingRegion.Bottom;

                    x1 = Util.Max(0, cx1);
                    u1 = TextureLeft + x1;

                    if (FlippedX)
                    {
                        u1 = TextureRegion.Width - u1 + TextureLeft + TextureRegion.Left;
                    }

                    y1 = Util.Max(0, cy1);
                    v1 = TextureTop + y1;

                    if (FlippedY)
                    {
                        v1 = TextureRegion.Height - v1 + TextureTop + TextureRegion.Top;
                    }

                    x2 = Util.Min(TextureRegion.Right, cx2);
                    u2 = TextureLeft + x2;

                    if (FlippedX)
                    {
                        u2 = TextureRegion.Width - u2 + TextureLeft + TextureRegion.Left;
                    }

                    y2 = Util.Min(TextureRegion.Bottom, cy2);
                    v2 = TextureTop + y2;

                    if (FlippedY)
                    {
                        v2 = TextureRegion.Height - v2 + TextureTop + TextureRegion.Top;
                    }

                    SFMLVertices.Append(x1, y1, Color, u1, v1);
                    SFMLVertices.Append(x1, y2, Color, u1, v2);
                    SFMLVertices.Append(x2, y2, Color, u2, v2);
                    SFMLVertices.Append(x2, y1, Color, u2, v1);

                    Width  = TextureRegion.Width;
                    Height = TextureRegion.Height;
                }
            }
        }