Esempio n. 1
0
        public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length)
        {
            CloudEffectConfigToken token = (CloudEffectConfigToken)parameters;
            PdnRegion selectionRegion    = EnvironmentParameters.GetSelection(srcArgs.Bounds);

            this.r1 = token.R1;
            this.r2 = token.R2;
            this.r3 = token.R3;

            for (int i = startIndex; i < startIndex + length; ++i)
            {
                Rectangle rect = rois[i];

                for (int y = rect.Top; y < rect.Bottom; ++y)
                {
                    for (int x = rect.Left; x < rect.Right; ++x)
                    {
                        if (selectionRegion.IsVisible(x, y))
                        {
                            ColorBgra srcBgra = srcArgs.Surface[x, y];
                            byte      c       = (byte)(PerlinNoise2d(x, y, token) * 255);

                            switch (token.DisplayOption)
                            {
                            case CloudEffect.REPLACE_SOURCE:
                                dstArgs.Surface[x, y] = ColorBgra.FromBgra(srcBgra.B, srcBgra.G, srcBgra.R, c);
                                break;

                            case CloudEffect.OVERLAY_PRIMARY:
                                ColorBgra primary = (ColorBgra)EnvironmentParameters.ForeColor;
                                dstArgs.Surface[x, y] = ColorBgra.FromBgra(primary.B, primary.G, primary.R, c);
                                break;

                            case CloudEffect.OVERLAY_SECONDARY:
                                ColorBgra secondary = (ColorBgra)EnvironmentParameters.BackColor;
                                dstArgs.Surface[x, y] = ColorBgra.FromBgra(secondary.B, secondary.G, secondary.R, c);
                                break;

                            case CloudEffect.REPLACE_TRANSPARENT:
                                dstArgs.Surface[x, y] = (0 == srcBgra.A) ? ColorBgra.FromBgra(srcBgra.B, srcBgra.G, srcBgra.R, c) : srcArgs.Surface[x, y];
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the left and right visible extents of the current line in relation to the selection scaledBounds
        /// </summary>
        /// <param name="scaledLineY">The y coordinate in AA scale</param>
        /// <returns>The visible extent of the line in AA scale-coordinates</returns>
        private Extent TraceLineExtent(int scaledLineY)
        {
            int lineY = (scaledLineY / settings.AntiAliasLevel) + bounds.Top;

            //if y falls outside selection, simply return entire line
            if (lineY < bounds.Top || lineY > bounds.Bottom)
            {
                return(new Extent(bounds.Left, bounds.Right, lineY - bounds.Top).Multiply(settings.AntiAliasLevel));
            }

            int leftX  = bounds.Left;
            int rightX = bounds.Right;

            //trace line inward from left to right
            while (leftX < rightX)
            {
                if (selectionRegion.IsVisible(leftX, lineY))
                {
                    break;
                }

                leftX++;
            }

            while (rightX > 0)
            {
                if (selectionRegion.IsVisible(rightX, lineY))
                {
                    break;
                }

                rightX--;
            }

            return(new Extent(leftX - bounds.Left, rightX - bounds.Left, lineY - bounds.Top).Multiply(settings.AntiAliasLevel));
        }
Esempio n. 3
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            Point pos = new Point(e.X, e.Y);

            this.contiguous = ((ModifierKeys & Keys.Shift) == 0);

            if (Document.Bounds.Contains(pos))
            {
                base.OnMouseDown(e);

                PdnRegion currentRegion = Selection.CreateRegion();

                // See if the mouse click is valid
                if (!currentRegion.IsVisible(pos) && limitToSelection)
                {
                    currentRegion.Dispose();
                    currentRegion = null;
                    return;
                }

                // Set the current surface, color picked and color to draw
                Surface surface = ((BitmapLayer)ActiveLayer).Surface;

                IBitVector2D stencilBuffer = new BitVector2DSurfaceAdapter(this.ScratchSurface);

                Rectangle boundingBox;
                int       tolerance = (int)(AppEnvironment.Tolerance * AppEnvironment.Tolerance * 256);

                if (contiguous)
                {
                    FillStencilFromPoint(surface, stencilBuffer, pos, tolerance, out boundingBox, currentRegion, limitToSelection);
                }
                else
                {
                    FillStencilByColor(surface, stencilBuffer, surface[pos], tolerance, out boundingBox, currentRegion, limitToSelection);
                }

                Point[][] polygonSet = PdnGraphicsPath.PolygonSetFromStencil(stencilBuffer, boundingBox, 0, 0);
                OnFillRegionComputed(polygonSet);
            }

            base.OnMouseDown(e);
        }