示例#1
0
文件: Flash.cs 项目: kaldap/XnaFlash
        private Flash(Game game, IServiceProvider services, FlashDocument document, int surfaceWidth, int surfaceHeight)
            : base(null)
        {
            if (document == null) throw new ArgumentNullException("document");
            if (services == null) throw new ArgumentNullException("services");

            ISystemServices system = (ISystemServices)services.GetService(typeof(ISystemServices));
            if (system == null) throw new InvalidOperationException("Flash can be used only with ISystemServices registered!");

            _surface = system.VectorDevice.CreateSurface(surfaceWidth, surfaceHeight, SurfaceFormat.Color);
            Root = new RootMovieClip(document, system);
            SurfaceSize = new Vector2(surfaceWidth, surfaceHeight);
            SizeInTwips = new Vector2(document.Width, document.Height);
        }
示例#2
0
 public void Draw(VGSurface surface)
 {
     using (var draw = Services.VectorDevice.BeginRendering(surface, new DisplayState(), true))
     {
         draw.State.ResetDefaultValues();
         draw.State.SetAntialiasing(Antialiasing);
         draw.State.SetProjection(Width, Height);
         draw.State.NonScalingStroke = true;
         draw.State.MaskingEnabled = false;
         draw.State.FillRule = VGFillRule.EvenOdd;
         draw.State.ColorTransformationEnabled = true;
         draw.Device.GraphicsDevice.Clear(
             ClearOptions.Stencil | ClearOptions.Target | ClearOptions.DepthBuffer,
             Transparent ? Color.Transparent.ToVector4() : Document.BackgroundColor.ToVector4(),
             0f, 0);
         (this as IDrawable).Draw(draw);
     }
 }
示例#3
0
文件: Flash.cs 项目: kaldap/XnaFlash
 protected override void Dispose(bool disposing)
 {
     if (disposing && _surface != null)
     {
         _surface.Dispose();
         _surface = null;
     }
     base.Dispose(disposing);
 }