예제 #1
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.thickness = newToken.GetProperty<Int32Property>(PropertyNames.Thickness).Value;
            this.intensity = newToken.GetProperty<Int32Property>(PropertyNames.Intensity).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #2
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Amount1 = newToken.GetProperty <DoubleProperty>(PropertyNames.Amount1).Value;
            Amount2 = newToken.GetProperty <Int32Property>(PropertyNames.Amount2).Value;
            Amount3 = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount3).Value;
            Amount4 = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Amount4).Value);
            Amount5 = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Amount5).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);


            Bitmap   puzzleBitmap   = new Bitmap((int)(100 * Amount1), (int)(100 * Amount1), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics puzzleGraphics = Graphics.FromImage(puzzleBitmap);

            puzzleGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            Pen puzzlePen = new Pen(Amount4, Amount2);

            // Create points that define the horizontal curve.
            Point horPoint0 = new Point((int)(-50 * Amount1), (int)(16 * Amount1));
            Point horPoint1 = new Point((int)(0 * Amount1), (int)(16 * Amount1));
            Point horPoint2 = new Point((int)(13 * Amount1), (int)(28 * Amount1));
            Point horPoint3 = new Point((int)(9 * Amount1), (int)(50 * Amount1));

            Point horPoint4 = new Point((int)(49 * Amount1), (int)(49 * Amount1));

            Point horPoint5 = new Point((int)(90 * Amount1), (int)(49 * Amount1));
            Point horPoint6 = new Point((int)(86 * Amount1), (int)(71 * Amount1));
            Point horPoint7 = new Point((int)(99 * Amount1), (int)(83 * Amount1));
            Point horPoint8 = new Point((int)(149 * Amount1), (int)(83 * Amount1));

            Point[] horCurvePoints = { horPoint0, horPoint1, horPoint2, horPoint3, horPoint4, horPoint5, horPoint6, horPoint7, horPoint8 };

            // Draw the horizontal curve to graphics object.
            puzzleGraphics.DrawCurve(puzzlePen, horCurvePoints);


            // Create points that define the vertical curve.
            Point verPoint0 = new Point((int)(83 * Amount1), (int)(-50 * Amount1));
            Point verPoint1 = new Point((int)(83 * Amount1), (int)(0 * Amount1));
            Point verPoint2 = new Point((int)(73 * Amount1), (int)(13 * Amount1));
            Point verPoint3 = new Point((int)(49 * Amount1), (int)(9 * Amount1));

            Point verPoint4 = new Point((int)(50 * Amount1), (int)(50 * Amount1));

            Point verPoint5 = new Point((int)(50 * Amount1), (int)(90 * Amount1));
            Point verPoint6 = new Point((int)(28 * Amount1), (int)(86 * Amount1));
            Point verPoint7 = new Point((int)(16 * Amount1), (int)(99 * Amount1));
            Point verPoint8 = new Point((int)(16 * Amount1), (int)(149 * Amount1));

            Point[] verCurvePoints = { verPoint0, verPoint1, verPoint2, verPoint3, verPoint4, verPoint5, verPoint6, verPoint7, verPoint8 };

            // Draw the vertical curve to graphics object.
            puzzleGraphics.DrawCurve(puzzlePen, verCurvePoints);

            puzzlePen.Dispose();

            puzzleSurface = Surface.CopyFromBitmap(puzzleBitmap);
            puzzleBitmap.Dispose();
        }
예제 #3
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.radius = newToken.GetProperty<Int32Property>(PropertyNames.Radius).Value;
            this.strength = -0.2 * newToken.GetProperty<DoubleProperty>(PropertyNames.Strength).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #4
0
 protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
 {
     Size = newToken.GetProperty <Int32Property>(PropertyNames.Size).Value;
     K    = newToken.GetProperty <DoubleProperty>(PropertyNames.K).Value;
     InitializeIntegralImage(srcArgs.Surface);
     base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
 }
예제 #5
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.radius = newToken.GetProperty<Int32Property>(PropertyNames.Radius).Value;
            this.percentile = newToken.GetProperty<Int32Property>(PropertyNames.Percentile).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #6
0
 protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
 {
     this.Value1 = (int)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Type).Value;
     this.Value2 = newToken.GetProperty <Int32Property>(PropertyNames.Aperture).Value;
     //this.Value3 = newToken.GetProperty<Int32Property>(PropertyNames.Tolerance).Value;
     //this.Value4 = newToken.GetProperty<BooleanProperty>(PropertyNames.Alpha).Value;
     base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
 }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            m_Text    = token.GetProperty <StringProperty>(PropertyNames.M_Text).Value;
            m_Modulus = token.GetProperty <Int32Property>(PropertyNames.M_Modulus).Value;
            m_Offset  = token.GetProperty <Int32Property>(PropertyNames.M_Offset).Value;

            base.OnSetRenderInfo(token, dstArgs, srcArgs);
        }
예제 #8
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            DirSetting = newToken.GetProperty <StringProperty>(PropertyNames.DirSetting).Value;
            Filename   = (byte)((int)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.DirFiles).Value);
            Checkk     = newToken.GetProperty <BooleanProperty>(PropertyNames.checkk).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #9
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.tolerance = newToken.GetProperty<Int32Property>(PropertyNames.Tolerance).Value;
            this.saturation = newToken.GetProperty<Int32Property>(PropertyNames.Saturation).Value;

            this.redEyeOp = new UnaryPixelOps.RedEyeRemove(this.tolerance, this.saturation);

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #10
0
        /// <summary>
        /// Sets global effect parameters.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="dstArgs">The destination picture arguments.</param>
        /// <param name="srcArgs">The source picture arguments.</param>
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            var wavelength    = parameters.GetProperty <Int32Property>("Wavelength").Value;
            var orientation   = parameters.GetProperty <DoubleProperty>("Orientation").Value *Math.PI / 180.0;
            var renderQuality = parameters.GetProperty <Int32Property>("RenderQuality").Value + 1;
            var binary        = parameters.GetProperty <BooleanProperty>("Binary").Value;

            _convolutionPool = new GaborConvolutionPool(wavelength, orientation, renderQuality, binary);
        }
예제 #11
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.zoom = newToken.GetProperty<DoubleProperty>(PropertyNames.Zoom).Value;
            this.quality = newToken.GetProperty<Int32Property>(PropertyNames.Quality).Value;
            this.angle = newToken.GetProperty<DoubleProperty>(PropertyNames.Angle).Value;
            this.angleTheta = (this.angle * Math.PI * 2) / 360.0;
            this.factor = newToken.GetProperty<DoubleProperty>(PropertyNames.Factor).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #12
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.Amount1 = newToken.GetProperty <Int32Property>(PropertyNames.Amount1).Value;
            this.Amount2 = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount2).Value;
            this.Amount3 = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Amount3).Value);
            this.Amount4 = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount4).Value;
            this.Amount5 = newToken.GetProperty <Int32Property>(PropertyNames.Amount5).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #13
