コード例 #1
0
ファイル: Shape.cs プロジェクト: kaldap/XnaFlash
        private VGPaint MakeFill(FillStyle f, IVGDevice device, FlashDocument document)
        {
            VGPaint paint = null;

            switch (f.FillType)
            {
                case FillStyle.FillStyleType.Solid:
                    paint = device.CreateColorPaint(f.Color);
                    break;
                case FillStyle.FillStyleType.Linear:
                    paint = device.CreateLinearPaint(f.Gradient.AsEnumerable(), f.Gradient.InterpolationMode == GradientInfo.Interpolation.Linear);
                    break;
                case FillStyle.FillStyleType.Radial:
                case FillStyle.FillStyleType.Focal:
                    paint = device.CreateRadialPaint(f.Gradient.AsEnumerable(), f.Gradient.InterpolationMode == GradientInfo.Interpolation.Linear);
                    break;
                case FillStyle.FillStyleType.RepeatingBitmap:
                case FillStyle.FillStyleType.RepeatingNonsmoothedBitmap:
                case FillStyle.FillStyleType.ClippedBitmap:
                case FillStyle.FillStyleType.ClippedNonsmoothedBitmap:
                    paint = device.CreatePatternPaint((document[f.BitmapID] as Bitmap).Image);
                    break;
            }

            if (paint is VGColorPaint)
                return paint;

            if (paint is VGGradientPaint)
            {
                if (f.Gradient is FocalGradientInfo)
                    (paint as VGRadialPaint).FocalPoint = (float)(f.Gradient as FocalGradientInfo).FocalPoint;

                var p = paint as VGGradientPaint;
                p.GradientFilter = TextureFilter.Linear;
                switch (f.Gradient.PadMode)
                {
                    case GradientInfo.Padding.Pad:
                        p.AddressMode = TextureAddressMode.Clamp;
                        break;
                    case GradientInfo.Padding.Reflect:
                        p.AddressMode = TextureAddressMode.Mirror;
                        break;
                    case GradientInfo.Padding.Repeat:
                        p.AddressMode = TextureAddressMode.Wrap;
                        break;
                }
            }

            if (paint is VGPatternPaint)
            {
                var i = (paint as VGPatternPaint).Pattern;
                switch (f.FillType)
                {
                    case FillStyle.FillStyleType.RepeatingBitmap:
                        i.ImageFilter = TextureFilter.Linear;
                        i.AddressMode = TextureAddressMode.Wrap;
                        break;
                    case FillStyle.FillStyleType.RepeatingNonsmoothedBitmap:
                        i.ImageFilter = TextureFilter.Point;
                        i.AddressMode = TextureAddressMode.Wrap;
                        break;
                    case FillStyle.FillStyleType.ClippedBitmap:
                        i.ImageFilter = TextureFilter.Linear;
                        i.AddressMode = TextureAddressMode.Clamp;
                        break;
                    case FillStyle.FillStyleType.ClippedNonsmoothedBitmap:
                        i.ImageFilter = TextureFilter.Point;
                        i.AddressMode = TextureAddressMode.Clamp;
                        break;
                }
            }

            return paint;
        }
コード例 #2
0
ファイル: FlashPlayerControl.cs プロジェクト: kaldap/XnaFlash
 protected void Initialize()
 {
     VectorDevice = VGDevice.Initialize(GraphicsDevice, gameServiceContainer);
     Application.Idle += delegate { Invalidate(); };
 }