예제 #1
0
        public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, System.Drawing.Rectangle[] rois, int startIndex, int length)
        {
            CloudsEffectConfigToken token   = (CloudsEffectConfigToken)parameters;
            UserBlendOp             blendOp = token.BlendOp;

            if (blendOp is UserBlendOps.NormalBlendOp &&
                EnvironmentParameters.PrimaryColor.A == 255 &&
                EnvironmentParameters.SecondaryColor.A == 255)
            {
                // this is just an optimization
                blendOp = null;
            }

            this.scale = token.Amount1;
            this.power = token.Amount2 / 100.0f;
            this.seed  = (byte)(token.Seed ^ instanceSeed);

            for (int i = startIndex; i < startIndex + length; ++i)
            {
                RenderClouds(dstArgs.Surface, rois[i]);

                if (blendOp != null)
                {
                    blendOp.Apply(dstArgs.Surface, rois[i].Location, srcArgs.Surface,
                                  rois[i].Location, dstArgs.Surface, rois[i].Location, rois[i].Size);
                }
            }
        }
예제 #2
0
        protected override void OnRender(Rectangle[] renderRects, int startIndex, int length)
        {
            for (int i = startIndex; i < startIndex + length; ++i)
            {
                RenderClouds(this.DstArgs.Surface, renderRects[i], this.scale, this.seed,
                             this.power, EnvironmentParameters.PrimaryColor, EnvironmentParameters.SecondaryColor);

                if (blendOp != null)
                {
                    blendOp.Apply(this.DstArgs.Surface, renderRects[i].Location, this.SrcArgs.Surface,
                                  renderRects[i].Location, this.DstArgs.Surface, renderRects[i].Location, renderRects[i].Size);
                }
            }
        }
예제 #3
0
        public override void Render(Surface src, Surface dest, Rectangle[] rois, int startIndex, int length)
        {
            for (int i = startIndex; i < startIndex + length; ++i)
            {
                RenderClouds(dest, rois[i], this.scale, this.seed,
                             this.power, primaryColor, secondaryColor);

                if (blendOp != null)
                {
                    blendOp.Apply(dest, rois[i].Location, src,
                                  rois[i].Location,
                                  dest,
                                  rois[i].Location,
                                  rois[i].Size);
                }
            }
        }
예제 #4
0
파일: Effect.cs 프로젝트: bsneeze/pdn-trail
        protected unsafe override void OnRender(Rectangle[] renderRects, int startIndex, int length)
        {
            Surface   dst    = DstArgs.Surface;
            Surface   src    = SrcArgs.Surface;
            Rectangle bounds = SrcArgs.Bounds;

            dst.CopySurface(src, renderRects);

            foreach (Rectangle rect in renderRects)
            {
                for (
                    double xoffset = 0, yoffset = 0;
                    xoffset <= DistanceX && yoffset <= DistanceY;
                    xoffset += SpacingX, yoffset += SpacingY)
                {
                    float xdirectedoffset = -(float)xoffset * DirectionX;
                    float ydirectedoffset = -(float)yoffset * DirectionY;

                    if (IsCancelRequested)
                    {
                        return;
                    }

                    for (int y = rect.Top; y < rect.Bottom; ++y)
                    {
                        float srcy = y + ydirectedoffset;
                        if (!(bounds.Top <= srcy && srcy < bounds.Bottom))
                        {
                            continue;
                        }
                        ColorBgra *dstptr = dst.GetPointAddressUnchecked(rect.Left, y);
                        ColorBgra *srcptr = src.GetPointAddressUnchecked(0, (int)srcy);

                        for (int x = rect.Left; x < rect.Right; ++x)
                        {
                            float srcx = x + xdirectedoffset;
                            if (!(bounds.Left <= srcx && srcx < bounds.Right))
                            {
                                ++dstptr;
                                continue;
                            }

                            ColorBgra srcpixel;
                            if (Bilinear)
                            {
                                srcpixel = src.GetBilinearSample(srcx, srcy);
                            }
                            else
                            {
                                srcpixel = *(srcptr + (int)srcx);
                            }

                            if (Fade)
                            {
                                srcpixel.A = (byte)((srcpixel.A) * (1 - xoffset / DistanceX));
                            }

                            *dstptr = blendOp.Apply(srcpixel, *dstptr);
                            ++dstptr;
                        }
                    }
                }
            }
        }
예제 #5
0
 // Adapted to 2-D version in C# from 3-D version in Java from http://mrl.nyu.edu/~perlin/noise/
 protected override void RenderLine(ISurface src, ISurface dst, Rectangle roi)
 {
     RenderClouds(dst, roi, scale, (byte)(seed), power / 100.0, from_color, to_color);
     blend_op.Apply(src, dst, dst, roi);
 }