0
        protected override void OnSetRenderInfoCore(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            if (this._enumDropDown == null)
            {
                this._enumDropDown = new EnumDropDownValues <ValueSources>();
            }

            this._isForwards  = !newToken.GetProperty <BooleanProperty>(PropertyNames.FFTDirectionIsForward).Value;
            this._valueSource = this._enumDropDown.GetEnumMember(newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.ValueSource).Value);
        }
        protected override void OnSetRenderInfo(
            PropertyBasedEffectConfigToken newToken,
            RenderArgs dstArgs,
            RenderArgs srcArgs)
        {
            _colorChart            = (ColorChart)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.ColorChart).Value;
            _includeSecondaryColor = newToken.GetProperty <BooleanProperty>(PropertyNames.IncludeSecondaryColor).Value;
            _colorMap = ComputeColorMap();

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #15
0
 /// <summary>
 /// Factory method for creating a ShadowEffectConfiguration object from the effect configuration token.
 /// </summary>
 /// <param name="token">The input token</param>
 /// <returns></returns>
 public static ShadowEffectConfiguration FromToken(PropertyBasedEffectConfigToken token)
 {
     return(new ShadowEffectConfiguration
     {
         Angle = (int)token.GetProperty <DoubleProperty>(ShadowEffectProperties.Angle).Value,
         DepthAngle = (int)token.GetProperty <DoubleProperty>(ShadowEffectProperties.DepthAngle).Value,
         Opacity = (double)(token.GetProperty <Int32Property>(ShadowEffectProperties.Opacity).Value),
         KeepOriginalImage = token.GetProperty <BooleanProperty>(ShadowEffectProperties.KeepOriginalImage).Value,
         DiffusionFactor = (int)token.GetProperty <Int32Property>(ShadowEffectProperties.DiffusionFactor).Value
     });
 }
        protected override void OnSetRenderInfo(
            PropertyBasedEffectConfigToken newToken,
            RenderArgs dstArgs,
            RenderArgs srcArgs)
        {
            UpdatePropertiesIfNeeded(newToken);

            var redGain   = newToken.GetProperty <DoubleProperty>(PropertyNames.RedGain).Value;
            var greenGain = newToken.GetProperty <DoubleProperty>(PropertyNames.GreenGain).Value;
            var blueGain  = newToken.GetProperty <DoubleProperty>(PropertyNames.BlueGain).Value;

            _colorMap = ComputeColorMap(redGain, greenGain, blueGain);

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #17
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.angle = newToken.GetProperty<DoubleProperty>(PropertyNames.Angle).Value;

            // adjust and convert angle to radians
            double r = (double)this.angle * 2.0 * Math.PI / 360.0;

            // angle delta for each weight
            double dr = Math.PI / 4.0;

            // for r = 0 this builds an emboss filter pointing straight left
            this.weights = new double[3][];

            for (int i = 0; i < 3; ++i)
            {
                this.weights[i] = new double[3];
            }

            this.weights[0][0] = Math.Cos(r + dr);
            this.weights[0][1] = Math.Cos(r + 2.0 * dr);
            this.weights[0][2] = Math.Cos(r + 3.0 * dr);

            this.weights[1][0] = Math.Cos(r);
            this.weights[1][1] = 0;
            this.weights[1][2] = Math.Cos(r + 4.0 * dr);

            this.weights[2][0] = Math.Cos(r - dr);
            this.weights[2][1] = Math.Cos(r - 2.0 * dr);
            this.weights[2][2] = Math.Cos(r - 3.0 * dr);

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #18
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            int colorValue = newToken.GetProperty <Int32Property>(PropertyNames.Int32ColorWheel).Value;

            this.color = ColorBgra.FromOpaqueInt32(colorValue);
            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #19
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.intensity = newToken.GetProperty<Int32Property>(PropertyNames.Intensity).Value;
            this.saturation = newToken.GetProperty<Int32Property>(PropertyNames.Saturation).Value;
            this.coverage = 0.01 * newToken.GetProperty<DoubleProperty>(PropertyNames.Coverage).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #20
0
        /// <summary>
        /// Apply the selected property values
        /// </summary>
        /// <param name="newToken">UI property data</param>
        /// <param name="dstArgs">Destination information</param>
        /// <param name="srcArgs">Source information</param>
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            var start    = newToken.GetProperty <Int32Property>(PropertyNames.PaletteStartIndex).Value;
            var end      = newToken.GetProperty <Int32Property>(PropertyNames.PaletteEndIndex).Value;
            var palettes = Services.GetService <PaintDotNet.AppModel.IPalettesService>();

            paletteBgra = palettes.CurrentPalette.Skip(start - 1).Take(end - start + 1).ToArray();

            dithering = (DitheringMethods)((int)newToken.GetProperty <StaticListChoiceProperty>(
                                               PropertyNames.DitheringMethod).Value);

            ditheringAmount = (float)newToken.GetProperty <DoubleProperty>(
                PropertyNames.DitheringAmount).Value;

            keepOpacity = newToken.GetProperty <BooleanProperty>(PropertyNames.IgnoreAlpha).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.horMargin = newToken.GetProperty <Int32Property>(PropertyNames.HorMargin).Value;
            this.verMargin = newToken.GetProperty <Int32Property>(PropertyNames.VerMargin).Value;
            this.position  = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Position).Value;

            Rectangle selection = this.EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt();

            if (this.trimmedSurface is null)
            {
                Rectangle trimmedBounds = GetTrimmedBounds(srcArgs.Surface, selection);

                this.trimmedSurface = new Surface(trimmedBounds.Size);
                this.trimmedSurface.CopySurface(srcArgs.Surface, Point.Empty, trimmedBounds);
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #22
0
파일: Effect.cs 프로젝트: bsneeze/pdn-trail
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);

            this.Direction = newToken.GetProperty <DoubleProperty>(PropertyNames.Direction).Value *Math.PI / 180.0;
            this.Distance  = newToken.GetProperty <Int32Property>(PropertyNames.Distance).Value;
            this.Spacing   = newToken.GetProperty <Int32Property>(PropertyNames.Spacing).Value;
            this.Fade      = newToken.GetProperty <BooleanProperty>(PropertyNames.Fade).Value;
            this.Bilinear  = newToken.GetProperty <BooleanProperty>(PropertyNames.Bilinear).Value;

            this.SpacingX  = Spacing * Math.Abs(Math.Cos(Direction));
            this.SpacingY  = Spacing * Math.Abs(Math.Sin(Direction));
            this.DistanceX = Distance * Math.Abs(Math.Cos(Direction));
            this.DistanceY = Distance * Math.Abs(Math.Sin(Direction));

            this.DirectionX = Math.Sign(Math.Cos(Direction));
            this.DirectionY = -Math.Sign(Math.Sin(Direction));

            this.blendOp = new UserBlendOps.NormalBlendOp();
        }
예제 #23
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            PropertyCollection blurValues = this.blurProps.Clone();
            blurValues[GaussianBlurEffect.PropertyNames.Radius].Value = newToken.GetProperty<Int32Property>(PropertyNames.Radius).Value;
            PropertyBasedEffectConfigToken blurToken = new PropertyBasedEffectConfigToken(blurValues);
            this.blurEffect.SetRenderInfo(blurToken, dstArgs, srcArgs);

            PropertyCollection bcValues = this.bcProps.Clone();

            bcValues[BrightnessAndContrastAdjustment.PropertyNames.Brightness].Value =
                newToken.GetProperty<Int32Property>(PropertyNames.Brightness).Value;

            bcValues[BrightnessAndContrastAdjustment.PropertyNames.Contrast].Value =
                newToken.GetProperty<Int32Property>(PropertyNames.Contrast).Value;

            PropertyBasedEffectConfigToken bcToken = new PropertyBasedEffectConfigToken(bcValues);
            this.bcAdjustment.SetRenderInfo(bcToken, dstArgs, dstArgs); // have to do adjustment in place, hence dstArgs for both 'args' parameters

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #24
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.pencilTipSize = newToken.GetProperty<Int32Property>(PropertyNames.PencilTipSize).Value;
            this.colorRange = newToken.GetProperty<Int32Property>(PropertyNames.ColorRange).Value;

            PropertyBasedEffectConfigToken blurToken = new PropertyBasedEffectConfigToken(this.blurProps);
            blurToken.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, this.pencilTipSize);
            this.blurEffect.SetRenderInfo(blurToken, dstArgs, srcArgs);

            PropertyBasedEffectConfigToken bacToken = new PropertyBasedEffectConfigToken(this.bacProps);
            bacToken.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, this.colorRange);
            bacToken.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, -this.colorRange);
            this.bacAdjustment.SetRenderInfo(bacToken, dstArgs, dstArgs);

            this.desaturateEffect.SetRenderInfo(null, dstArgs, dstArgs);

            this.invertEffect.SetRenderInfo(null, dstArgs, dstArgs);

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
        private void UpdatePropertiesIfNeeded(PropertyBasedEffectConfigToken newToken)
        {
            var whiteBalanceMethod = (WhiteBalanceMethod)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.WhiteBalanceMethod).Value;

            if (_lastSetWhiteBalanceMethod == whiteBalanceMethod)
            {
                return;
            }

            UpdateProperties(newToken, whiteBalanceMethod);
            _lastSetWhiteBalanceMethod = whiteBalanceMethod;
        }
