Ejemplo n.º 1
0
 public Text(FontAsset font, string text, Vector2 position, Color color, float alpha = 1.0f, AlignX alignX = BeauSharp.AlignX.Left, AlignY alignY = BeauSharp.AlignY.Top)
     : base(false)
 {
     this.font = font;
     this.text = text;
     Position = position;
     Color = color;
     Alpha = alpha;
     AlignX = alignX;
     AlignY = alignY;
     UpdateSize();
 }
Ejemplo n.º 2
0
 public SavedTransformation(Vector2 position, Vector2 origin, Vector2 scale, float zoom, Angle rotation, Color color, float alpha, SpriteEffects effect, FontAsset font
     , AlignX alignH, AlignY alignV)
 {
     Position = position;
     Origin = origin;
     Scale = scale;
     Zoom = zoom;
     Rotation = rotation;
     Color = color;
     Alpha = alpha;
     Effects = effect;
     Font = font;
     AlignH = alignH;
     AlignV = alignV;
 }
Ejemplo n.º 3
0
        internal static void Init(GraphicsDevice device)
        {
            SpriteBatch = new SpriteBatch(device);

            Pixel = new Texture2D(device, 1, 1);
            Pixel.SetData<Color>(new Color[1] { Color.White });

            Particle = new Texture2D(device, 2, 2);
            Particle.SetData<Color>(new Color[4] { Color.White, Color.White, Color.White, Color.White });

            DefaultFont = new FontAsset("../WinFont", true);
            Font = DefaultFont;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Renders text with the given parameters.
        /// </summary>
        /// <param name="font">The SpriteFont to use.</param>
        /// <param name="text">The text to render.</param>
        /// <param name="position">The position of the text.</param>
        /// <param name="color">The color of the text.</param>
        /// <param name="alpha">The transparency to use.</param>
        /// <param name="alignH">The horizontal alignment.</param>
        /// <param name="alignV">The vertical alignment.</param>
        /// <param name="scale">The scaling factors to use.</param>
        /// <param name="rotation">The rotation of the </param>
        public static void Text(FontAsset font, string text, Vector2 position, Color color, float alpha, AlignX alignH, AlignY alignV, Vector2 scale, Angle rotation)
        {
            Vector2 origin = Font.SpriteFont.MeasureString(text);
            origin.X *= AlignFactor(alignH);
            origin.Y *= AlignFactor(alignV);

            SpriteBatch.DrawString(font.SpriteFont, text, Calc.Floor(position), color * Math.Min(alpha, 1), rotation.Radians, origin, scale, Effects, 0);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Renders text with the given parameters.
 /// </summary>
 /// <param name="font">The SpriteFont to use.</param>
 /// <param name="text">The text to render.</param>
 /// <param name="position">The position of the text.</param>
 /// <param name="color">The color of the text.</param>
 /// <param name="alpha">The transparency to use.</param>
 public static void Text(FontAsset font, string text, Vector2 position, Color color, float alpha = 1.0f)
 {
     SpriteBatch.DrawString(font.SpriteFont, text, Calc.Floor(position), color * Math.Min(alpha, 1));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Resets the rendering state.
 /// </summary>
 public static void ResetState()
 {
     Position = Vector2.Zero;
     Origin = Vector2.Zero;
     Scale = Vector2.One;
     Zoom = 1.0f;
     Rotation = Angle.Zero;
     Color = Color.White;
     Alpha = 1.0f;
     Effects = SpriteEffects.None;
     Font = DefaultFont;
     AlignX = AlignX.Left;
     AlignY = AlignY.Top;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Pops the rendering state off the stack.
 /// </summary>
 public static void PopState()
 {
     #if DEBUG
     if ( _savedTransformations == null || _savedTransformations.Count == 0 )
         throw new Exception("No states available on the stack.");
     #endif
     SavedTransformation oldState = _savedTransformations.Pop();
     Position = oldState.Position;
     Origin = oldState.Origin;
     Scale = oldState.Scale;
     Zoom = oldState.Zoom;
     Rotation = oldState.Rotation;
     Color = oldState.Color;
     Alpha = oldState.Alpha;
     Effects = oldState.Effects;
     Font = oldState.Font;
     AlignX = oldState.AlignH;
     AlignY = oldState.AlignV;
 }
Ejemplo n.º 8
0
 public Text(FontAsset font, string text, Vector2 position, AlignX alignX = BeauSharp.AlignX.Left, AlignY alignY = BeauSharp.AlignY.Top)
     : this(font, text, position, Color.White, 1.0f, alignX, alignY)
 {
 }