public Chart2DSpriteContainer(SpriteSet<UVColorVertexData> sprites, FontGeometry fontGeo,
            VertexSurface<FastChart2DBarVertex> fastBarSurface = null)
        {
            this.line = (Sprite2DGeometry)sprites["line"].Geometry;
            this.point = (Sprite2DGeometry)sprites["point"].Geometry;

            this.surface = sprites.Surface;

            this.quadUV = sprites["quad"].Geometry.UV;

            this.font = fontGeo;

            this.ThinLineWidth = 0.015f;
            this.ThickLineWidth = 0.03f;
            this.SmallPointSize = 0.03f;
            this.LargePointSize = 0.1f;
            this.Color = Color.DeepPink;

            if (fastBarSurface != null)
            {
                this.fastBarSurface = fastBarSurface;
                this.fastBarSurface.AddSettings(sprites.Surface.Settings);
                this.fastBarSurface.AddSettings(
                    new Vector2Uniform("uv01", this.quadUV.TopLeft),
                    new Vector2Uniform("uv11", this.quadUV.TopRight),
                    new Vector2Uniform("uv00", this.quadUV.BottomLeft),
                    new Vector2Uniform("uv10", this.quadUV.BottomRight)
                    );
            }
        }
        public Chart2DSpriteContainer(SpriteSet <UVColorVertexData> sprites, FontGeometry fontGeo,
                                      VertexSurface <FastChart2DBarVertex> fastBarSurface = null)
        {
            this.line  = (Sprite2DGeometry)sprites["line"].Geometry;
            this.point = (Sprite2DGeometry)sprites["point"].Geometry;

            this.surface = sprites.Surface;

            this.quadUV = sprites["quad"].Geometry.UV;

            this.font = fontGeo;

            this.ThinLineWidth  = 0.015f;
            this.ThickLineWidth = 0.03f;
            this.SmallPointSize = 0.03f;
            this.LargePointSize = 0.1f;
            this.Color          = Color.DeepPink;

            if (fastBarSurface != null)
            {
                this.fastBarSurface = fastBarSurface;
                this.fastBarSurface.AddSettings(sprites.Surface.Settings);
                this.fastBarSurface.AddSettings(
                    new Vector2Uniform("uv01", this.quadUV.TopLeft),
                    new Vector2Uniform("uv11", this.quadUV.TopRight),
                    new Vector2Uniform("uv00", this.quadUV.BottomLeft),
                    new Vector2Uniform("uv10", this.quadUV.BottomRight)
                    );
            }
        }
Beispiel #3
0
        /// <summary>
        /// Retuns the boxed <see cref="UVRectangle"/> after applying the given scalar, if the uv rectangle is marked as having absolute positions.
        /// </summary>
        /// <param name="uvSize">The absolute size of the texture this <see cref="UVRectangle"/> is a part of</param>
        public UVRectangle GetUVRectangle(Vector2 uvSize)
        {
            if (!this.absolute)
            {
                return(this.uv);
            }
            UVRectangle uv    = this.uv;
            Vector2     scale = new Vector2(1f / uvSize.X, 1f / uvSize.Y);

            uv.ReScale(scale);
            return(uv);
        }
Beispiel #4
0
        /// <summary>
        /// Reads a string from the reader, and converts it to a uv rectangle.
        /// </summary>
        /// <param name="reader">The JSON reader to fetch data from.</param>
        /// <param name="serializer">The serializer for embedded serialization.</param>
        /// <returns>The <see cref="UVRectangleContainer"/> identified in the JSON.</returns>
        protected override UVRectangleContainer readJsonImpl(JsonReader reader, JsonSerializer serializer)
        {
            bool        absolute = true;
            UVRectangle uv       = new UVRectangle();

            bool    sizeGiven = false;
            Vector2 size      = new Vector2();

            float rotation = 0;

            while (reader.Read())
            {
                // break on unexpected or end of object
                if (reader.TokenType != JsonToken.PropertyName)
                {
                    break;
                }

                var propertyName = (string)reader.Value;

                if (!reader.Read())
                {
                    // no property value? stop reading and let JSON.NET fail
                    break;
                }

                // read correct property
                switch (propertyName)
                {
                case "absolute":
                    absolute = serializer.Deserialize <bool>(reader);
                    break;

                case "leftTop":
                case "lt":
                    uv.TopLeft = serializer.Deserialize <Vector2>(reader);
                    break;

                case "leftBottom":
                case "lb":
                    uv.BottomLeft = serializer.Deserialize <Vector2>(reader);
                    break;

                case "rightTop":
                case "rt":
                    uv.TopRight = serializer.Deserialize <Vector2>(reader);
                    break;

                case "rightBottom":
                case "rb":
                    uv.BottomRight = serializer.Deserialize <Vector2>(reader);
                    break;

                case "size":
                    size      = serializer.Deserialize <Vector2>(reader);
                    sizeGiven = true;
                    break;

                case "rotation":
                    rotation = serializer.Deserialize <float>(reader);
                    break;

                default:
                    throw new InvalidDataException(String.Format("Unknown property while deserialising uv rectangle: {0}", propertyName));
                }
            }

            if (sizeGiven)
            {
                uv = new UVRectangle(uv.TopLeft.X, uv.TopLeft.X + size.X, uv.TopLeft.Y, uv.TopLeft.Y + size.Y);
            }

            if (rotation != 0)
            {
                uv.Rotate(rotation);
            }

            return(new UVRectangleContainer(uv, absolute));
        }
 /// <summary>
 /// Create a new <see cref="UVRectangleContainer"/>.
 /// </summary>
 /// <param name="uv">The <see cref="UVRectangle"/> to box</param>
 /// <param name="absolite">Whether the boxed <see cref="UVRectangle"/> has relative of absolute ub coordinates</param>
 public UVRectangleContainer(UVRectangle uv, bool absolute)
 {
     this.uv = uv;
     this.absolute = absolute;
 }
Beispiel #6
0
 /// <summary>
 /// Create a new <see cref="UVRectangleContainer"/>.
 /// </summary>
 /// <param name="uv">The <see cref="UVRectangle"/> to box</param>
 /// <param name="absolite">Whether the boxed <see cref="UVRectangle"/> has relative of absolute ub coordinates</param>
 public UVRectangleContainer(UVRectangle uv, bool absolute)
 {
     this.uv       = uv;
     this.absolute = absolute;
 }