예제 #26
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            scale       = newToken.GetProperty <Int32Property>(PropertyNames.Scale).Value;
            roughness   = newToken.GetProperty <DoubleProperty>(PropertyNames.Roughness).Value;
            minOpacity  = newToken.GetProperty <Int32Property>(PropertyNames.MinimumOpacity).Value;
            reseed      = (byte)newToken.GetProperty <Int32Property>(PropertyNames.Reseed).Value;
            customColor = newToken.GetProperty <BooleanProperty>(PropertyNames.UseCustomColor).Value;
            color       = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Color).Value);

            if (emptySurface == null)
            {
                emptySurface = new Surface(srcArgs.Size);
            }
            if (cloudSurface == null)
            {
                cloudSurface = new Surface(srcArgs.Size);
            }

            // Call the Render Clouds function
            cloudsProps = cloudsEffect.CreatePropertyCollection();
            PropertyBasedEffectConfigToken CloudsParameters = new PropertyBasedEffectConfigToken(cloudsProps);

            CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Scale, scale);
            CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Power, roughness);
            CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Seed, reseed);
            using (EffectEnvironmentParameters environParameters = new EffectEnvironmentParameters(ColorBgra.Black, Color.FromArgb(minOpacity, Color.Black), 0, EnvironmentParameters.GetSelectionAsPdnRegion(), emptySurface))
                cloudsEffect.EnvironmentParameters = environParameters;
            cloudsEffect.SetRenderInfo(CloudsParameters, new RenderArgs(cloudSurface), new RenderArgs(emptySurface));

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #27
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.angle = newToken.GetProperty<DoubleProperty>(PropertyNames.Angle).Value;
            this.distance = newToken.GetProperty<Int32Property>(PropertyNames.Distance).Value;
            this.centered = newToken.GetProperty<BooleanProperty>(PropertyNames.Centered).Value;

            PointF start = new PointF(0, 0);
            double theta = ((double)(this.angle + 180) * 2 * Math.PI) / 360.0;
            double alpha = (double)distance;
            double x = alpha * Math.Cos(theta);
            double y = alpha * Math.Sin(theta);
            PointF end = new PointF((float)x, (float)(-y));

            if (this.centered)
            {
                start.X = -end.X / 2.0f;
                start.Y = -end.Y / 2.0f;

                end.X /= 2.0f;
                end.Y /= 2.0f;
            }

            this.points = new PointF[((1 + this.distance) * 3) / 2];

            if (this.points.Length == 1)
            {
                this.points[0] = new PointF(0, 0);
            }
            else
            {
                for (int i = 0; i < this.points.Length; ++i)
                {
                    float frac = (float)i / (float)(this.points.Length - 1);
                    this.points[i] = Utility.Lerp(start, end, frac);
                }
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.hue = newToken.GetProperty<Int32Property>(PropertyNames.Hue).Value;
            this.saturation = newToken.GetProperty<Int32Property>(PropertyNames.Saturation).Value;
            this.lightness = newToken.GetProperty<Int32Property>(PropertyNames.Lightness).Value;

            // map the range [0,100] -> [0,100] and the range [101,200] -> [103,400]
            if (this.saturation > 100)
            {
                this.saturation = ((this.saturation - 100) * 3) + 100;
            }

            if (this.hue == 0 && this.saturation == 100 && this.lightness == 0)
            {
                this.pixelOp = new UnaryPixelOps.Identity();
            }
            else
            {
                this.pixelOp = new UnaryPixelOps.HueSaturationLightness(this.hue, this.saturation, this.lightness);
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #29
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Modes OldMode = Mode;

            Mode           = (Modes)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Mode).Value;
            ModeChanged    = Mode != OldMode;
            LowerThreshold = newToken.GetProperty <Int32Property>(PropertyNames.LowerThreshold).Value;

            UpperThreshold = newToken.GetProperty <Int32Property>(PropertyNames.UpperThreshold).Value;

            float OldTolerance = Tolerance;

            Tolerance        = newToken.GetProperty <Int32Property>(PropertyNames.Tolerance).Value;
            Tolerance       *= Tolerance / toleranceMax / toleranceMax;
            ToleranceChanged = Tolerance != OldTolerance;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);

            PdnRegion           selection = EnvironmentParameters.GetSelection(SrcArgs.Surface.Bounds);
            List <RectangleRef> selRects  = RectangleRef.RectanglesToRectangleRefs(selection.GetRegionScansInt());

            CustomOnRender(RectangleRef.SplitSmall(selRects, selection.GetBoundsInt().Bottom / 4));
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.antiAlias   = newToken.GetProperty <BooleanProperty>(PropertyNames.AntiAliasing).Value;
            this.transparent = newToken.GetProperty <BooleanProperty>(PropertyNames.TransparentBack).Value;
            this.backColor   = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.BackColor).Value);

            int radius = newToken.GetProperty <Int32Property>(PropertyNames.Radius).Value;
            int margin = newToken.GetProperty <Int32Property>(PropertyNames.Margin).Value;

            Rectangle selection = EnvironmentParameters.SelectionBounds;

            marginBounds = Rectangle.FromLTRB(selection.Left + margin, selection.Top + margin, selection.Right - margin, selection.Bottom - margin);
            int radiusMax = Math.Min(selection.Width, selection.Height) / 2 - margin;

            radiusValue = Math.Min(radius, radiusMax);

            // create a rectangle that will be used to determine how the pixels should be rendered
            this.rectangleTopCoordinate    = this.marginBounds.Top + this.radiusValue;
            this.rectangleBottomCoordinate = this.marginBounds.Bottom - 1 - this.radiusValue;
            this.rectangleLeftCoordinate   = this.marginBounds.Left + this.radiusValue;
            this.rectangleRightCoordinate  = this.marginBounds.Right - 1 - this.radiusValue;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #31
