Esempio n. 1
0
        protected override void UpdateWithLocation(Rectangle rect, Keys modifiers, Point end)
        {
            shouldApplyCharacter = ApplyCharacter;       //modifiers.HasFlag (Key.Shift | Application.Instance.CommonModifier) ^ ApplyCharacter;
            shouldApplyColour    = ApplyColour;          //modifiers.HasFlag (Key.Alt | Application.Instance.CommonModifier) ^ ApplyColour;

            var oldRect = currentRect;

            rect.Normalize();
            lines.Clear();
            if (!Filled)
            {
                var templines = new ScanLines();
                currentRect = rect = templines.AddEllipse(rect);
                ScanLinesDrawDelegate draw = (drawrect) => {
                    lines.AddRect(drawrect);
                };
                templines.Outline(draw);
            }
            else
            {
                currentRect = rect = lines.AddEllipse(rect);
            }

            if (oldRect != null)
            {
                rect = Rectangle.Union(rect, oldRect.Value);
            }
            UpdatingCursor         = true;
            Handler.CursorPosition = end;
            UpdatingCursor         = false;
            Handler.InvalidateCharacterRegion(rect, false, false);
        }
Esempio n. 2
0
        public void Do(Point?cursorPosition, Point start, Point end, CanvasElement element, bool applyColour, bool applyCharacter)
        {
            var lines = new ScanLines();

            lines.AddLine(start, end);
            var canvas = Handler.CurrentPage.Canvas;

            Handler.Undo.Save(cursorPosition, cursorPosition, new Rectangle(start, end));
            foreach (var row in lines.Values)
            {
                var minx  = row.Min();
                var width = row.Max() - minx + 1;
                var rect  = new Rectangle(minx, row.Row, width, 1);
                if (applyColour && applyCharacter)
                {
                    canvas.Fill(rect, element);
                }
                else if (applyColour)
                {
                    canvas.Fill(rect, element.Attribute);
                }
                else if (applyCharacter)
                {
                    canvas.Fill(rect, element.Character);
                }
            }
            Handler.InvalidateCharacterRegion(new Rectangle(start, end), true, false);
            Handler.Document.IsModified = true;
        }
Esempio n. 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Initialize ColorPixels instance
            new PixelTextures(GraphicsDevice);

            var presentationParams = GraphicsDevice.PresentationParameters;

            // Create render target at virtual resolution for game to render to first,
            // then render result upscaled to second render target at full resolution
            // with PointClamp to keep pixel alignment and apply post processing
            virtualSizeRenderTarget = new RenderTarget2D(
                GraphicsDevice,
                VIRTUAL_WIDTH,
                VIRTUAL_HEIGHT);
            fullSizeRenderTarget1 = new RenderTarget2D(
                GraphicsDevice,
                presentationParams.BackBufferWidth,
                presentationParams.BackBufferHeight);
            fullSizeRenderTarget2 = new RenderTarget2D(
                GraphicsDevice,
                presentationParams.BackBufferWidth,
                presentationParams.BackBufferHeight);

            bloomEffect = new Bloom(GraphicsDevice)
            {
                Settings = new BloomSettings("Custom1", 0, 1.2f, 0.9f, 1, 1, 1)
            };
            var bloomExtractShader = Content.Load <Effect>("Shaders/BloomExtract");
            var bloomCombineShader = Content.Load <Effect>("Shaders/BloomCombine");
            var gaussianBlurShader = Content.Load <Effect>("Shaders/GaussianBlur");

            bloomEffect.LoadContent(bloomExtractShader, bloomCombineShader, gaussianBlurShader);

            var scanLinesShader = Content.Load <Effect>("Shaders/ScanLines");

            scanLinesEffect = new ScanLines(GraphicsDevice);
            scanLinesEffect.LoadContent(scanLinesShader);

            var screenRect = new Rectangle(0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);

            menu = new MainMenu(screenRect);
            menu.LoadContent();

            gameOverMenu = new GameOverMenu(screenRect);
            pauseMenu    = new PauseMenu(screenRect);
        }
Esempio n. 4
0
        public void Do(Point?cursorPosition, Rectangle rect, CanvasElement element, bool applyColour, bool applyCharacter, bool filled)
        {
            var canvas = Handler.CurrentPage.Canvas;

            Handler.Undo.Save(cursorPosition, cursorPosition, rect);

            var lines = new ScanLines();

            lines.AddEllipse(rect);

            ScanLinesDrawDelegate draw = (linerect) => {
                if (applyColour && applyCharacter)
                {
                    canvas.Fill(linerect, element);
                }
                else if (applyColour)
                {
                    canvas.Fill(linerect, element.Attribute);
                }
                else if (applyCharacter)
                {
                    canvas.Fill(linerect, element.Character);
                }
            };

            if (filled)
            {
                lines.Fill(draw);
            }
            else
            {
                lines.Outline(draw);
            }

            Handler.InvalidateCharacterRegion(rect, true, false);
            Handler.Document.IsModified = true;
        }