Ejemplo n.º 1
0
        private void CreateStrokeSpriteFont(Drawables.Image image, SpriteFont spriteFont, string text, Vector2?scale = null, Color?textStrokeColor = null, Color?textColor = null)
        {
            var textStroke = StrokeEffect.CreateStrokeSpriteFont(spriteFont, text, textColor == null ? Color.Black : textColor.Value, scale ?? Vector2.One, strokeSize, textStrokeColor == null ? strokeColor : textStrokeColor.Value, GraphicsDevice, strokeType);

            // Dispose if the previous texture is not pixel
            if (image.texture != imgPixel)
            {
                image.texture.Dispose();
            }

            image.texture = textStroke;
        }
Ejemplo n.º 2
0
        private void CreateStroke(Drawables.Image image, Texture2D texture, Color?imageStrokeColor = null)
        {
            var imageStroke = StrokeEffect.CreateStroke(texture, strokeSize, imageStrokeColor == null ? strokeColor : imageStrokeColor.Value, GraphicsDevice, strokeType);

            // Dispose if the previous texture is not pixel
            if (image.texture != imgPixel)
            {
                image.texture.Dispose();
            }

            image.texture = imageStroke;
        }
Ejemplo n.º 3
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);


            imgPixel = new Texture2D(GraphicsDevice, 1, 1);
            Color[] _Color = new Color[1];
            _Color[0] = Color.White;
            imgPixel.SetData(_Color);

            arialSpriteFont       = Content.Load <SpriteFont>("Arial");
            cooperBlackSpriteFont = Content.Load <SpriteFont>("CooperBlack");

            imgCheckBox        = Content.Load <Texture2D>("CheckBox");
            imgCheckBoxChecked = Content.Load <Texture2D>("CheckBox_Checked");

            imgCameraOriginal    = Content.Load <Texture2D>("camera");
            imgGlobeOriginal     = Content.Load <Texture2D>("globe");
            imgHeartOriginal     = Content.Load <Texture2D>("heart");
            imgImagePlusOriginal = Content.Load <Texture2D>("picture-plus");
            imgSurgeOriginal     = Content.Load <Texture2D>("surge");

            var pos = new Vector2(50, 50);

            imgObjTextType = CreateAndAddImageObject(new Drawables.Image(imgPixel, pos));
            pos.X         += 100;
            imgObjTextOutlineWithTextureCheckbox         = CreateAndAddImageObject(new Drawables.Image(imgPixel, pos));
            imgObjTextOutlineWithTextureCheckbox.OnClick = () =>
            {
                strokeType = StrokeType.OutlineAndTexture;
                UpdateTextureOutlines();
            };
            imgObjTextOutlineWithTexture = CreateAndAddImageObject(new Drawables.Image(imgPixel, pos + new Vector2(38, 0)));

            pos.Y += 40;
            imgObjTextOutlineWithoutTextureCheckbox         = CreateAndAddImageObject(new Drawables.Image(imgPixel, pos));
            imgObjTextOutlineWithoutTextureCheckbox.OnClick = () =>
            {
                strokeType = StrokeType.OutlineWithoutTexture;
                UpdateTextureOutlines();
            };
            imgObjTextOutlineWithoutTexture = CreateAndAddImageObject(new Drawables.Image(imgPixel, pos + new Vector2(38, 0)));

            pos = new Vector2(600, 15);

            CreateAndAddImageObject(new Drawables.Image(imgPixel, new Rectangle((int)pos.X - 30, (int)pos.Y, 2, 180)))
            .color = Color.Yellow;

            imgObjTextSize = new Drawables.Image(imgPixel, pos);
            drawList.Add(imgObjTextSize);
            pos.X += 80;
            var imgBtnMinus = Content.Load <Texture2D>("btnMinus");

            CreateAndAddImageObject(new Drawables.Image(imgBtnMinus, pos))
            .OnClick = () =>
            {
                strokeSize = Math.Max(strokeSize - 1, 0);
                UpdateTextureOutlines();
            };
            pos.X += 45;
            imgObjTextSizeNumber = new Drawables.Image(imgPixel, pos);
            drawList.Add(imgObjTextSizeNumber);
            pos.X += 40;
            var imgBtnPlus = Content.Load <Texture2D>("btnPlus");

            CreateAndAddImageObject(new Drawables.Image(imgBtnPlus, pos))
            .OnClick = () =>
            {
                strokeSize++;
                UpdateTextureOutlines();
            };

            pos = new Vector2(600, 80);

            imgObjTextColor = new Drawables.Image(imgPixel, pos);
            drawList.Add(imgObjTextColor);

            var posLeftColor = pos.X + 100;

            pos = new Vector2(posLeftColor, pos.Y);
            CreateSquareColor(pos, Color.White, true);
            pos.X += 45;
            CreateSquareColor(pos, Color.Yellow);
            pos.X += 45;
            CreateSquareColor(pos, Color.Black);
            pos.X += 45;
            CreateSquareColor(pos, Color.Red);
            pos.X += 45;
            CreateSquareColor(pos, Color.Blue);
            pos.X += 45;
            CreateSquareColor(pos, Color.Green);
            pos.X += 45;
            CreateSquareColor(pos, Color.Pink);
            pos.X  = posLeftColor;
            pos.Y += 45;
            CreateSquareColor(pos, Color.LightGray);
            pos.X += 45;
            CreateSquareColor(pos, Color.Gray);
            pos.X += 45;
            CreateSquareColor(pos, Color.DarkGray);
            pos.X += 45;
            CreateSquareColor(pos, Color.Olive);
            pos.X += 45;
            CreateSquareColor(pos, Color.Cyan);
            pos.X += 45;
            CreateSquareColor(pos, Color.Orange);
            pos.X += 45;
            CreateSquareColor(pos, Color.Purple);

            CreateAndAddImageObject(new Drawables.Image(imgPixel, new Rectangle(15, 195, 1000, 2)))
            .color = Color.Yellow;

            imgObjTextSprintFontStroke = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(25, 210)));
            imgObjTextSmall            = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(25, 260)));
            imgObjTextBigText          = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(25, 280)));

            CreateAndAddImageObject(new Drawables.Image(imgPixel, new Rectangle(15, 195, 1000, 2)))
            .color = Color.Yellow;

            CreateAndAddImageObject(new Drawables.Image(imgSurgeOriginal, new Vector2(850, 250)));
            imgObjSurge = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(900, 250)));

            var posY = 370;

            CreateAndAddImageObject(new Drawables.Image(imgHeartOriginal, new Vector2(50, posY)));
            imgObjHeart = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(100, posY)));

            CreateAndAddImageObject(new Drawables.Image(imgCameraOriginal, new Vector2(200, posY)));
            imgObjCamera = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(275, posY)));

            CreateAndAddImageObject(new Drawables.Image(imgImagePlusOriginal, new Vector2(50, posY + 75)));
            imgObjImagePlus = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(200, posY + 75)));

            CreateAndAddImageObject(new Drawables.Image(imgGlobeOriginal, new Vector2(440, posY)));
            imgObjGlobe = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(700, posY)));

            CreateAndAddImageObject(new Drawables.Image(imgPixel, new Rectangle(15, 630, 1000, 2)))
            .color = Color.Yellow;

            imgObjMultipleText = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(25, 640)));

            imgObjFpsText = CreateAndAddImageObject(new Drawables.Image(imgPixel, new Vector2(600, 660)));

            UpdateTextureOutlines();
        }
Ejemplo n.º 4
0
 private Drawables.Image CreateAndAddImageObject(Drawables.Image imgObj)
 {
     drawList.Add(imgObj);
     return(imgObj);
 }