0
        /// <summary>
        /// Sets global effect parameters.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="dstArgs">The destination picture arguments.</param>
        /// <param name="srcArgs">The source picture arguments.</param>
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            if (_initialized == false)
            {
                picture  = ToYCbCr(srcArgs.Surface);
                blendMap = Colorizer.ComputeBlendMap(picture, () => IsCancelRequested);

                if (blendMap != null)
                {
                    _initialized = true;
                }
            }

            _blendFactor = parameters.GetProperty <Int32Property>("BlendFactor").Value;
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            margin  = newToken.GetProperty <Int32Property>(PropertyNames.Margin).Value;
            spread  = newToken.GetProperty <Int32Property>(PropertyNames.Spread).Value;
            blur    = newToken.GetProperty <Int32Property>(PropertyNames.Blur).Value;
            color   = ColorBgra.FromUInt32(unchecked ((uint)newToken.GetProperty <Int32Property>(PropertyNames.Color).Value));
            offsetX = newToken.GetProperty <Int32Property>(PropertyNames.OffsetX).Value;
            offsetY = newToken.GetProperty <Int32Property>(PropertyNames.OffsetY).Value;

            if (shadowSurface == null)
            {
                shadowSurface = new Surface(srcArgs.Surface.Size);
            }
            else
            {
                shadowSurface.Clear(Color.Transparent);
            }

            // Setup for calling the Gaussian Blur effect
            PropertyCollection             blurProps      = blurEffect.CreatePropertyCollection();
            PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps);

            BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, blur);
            blurEffect.SetRenderInfo(BlurParameters, dstArgs, new RenderArgs(shadowSurface));

            Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt();

            PointF topStart    = new PointF(selection.Left, selection.Top + (margin + spread + offsetY) / 2f);
            PointF topEnd      = new PointF(selection.Right, selection.Top + (margin + spread + offsetY) / 2f);
            PointF rightStart  = new PointF(selection.Right - (margin + spread - offsetX) / 2f, selection.Top);
            PointF rightEnd    = new PointF(selection.Right - (margin + spread - offsetX) / 2f, selection.Bottom);
            PointF bottomStart = new PointF(selection.Left, selection.Bottom - (margin + spread - offsetY) / 2f);
            PointF bottomEnd   = new PointF(selection.Right, selection.Bottom - (margin + spread - offsetY) / 2f);
            PointF leftStart   = new PointF(selection.Left + (margin + spread + offsetX) / 2f, selection.Top);
            PointF leftEnd     = new PointF(selection.Left + (margin + spread + offsetX) / 2f, selection.Bottom);

            using (Graphics shadow = new RenderArgs(shadowSurface).Graphics)
                using (Pen shadowPen = new Pen(color))
                {
                    shadowPen.Width = margin + spread + offsetX;
                    shadow.DrawLine(shadowPen, leftStart, leftEnd);

                    shadowPen.Width = margin + spread - offsetX;
                    shadow.DrawLine(shadowPen, rightStart, rightEnd);

                    shadowPen.Width = margin + spread + offsetY;
                    shadow.DrawLine(shadowPen, topStart, topEnd);

                    shadowPen.Width = margin + spread - offsetY;
                    shadow.DrawLine(shadowPen, bottomStart, bottomEnd);
                }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #33
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            m_TintStrength = token.GetProperty <DoubleProperty>(PropertyNames.M_TintStrength).Value;
            m_UseRgbPicker = token.GetProperty <BooleanProperty>(PropertyNames.M_UseRgbPicker).Value;
            m_RgbColor     = ColorBgra.FromOpaqueInt32(token.GetProperty <Int32Property>(PropertyNames.M_RgbColor).Value);
            m_H            = token.GetProperty <Int32Property>(PropertyNames.M_H).Value;
            m_S            = token.GetProperty <Int32Property>(PropertyNames.M_S).Value;
            m_V            = token.GetProperty <Int32Property>(PropertyNames.M_V).Value;

            base.OnSetRenderInfo(token, dstArgs, srcArgs);
        }
예제 #34
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Rectangle selection = EnvironmentParameters.SelectionBounds;
            double    rmax      = Math.Max(selection.Height, selection.Width);

            innerRadius   = newToken.GetProperty <DoubleProperty>(PropertyNames.InnerRadius).Value *rmax;
            outerRadius   = newToken.GetProperty <DoubleProperty>(PropertyNames.OuterRadius).Value *rmax;
            center        = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Center).Value;
            inverseAlpha  = newToken.GetProperty <BooleanProperty>(PropertyNames.InverseAlpha).Value;
            repeatPerTurn = newToken.GetProperty <Int32Property>(PropertyNames.RepeatPerTurn).Value;
            angle         = newToken.GetProperty <DoubleProperty>(PropertyNames.Angle).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            var newBgSource = (BackgroundSources)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.BackgroundSource).Value;

            this._tolRGB       = newToken.GetProperty <Int32Property>(PropertyNames.ToleranceRGB).Value;
            this._tolHue       = newToken.GetProperty <Int32Property>(PropertyNames.ToleranceHue).Value;
            this._tolSat       = newToken.GetProperty <Int32Property>(PropertyNames.ToleranceSat).Value;
            this._tolVal       = newToken.GetProperty <Int32Property>(PropertyNames.ToleranceVal).Value;
            this._domColMaxDev = newToken.GetProperty <Int32Property>(PropertyNames.DominantColorMaxDeviation).Value;

            if (newBgSource != this._bgSource && (newBgSource == BackgroundSources.ClipboardAverage || newBgSource == BackgroundSources.ClipboardDominant))
            {
                this._clipboardSurface = Utils.GetSurfaceFromClipboard();
            }

            this._bgSource = newBgSource;

            if (this._bgSource == BackgroundSources.DominantColor)
            {
                this._taskBGColor = srcArgs.Surface.GetDominantColorAsync((byte)this._domColMaxDev, 100, this.EnvironmentParameters.GetSelectionScanlines(), this);
            }
            else if (this._bgSource == BackgroundSources.ClipboardDominant)
            {
                this._taskBGColor = this._clipboardSurface?.GetDominantColorAsync((byte)this._domColMaxDev, 100, null, this) ?? Task.FromResult <ArgusColor>(this.EnvironmentParameters.PrimaryColor);
            }
            else if (this._bgSource == BackgroundSources.ClipboardAverage)
            {
                this._taskBGColor = Task.Run(() => { return(this._clipboardSurface?.GetMeanAndStdDeviation(null, this).First ?? this.EnvironmentParameters.PrimaryColor); });
            }
            else if (this._bgSource == BackgroundSources.ColorWheel)
            {
                this._taskBGColor = Task.FromResult <ArgusColor>(ArgusColor.FromRGB(newToken.GetProperty <Int32Property>(PropertyNames.ColorWheel).Value));
            }
            else if (this._bgSource == BackgroundSources.SecondaryColor)
            {
                this._taskBGColor = Task.FromResult <ArgusColor>(this.EnvironmentParameters.SecondaryColor);
            }
            else
            {
                this._taskBGColor = Task.FromResult <ArgusColor>(this.EnvironmentParameters.PrimaryColor);
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #36
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            SelLower  = newToken.GetProperty <Int32Property>(PropertyNames.SelLower).Value;
            SelUpper  = newToken.GetProperty <Int32Property>(PropertyNames.SelUpper).Value;
            SizeLower = newToken.GetProperty <Int32Property>(PropertyNames.SizeLower).Value;
            SizeUpper = newToken.GetProperty <Int32Property>(PropertyNames.SizeUpper).Value;
            ReqLower  = newToken.GetProperty <Int32Property>(PropertyNames.ReqLower).Value;
            ReqUpper  = newToken.GetProperty <Int32Property>(PropertyNames.ReqUpper).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);

            PdnRegion selection = EnvironmentParameters.GetSelection(SrcArgs.Surface.Bounds);

            CustomOnRender(selection.GetRegionScansInt());
        }
예제 #37
0
        protected override void OnSetRenderInfoCore(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            RectInt32 bounds = this.EnvironmentParameters.GetSelection(this.EnvironmentParameters.SourceSurface.Bounds).GetBoundsRectInt32();

            if (this._enumDropDown == null)
            {
                this._enumDropDown = new EnumDropDownValues <ValueSources>();
            }

            this._valueSource = this._enumDropDown.GetEnumMember(newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.ValueSource).Value);

            this._linkFrequencies = newToken.GetProperty <BooleanProperty>(PropertyNames.LinkCutoffFrequencies).Value;
            if (this.ShowSlidersLowPass)
            {
                this._lowPassX = newToken.GetProperty <DoubleProperty>(PropertyNames.CutoffFrequencyLowPassX).Value;
                if (this._linkFrequencies)
                {
                    this._lowPassY = this._lowPassX / bounds.Width * bounds.Height;
                }
                else
                {
                    this._lowPassY = newToken.GetProperty <DoubleProperty>(PropertyNames.CutoffFrequencyLowPassY).Value;
                }
            }
            if (this.ShowSlidersHighPass)
            {
                this._highPassX = newToken.GetProperty <DoubleProperty>(PropertyNames.CutoffFrequencyHighPassX).Value;
                if (this._linkFrequencies)
                {
                    this._highPassY = this._highPassX / bounds.Width * bounds.Height;
                }
                else
                {
                    this._highPassY = newToken.GetProperty <DoubleProperty>(PropertyNames.CutoffFrequencyHighPassY).Value;
                }
            }
        }
