示例#1
0
        public static LTexture CreateShadowTexture(LTexture texture, float alpha,
                                                   float scale, float angle)
        {
            int     width   = texture.Width;
            int     height  = texture.Height;
            LPixmap image   = new LPixmap(texture);
            int     centerX = width / 2;
            int     centerY = height / 2;
            int     offsetX = (int)((width - image.Width) / 2);
            int     offsetY = (int)((height - image.Height) / 2);

            Loon.Core.Geom.Matrix.Transform2i t = new Loon.Core.Geom.Matrix.Transform2i();
            t.Rotate(angle, centerX, centerY);
            t.Zoom(scale, centerX, centerY);
            LPixmap shadowProcess = new LPixmap(width, height,
                                                image.IsAlpha());

            shadowProcess.DrawPixmap(image, offsetX, offsetY);
            shadowProcess.Transparency();
            shadowProcess.Mul(255, 0, 0, 0);
            shadowProcess.Mul((int)(alpha * 255), 255, 255, 255);
            shadowProcess.Convolve(LPixmap.GaussianBlurKernel());
            shadowProcess.Transform(t);
            if (image != null)
            {
                image.Dispose();
                image = null;
            }
            return(shadowProcess.Texture);
        }