예제 #38
0
 protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
 {
     int colorValue = newToken.GetProperty<Int32Property>(PropertyNames.Int32ColorWheel).Value;
     this.color = ColorBgra.FromOpaqueInt32(colorValue);
     base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
 }
예제 #39
0
 protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
 {
     this.brushSize = newToken.GetProperty<Int32Property>(PropertyNames.BrushSize).Value;
     this.coarseness = (byte)newToken.GetProperty<Int32Property>(PropertyNames.Coarseness).Value;
     base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
 }
예제 #40
0
        private Settings GetSettings(PropertyBasedEffectConfigToken newToken)
        {
            var settings = new Settings();

            settings.Text           = newToken.GetProperty <StringProperty>(C.Properties.Text.ToString()).Value;
            settings.FontFamily     = (FontFamily)newToken.GetProperty <StaticListChoiceProperty>(C.Properties.FontFamily.ToString()).Value;
            settings.FontSize       = newToken.GetProperty <Int32Property>(C.Properties.FontSize.ToString()).Value;
            settings.LetterSpacing  = newToken.GetProperty <DoubleProperty>(C.Properties.LetterSpacing.ToString()).Value;
            settings.LineSpacing    = newToken.GetProperty <DoubleProperty>(C.Properties.LineSpacing.ToString()).Value;
            settings.AntiAliasLevel = newToken.GetProperty <Int32Property>(C.Properties.AntiAliasLevel.ToString()).Value;
            settings.FontStyle      = settings.FontFamily.IsStyleAvailable(FontStyle.Regular) ? FontStyle.Regular : settings.FontFamily.IsStyleAvailable(FontStyle.Bold) ? FontStyle.Bold : FontStyle.Italic;
            settings.TextAlign      = (C.TextAlignmentOptions)Enum.Parse(typeof(C.TextAlignmentOptions),
                                                                         newToken
                                                                         .GetProperty <StaticListChoiceProperty>(C.Properties.TextAlignment.ToString())
                                                                         .Value.ToString());
            if (newToken.GetProperty <BooleanProperty>(C.Properties.Bold.ToString()).Value&& settings.FontFamily.IsStyleAvailable(FontStyle.Bold))
            {
                settings.FontStyle |= FontStyle.Bold;
            }
            if (newToken.GetProperty <BooleanProperty>(C.Properties.Italic.ToString()).Value&& settings.FontFamily.IsStyleAvailable(FontStyle.Italic))
            {
                settings.FontStyle |= FontStyle.Italic;
            }
            if (newToken.GetProperty <BooleanProperty>(C.Properties.Underline.ToString()).Value&& settings.FontFamily.IsStyleAvailable(FontStyle.Underline))
            {
                settings.FontStyle |= FontStyle.Underline;
            }
            if (newToken.GetProperty <BooleanProperty>(C.Properties.Strikeout.ToString()).Value&& settings.FontFamily.IsStyleAvailable(FontStyle.Strikeout))
            {
                settings.FontStyle |= FontStyle.Strikeout;
            }

            return(settings);
        }
예제 #41
0
        protected override void OnSetRenderInfo2(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            double scale = newToken.GetProperty<DoubleProperty>(PropertyNames.Scale).Value;

            double refraction = newToken.GetProperty<DoubleProperty>(PropertyNames.Refraction).Value;
            double detail1 = newToken.GetProperty<DoubleProperty>(PropertyNames.Roughness).Value;
            double detail2 = detail1;
            double roughness = detail2;

            double turbulence = newToken.GetProperty<DoubleProperty>(PropertyNames.Tension).Value;

            int quality = newToken.GetProperty<Int32Property>(PropertyNames.Quality).Value;
            byte newSeed = (byte)newToken.GetProperty<Int32Property>(PropertyNames.Seed).Value;

            this.seed = (byte)(this.instanceSeed ^ newSeed);

            this.scaleR = (400.0 / base.DefaultRadius) / scale;
            this.refractionScale = (refraction / 100.0) / scaleR;
            this.theta = Math.PI * 2.0 * turbulence / 10.0;
            this.roughness = roughness / 100.0;

            double detail3 = 1.0 + (detail2 / 10.0);

            // we don't want the perlin noise frequency components exceeding
            // the nyquist limit, so we will limit 'detail' appropriately
            double maxDetail = Math.Floor(Math.Log(this.scaleR) / Math.Log(0.5));

            if (detail3 > maxDetail && maxDetail >= 1.0)
            {
                this.detail = maxDetail;
            }
            else
            {
                this.detail = detail3;
            }

            base.Quality = quality;

            base.OnSetRenderInfo2(newToken, dstArgs, srcArgs);
        }
예제 #42
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            double minRadiusP = newToken.GetProperty<DoubleProperty>(PropertyNames.MinScatterRadius).Value;

            this.minRadius = Math.Min(minRadiusP, Math.Min(srcArgs.Width, srcArgs.Height) / 2); 
            this.maxRadius = newToken.GetProperty<DoubleProperty>(PropertyNames.MaxScatterRadius).Value;
            this.sampleCount = newToken.GetProperty<Int32Property>(PropertyNames.NumSamples).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.redRadius = newToken.GetProperty<Int32Property>(PropertyNames.RedRadius).Value;
            this.greenRadius = newToken.GetProperty<Int32Property>(PropertyNames.GreenRadius).Value;
            this.blueRadius = newToken.GetProperty<Int32Property>(PropertyNames.BlueRadius).Value;
            this.alphaRadius = newToken.GetProperty<Int32Property>(PropertyNames.AlphaRadius).Value;
            this.repeatEdgePixels = newToken.GetProperty<BooleanProperty>(PropertyNames.RepeatEdgePixels).Value;
            this.blurDimensions = (Dimensions)newToken.GetProperty<StaticListChoiceProperty>(PropertyNames.BlurDimensions).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #44
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.softness = newToken.GetProperty<Int32Property>(PropertyNames.Softness).Value;
            this.lighting = newToken.GetProperty<Int32Property>(PropertyNames.Lighting).Value;
            this.warmth = newToken.GetProperty<Int32Property>(PropertyNames.Warmth).Value;

            PropertyBasedEffectConfigToken blurToken = new PropertyBasedEffectConfigToken(this.blurProps);
            blurToken.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, this.softness * 3);
            this.blurEffect.SetRenderInfo(blurToken, dstArgs, srcArgs);

            PropertyBasedEffectConfigToken bacToken = new PropertyBasedEffectConfigToken(this.bacProps);
            bacToken.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, this.lighting);
            bacToken.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, -this.lighting / 2);
            this.bacAdjustment.SetRenderInfo(bacToken, dstArgs, dstArgs);

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.brightness = newToken.GetProperty<Int32Property>(PropertyNames.Brightness).Value;
            this.contrast = newToken.GetProperty<Int32Property>(PropertyNames.Contrast).Value;

            if (this.contrast < 0)
            {
                this.multiply = this.contrast + 100;
                this.divide = 100;
            }
            else if (this.contrast > 0)
            {
                this.multiply = 100;
                this.divide = 100 - this.contrast;
            }
            else
            {
                this.multiply = 1;
                this.divide = 1;
            }

            if (this.rgbTable == null)
            {
                this.rgbTable = new byte[65536];
            }

            if (this.divide == 0)
            {
                for (int intensity = 0; intensity < 256; ++intensity)
                {
                    if (intensity + this.brightness < 128)
                    {
                        this.rgbTable[intensity] = 0;
                    }
                    else
                    {
                        this.rgbTable[intensity] = 255;
                    }
                }
            }
            else if (this.divide == 100)
            {
                for (int intensity = 0; intensity < 256; ++intensity)
                {
                    int shift = (intensity - 127) * this.multiply / this.divide + 127 - intensity + this.brightness;

                    for (int col = 0; col < 256; ++col)
                    {
                        int index = (intensity * 256) + col;
                        this.rgbTable[index] = Utility.ClampToByte(col + shift);
                    }
                }
            }
            else
            {
                for (int intensity = 0; intensity < 256; ++intensity)
                {
                    int shift = (intensity - 127 + this.brightness) * this.multiply / this.divide + 127 - intensity;

                    for (int col = 0; col < 256; ++col)
                    {
                        int index = (intensity * 256) + col;
                        this.rgbTable[index] = Utility.ClampToByte(col + shift);
                    }
                }
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #46
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.angle = newToken.GetProperty<DoubleProperty>(PropertyNames.Angle).Value;
            this.offsetX = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Offset).ValueX;
            this.offsetY = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Offset).ValueY;

            this.quality = newToken.GetProperty<Int32Property>(PropertyNames.Quality).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Amount1 = newToken.GetProperty<DoubleProperty>(PropertyNames.Amount1).Value;
            Amount2 = newToken.GetProperty<Int32Property>(PropertyNames.Amount2).Value;
            Amount3 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount3).Value;
            Amount4 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount4).Value);
            Amount5 = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Amount5).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);

            Bitmap puzzleBitmap = new Bitmap((int)(100 * Amount1), (int)(100 * Amount1), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics puzzleGraphics = Graphics.FromImage(puzzleBitmap);
            puzzleGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            Pen puzzlePen = new Pen(Amount4, Amount2);

            // Create points that define the horizontal curve.
            Point horPoint0 = new Point((int)(-50 * Amount1), (int)(16 * Amount1));
            Point horPoint1 = new Point((int)(0 * Amount1), (int)(16 * Amount1));
            Point horPoint2 = new Point((int)(13 * Amount1), (int)(28 * Amount1));
            Point horPoint3 = new Point((int)(9 * Amount1), (int)(50 * Amount1));

            Point horPoint4 = new Point((int)(49 * Amount1), (int)(49 * Amount1));

            Point horPoint5 = new Point((int)(90 * Amount1), (int)(49 * Amount1));
            Point horPoint6 = new Point((int)(86 * Amount1), (int)(71 * Amount1));
            Point horPoint7 = new Point((int)(99 * Amount1), (int)(83 * Amount1));
            Point horPoint8 = new Point((int)(149 * Amount1), (int)(83 * Amount1));

            Point[] horCurvePoints = { horPoint0, horPoint1, horPoint2, horPoint3, horPoint4, horPoint5, horPoint6, horPoint7, horPoint8 };

            // Draw the horizontal curve to graphics object.
            puzzleGraphics.DrawCurve(puzzlePen, horCurvePoints);

            // Create points that define the vertical curve.
            Point verPoint0 = new Point((int)(83 * Amount1), (int)(-50 * Amount1));
            Point verPoint1 = new Point((int)(83 * Amount1), (int)(0 * Amount1));
            Point verPoint2 = new Point((int)(73 * Amount1), (int)(13 * Amount1));
            Point verPoint3 = new Point((int)(49 * Amount1), (int)(9 * Amount1));

            Point verPoint4 = new Point((int)(50 * Amount1), (int)(50 * Amount1));

            Point verPoint5 = new Point((int)(50 * Amount1), (int)(90 * Amount1));
            Point verPoint6 = new Point((int)(28 * Amount1), (int)(86 * Amount1));
            Point verPoint7 = new Point((int)(16 * Amount1), (int)(99 * Amount1));
            Point verPoint8 = new Point((int)(16 * Amount1), (int)(149 * Amount1));

            Point[] verCurvePoints = { verPoint0, verPoint1, verPoint2, verPoint3, verPoint4, verPoint5, verPoint6, verPoint7, verPoint8 };

            // Draw the vertical curve to graphics object.
            puzzleGraphics.DrawCurve(puzzlePen, verCurvePoints);

            puzzlePen.Dispose();

            puzzleSurface = Surface.CopyFromBitmap(puzzleBitmap);
            puzzleBitmap.Dispose();
        }
 protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
 {
     this._value1 = newToken.GetProperty <BooleanProperty>(PropertyNames.Value1).Value;
     base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
 }
예제 #49
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.amount = newToken.GetProperty<Int32Property>(PropertyNames.Amount).Value;
            this.offset = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Offset).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #50
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Amount1 = newToken.GetProperty<Int32Property>(PropertyNames.Amount1).Value;
            Amount2 = newToken.GetProperty<Int32Property>(PropertyNames.Amount2).Value;
            Amount3 = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Amount3).Value;
            Amount4 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount4).Value;

            Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt();

            double ratio = (double)selection.Height / selection.Width;

            Bitmap srcBitmap = srcArgs.Surface.CreateAliasedBitmap(selection);

            Bitmap croppedBitmap = TrimBitmap(srcBitmap, ratio, Amount3.First, Amount3.Second);
            srcBitmap.Dispose();

            if (croppedBitmap == null)
                croppedBitmap = new Bitmap(srcArgs.Surface.Width, srcArgs.Surface.Height);

            Surface croppedSurface = Surface.CopyFromBitmap(croppedBitmap);
            croppedBitmap.Dispose();

            if (enlargedSurface == null)
                enlargedSurface = new Surface(selection.Size);
            enlargedSurface.FitSurface(ResamplingAlgorithm.Bicubic, croppedSurface);

            if (alignedSurface == null)
                alignedSurface = new Surface(srcArgs.Surface.Size);

            if (selection.Size != srcArgs.Surface.Size)
            {
                for (int y = Math.Max(0, selection.Top - 200); y < Math.Min(alignedSurface.Height, selection.Bottom + 200); y++)
                {
                    if (IsCancelRequested) return;
                    for (int x = Math.Max(0, selection.Left - 200); x < Math.Min(alignedSurface.Width, selection.Right + 200); x++)
                    {
                        alignedSurface[x, y] = enlargedSurface.GetBilinearSampleClamped(x - selection.Left, y - selection.Top);
                    }
                }
            }
            else
            {
                alignedSurface = enlargedSurface;
            }

            if (bluredSurface == null)
                bluredSurface = new Surface(srcArgs.Surface.Size);
            if (lightSurface == null)
                lightSurface = new Surface(srcArgs.Surface.Size);

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #51
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            string                text       = newToken.GetProperty <StringProperty>(PropertyNames.Text).Value + " ";
            int                   textRepeat = newToken.GetProperty <Int32Property>(PropertyNames.TextRepeat).Value;
            int                   fontSize   = newToken.GetProperty <Int32Property>(PropertyNames.FontSize).Value;
            FontFamily            fontFam    = (FontFamily)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Font).Value;
            bool                  bold       = newToken.GetProperty <BooleanProperty>(PropertyNames.Bold).Value;
            bool                  italic     = newToken.GetProperty <BooleanProperty>(PropertyNames.Italic).Value;
            bool                  underline  = newToken.GetProperty <BooleanProperty>(PropertyNames.Underline).Value;
            bool                  strikeout  = newToken.GetProperty <BooleanProperty>(PropertyNames.Strikeout).Value;
            Pair <double, double> offset     = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Offset).Value;

            this.backColor = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.BackColor).Value);

            Rectangle  selection = EnvironmentParameters.SelectionBounds;
            RectangleF textRect  = new RectangleF(
                (float)offset.First * selection.Width + selection.Left,
                (float)offset.Second * selection.Height + selection.Top,
                selection.Width,
                selection.Height);

            System.Text.StringBuilder textRepeated = new System.Text.StringBuilder();
            for (int i = 0; i < textRepeat; i++)
            {
                textRepeated.Append(text);
            }

            if (this.textSurface == null)
            {
                this.textSurface = new Surface(srcArgs.Surface.Size);
            }
            else
            {
                this.textSurface.Clear(Color.Transparent);
            }

            using (Graphics g = new RenderArgs(this.textSurface).Graphics)
            {
                g.TextRenderingHint = TextRenderingHint.AntiAlias;

                FontStyle fontStyle = FontStyle.Regular;
                if (bold)
                {
                    fontStyle |= FontStyle.Bold;
                }
                if (italic)
                {
                    fontStyle |= FontStyle.Italic;
                }
                if (underline)
                {
                    fontStyle |= FontStyle.Underline;
                }
                if (strikeout)
                {
                    fontStyle |= FontStyle.Strikeout;
                }

                using (SolidBrush fontBrush = new SolidBrush(Color.Black))
                    using (Font font = new Font(fontFam, fontSize, fontStyle))
                    {
                        g.DrawString(textRepeated.ToString(), font, fontBrush, textRect);
                    }
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #52
0
 protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
 {
     this.Value1 = (int)newToken.GetProperty<StaticListChoiceProperty>(PropertyNames.Type).Value;
     this.Value2 = newToken.GetProperty<Int32Property>(PropertyNames.Aperture).Value;
     //this.Value3 = newToken.GetProperty<Int32Property>(PropertyNames.Tolerance).Value;
     //this.Value4 = newToken.GetProperty<BooleanProperty>(PropertyNames.Alpha).Value;
     base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
 }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.amount = newToken.GetProperty<Int32Property>(PropertyNames.Amount).Value;
            this.center.X = (int)((1 + newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Center).ValueX) * (srcArgs.Width / 2.0));
            this.center.Y = (int)((1 + newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Center).ValueY) * (srcArgs.Height / 2.0));

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #54
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Amount1 = newToken.GetProperty<DoubleProperty>(PropertyNames.Amount1).Value;
            Amount2 = newToken.GetProperty<Int32Property>(PropertyNames.Amount2).Value;
            Amount3 = (byte)((int)newToken.GetProperty<StaticListChoiceProperty>(PropertyNames.Amount3).Value);
            Amount4 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount4).Value;
            Amount5 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount5).Value);
            Amount6 = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Amount6).Value;

            Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt();

            Bitmap puzzleBitmap = new Bitmap(selection.Width, selection.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics puzzleGraphics = Graphics.FromImage(puzzleBitmap);
            puzzleGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            gridScale = 100 * Amount1;

            xOffset = (int)((selection.Width % gridScale) / 2 + (Amount6.First * (selection.Width % gridScale) / 2));
            yOffset = (int)((selection.Height % gridScale) / 2 + (Amount6.Second * (selection.Height % gridScale) / 2));

            int puzzleWidth = selection.Width - (int)(selection.Width % gridScale);
            int puzzleHeight = selection.Height - (int)(selection.Height % gridScale);

            horLoops = puzzleHeight / (int)(gridScale);
            verLoops = puzzleWidth / (int)(gridScale);

            // Puzzle Pattern
            bool horAlt, verAlt;
            switch (Amount3)
            {
                case 0:
                    horAlt = true;
                    verAlt = true;
                    break;
                case 1:
                    horAlt = false;
                    verAlt = false;
                    break;
                case 2:
                    horAlt = true;
                    verAlt = false;
                    break;
                case 3:
                    horAlt = false;
                    verAlt = true;
                    break;
                default:
                    horAlt = true;
                    verAlt = true;
                    break;
            }

            Pen puzzlePen = new Pen(Amount5, Amount2);
            PointF[] curvePoints;

            //Horizontal Lines
            #region Horizontal Lines
            for (int i = 0; i < horLoops - 1; i++)
            {
                if (horAlt && i % 2 == 0)
                {
                    for (int i2 = 0; i2 < verLoops; i2++)
                    {
                        if (i2 % 2 != 0) // upper apex on odds
                        {
                            curvePoints = getCurvePoints(0, i, i2); // upper apex
                        }
                        else
                        {
                            curvePoints = getCurvePoints(2, i, i2); // lower apex
                        }

                        puzzleGraphics.DrawCurve(puzzlePen, curvePoints);
                    }
                }
                else
                {
                    for (int i2 = 0; i2 < verLoops; i2++)
                    {
                        if (i2 % 2 == 0) // upper apex on evens
                        {
                            curvePoints = getCurvePoints(0, i, i2); // upper apex
                        }
                        else
                        {
                            curvePoints = getCurvePoints(2, i, i2); // lower apex
                        }

                        puzzleGraphics.DrawCurve(puzzlePen, curvePoints);
                    }
                }
            }
            #endregion

            //Vertical Lines
            #region Vertical Lines
            for (int i = 0; i < verLoops - 1; i++)
            {
                if (verAlt && i % 2 == 0)
                {
                    for (int i2 = 0; i2 < horLoops; i2++)
                    {
                        if (i2 % 2 != 0) // right apex on odds
                        {
                            curvePoints = getCurvePoints(1, i, i2); // right apex
                        }
                        else
                        {
                            curvePoints = getCurvePoints(3, i, i2); // left apex
                        }

                        puzzleGraphics.DrawCurve(puzzlePen, curvePoints);
                    }
                }
                else
                {
                    for (int i2 = 0; i2 < horLoops; i2++)
                    {
                        if (i2 % 2 == 0) // right apex on evens
                        {
                            curvePoints = getCurvePoints(1, i, i2); // right apex
                        }
                        else
                        {
                            curvePoints = getCurvePoints(3, i, i2); // left apex
                        }

                        puzzleGraphics.DrawCurve(puzzlePen, curvePoints);
                    }
                }
            }
            #endregion

            puzzlePen.Dispose();

            puzzleSurface = Surface.CopyFromBitmap(puzzleBitmap);
            puzzleBitmap.Dispose();

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #55
0
 protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
 {
     this.cellSize = newToken.GetProperty<Int32Property>(PropertyNames.CellSize).Value;
     base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
 }
예제 #56
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            rPath  = newToken.GetProperty <StringProperty>(PropertyNames.RedFile).Value;
            gPath  = newToken.GetProperty <StringProperty>(PropertyNames.GreenFile).Value;
            bPath  = newToken.GetProperty <StringProperty>(PropertyNames.BlueFile).Value;
            aPath  = newToken.GetProperty <StringProperty>(PropertyNames.AlphaFile).Value;
            input1 = (int)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Input1).Value;
            input2 = (int)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Input2).Value;
            input3 = (int)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Input3).Value;
            input4 = (int)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Input4).Value;

            Bitmap rImage = null;

            if (File.Exists(rPath))
            {
                try
                {
                    rImage = new Bitmap(rPath);
                }
                catch
                {
                }
            }

            if (rSurface != null)
            {
                rSurface.Dispose();
                rSurface = null;
            }

            if (rImage != null && rImage?.Size == srcArgs.Size)
            {
                rSurface = Surface.CopyFromBitmap(rImage);
            }

            rImage?.Dispose();

            Bitmap gImage = null;

            if (File.Exists(gPath))
            {
                try
                {
                    gImage = new Bitmap(gPath);
                }
                catch
                {
                }
            }

            if (gSurface != null)
            {
                gSurface.Dispose();
                gSurface = null;
            }

            if (gImage != null && gImage.Size == srcArgs.Size)
            {
                gSurface = Surface.CopyFromBitmap(gImage);
            }

            gImage?.Dispose();

            Bitmap bImage = null;

            if (File.Exists(bPath))
            {
                try
                {
                    bImage = new Bitmap(bPath);
                }
                catch
                {
                }
            }

            if (bSurface != null)
            {
                bSurface.Dispose();
                bSurface = null;
            }

            if (bImage != null && bImage.Size == srcArgs.Size)
            {
                bSurface = Surface.CopyFromBitmap(bImage);
            }

            bImage?.Dispose();

            Bitmap aImage = null;

            if (File.Exists(aPath))
            {
                try
                {
                    aImage = new Bitmap(aPath);
                }
                catch
                {
                }
            }

            if (aSurface != null)
            {
                aSurface.Dispose();
                aSurface = null;
            }

            if (aImage != null && aImage?.Size == srcArgs.Size)
            {
                aSurface = Surface.CopyFromBitmap(aImage);
            }

            aImage?.Dispose();

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #57
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            int red = newToken.GetProperty<Int32Property>(PropertyNames.RedLevels).Value;
            int green = newToken.GetProperty<Int32Property>(PropertyNames.GreenLevels).Value;
            int blue = newToken.GetProperty<Int32Property>(PropertyNames.BlueLevels).Value;

            this.op = new PosterizePixelOp(red, green, blue);

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #58
0
        //private PointF[] aaPointsArray;

        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.rotation = -newToken.GetProperty<DoubleProperty>(PropertyNames.Rotation).Value;
            this.squareSize = newToken.GetProperty<DoubleProperty>(PropertyNames.SquareSize).Value;
            this.curvature = newToken.GetProperty<DoubleProperty>(PropertyNames.Curvature).Value;
            
            this.sin = (float)Math.Sin(this.rotation * Math.PI / 180.0);
            this.cos = (float)Math.Cos(this.rotation * Math.PI / 180.0);
            this.scale = (float)(Math.PI / this.squareSize);
            this.intensity = (float)(this.curvature * this.curvature / 10.0 * Math.Sign(this.curvature));

            this.quality = newToken.GetProperty<Int32Property>(PropertyNames.Quality).Value;

            if (this.quality != 1)
            {
                ++this.quality;
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #59
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Amount1 = newToken.GetProperty<Int32Property>(PropertyNames.Amount1).Value;
            Amount2 = newToken.GetProperty<Int32Property>(PropertyNames.Amount2).Value;
            Amount3 = (byte)((int)newToken.GetProperty<StaticListChoiceProperty>(PropertyNames.Amount3).Value);
            Amount4 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount4).Value);
            Amount5 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount5).Value);
            Amount6 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount6).Value);
            Amount7 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount7).Value);

            Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Bounds).GetBoundsInt();

            Bitmap tattersallBitmap = new Bitmap(selection.Width, selection.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics tattersallGraphics = Graphics.FromImage(tattersallBitmap);

            // Fill with white
            Rectangle backgroundRect = new Rectangle(0, 0, selection.Width, selection.Height);
            using (SolidBrush backColor = new SolidBrush(Amount7))
                tattersallGraphics.FillRectangle(backColor, backgroundRect);

            // Set Brush Styles
            Brush brush1, brush2, brush3;
            switch (Amount3)
            {
                case 0: // Solid 33% Opacity
                    brush1 = new SolidBrush(Color.FromArgb(85, Amount4));
                    brush2 = new SolidBrush(Color.FromArgb(85, Amount5));
                    brush3 = new SolidBrush(Color.FromArgb(85, Amount6));
                    break;
                case 1: // Solid 66% Opacity
                    brush1 = new SolidBrush(Color.FromArgb(170, Amount4));
                    brush2 = new SolidBrush(Color.FromArgb(170, Amount5));
                    brush3 = new SolidBrush(Color.FromArgb(170, Amount6));
                    break;
                case 2: // Diagonal Lines Up
                    brush1 = new HatchBrush(HatchStyle.DarkUpwardDiagonal, Amount4, Amount7);
                    brush2 = new HatchBrush(HatchStyle.DarkUpwardDiagonal, Amount5, Amount7);
                    brush3 = new HatchBrush(HatchStyle.DarkUpwardDiagonal, Amount6, Amount7);
                    break;
                case 3: // Diagonal Lines Down
                    brush1 = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Amount4, Amount7);
                    brush2 = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Amount5, Amount7);
                    brush3 = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Amount6, Amount7);
                    break;
                case 4: // 50/50 Dots
                    brush1 = new HatchBrush(HatchStyle.Percent50, Amount4, Amount7);
                    brush2 = new HatchBrush(HatchStyle.Percent50, Amount5, Amount7);
                    brush3 = new HatchBrush(HatchStyle.Percent50, Amount6, Amount7);
                    break;
                default:
                    brush1 = new SolidBrush(Color.FromArgb(85, Amount4));
                    brush2 = new SolidBrush(Color.FromArgb(85, Amount5));
                    brush3 = new SolidBrush(Color.FromArgb(85, Amount6));
                    break;
            }

            // Set pen styles.
            Pen pen1 = new Pen(brush1, Amount1);
            brush1.Dispose();
            Pen pen2 = new Pen(brush2, Amount1);
            brush2.Dispose();
            Pen pen3 = new Pen(brush3, Amount1);
            brush3.Dispose();

            // Calculate the number of lines will fit in the selection
            int xLoops = (int)Math.Ceiling((double)selection.Height / ((Amount1 + Amount2) * 3));
            int yLoops = (int)Math.Ceiling((double)selection.Width / ((Amount1 + Amount2) * 3));

            // Draw Horizontal Lines
            for (int i = 0; i < xLoops; i++)
            {
                // Create points that define line.
                Point point1 = new Point(0, Amount1 / 2 + (Amount1 + Amount2) * i * 3);
                Point point2 = new Point(selection.Width, Amount1 / 2 + (Amount1 + Amount2) * i * 3);

                // Draw line to screen.
                tattersallGraphics.DrawLine(pen1, point1, point2);

                // Create points that define line.
                Point point3 = new Point(0, Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2));
                Point point4 = new Point(selection.Width, Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2));

                // Draw line to screen.
                tattersallGraphics.DrawLine(pen2, point3, point4);

                // Create points that define line.
                Point point5 = new Point(0, Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2) * 2);
                Point point6 = new Point(selection.Width, Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2) * 2);

                // Draw line to screen.
                tattersallGraphics.DrawLine(pen3, point5, point6);

            }

            // Draw Vertical Lines
            for (int i = 0; i < yLoops; i++)
            {
                // Create points that define line.
                Point point1 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3, 0);
                Point point2 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3, selection.Height);

                // Draw line to screen.
                tattersallGraphics.DrawLine(pen1, point1, point2);

                // Create points that define line.
                Point point3 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2), 0);
                Point point4 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2), selection.Height);

                // Draw line to screen.
                tattersallGraphics.DrawLine(pen2, point3, point4);

                // Create points that define line.
                Point point5 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2) * 2, 0);
                Point point6 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2) * 2, selection.Height);

                // Draw line to screen.
                tattersallGraphics.DrawLine(pen3, point5, point6);
            }

            pen1.Dispose();
            pen2.Dispose();
            pen3.Dispose();

            tattersallSurface = Surface.CopyFromBitmap(tattersallBitmap);
            tattersallBitmap.Dispose();

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }
예제 #60
0
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            int fragments = newToken.GetProperty<Int32Property>(PropertyNames.Fragments).Value;
            double rotation = newToken.GetProperty<DoubleProperty>(PropertyNames.Rotation).Value;
            int distance = newToken.GetProperty<Int32Property>(PropertyNames.Distance).Value;

            RecalcPointOffsets(fragments, rotation, distance);

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }