/// <inheritdoc/> void IFileWriter.Save(string path, object item, object options) { if (string.IsNullOrEmpty(path) || item == null) { return; } var ic = options as IImageCache; if (options == null) { return; } IProjectExporter exporter = new PdfRenderer(); ShapeRenderer renderer = (PdfRenderer)exporter; renderer.State.DrawShapeState.Flags = ShapeStateFlags.Printable; renderer.State.ImageCache = ic; if (item is XContainer) { exporter.Save(path, item as XContainer); } else if (item is XDocument) { exporter.Save(path, item as XDocument); } else if (item is XProject) { exporter.Save(path, item as XProject); } }
public static void RenderShapeToStream(string dataDir, Shape shape) { //ExStart //ExFor:ShapeRenderer //ExFor:ShapeRenderer.#ctor(ShapeBase) //ExFor:ImageSaveOptions.ImageColorMode //ExFor:ImageSaveOptions.ImageBrightness //ExFor:ShapeRenderer.Save(Stream, ImageSaveOptions) //ExId:RenderShapeToStream //ExSummary:Shows how to render a shape independent of the document to a JPEG image and save it to a stream. // We can also retrieve the renderer for a shape by using the ShapeRenderer constructor. ShapeRenderer r = new ShapeRenderer(shape); // Define custom options which control how the image is rendered. Render the shape to the vector format EMF. ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.Jpeg) { // Output the image in gray scale ImageColorMode = ImageColorMode.Grayscale, // Reduce the brightness a bit (default is 0.5f). ImageBrightness = 0.45f }; FileStream stream = new FileStream(dataDir + "TestFile.RenderToStream Out.jpg", FileMode.CreateNew); // Save the rendered image to the stream using different options. r.Save(stream, imageOptions); //ExEnd }
public void GetOpaqueBoundsInPixels() { Document doc = new Document(MyDir + "Shape.TextBox.doc"); Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true); ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.Jpeg); MemoryStream stream = new MemoryStream(); ShapeRenderer renderer = shape.GetShapeRenderer(); renderer.Save(stream, imageOptions); shape.Remove(); // Check that the opaque bounds and bounds have default values Assert.AreEqual(250, renderer.GetOpaqueBoundsInPixels(imageOptions.Scale, imageOptions.VerticalResolution).Width); Assert.AreEqual(52, renderer.GetOpaqueBoundsInPixels(imageOptions.Scale, imageOptions.HorizontalResolution).Height); Assert.AreEqual(250, renderer.GetBoundsInPixels(imageOptions.Scale, imageOptions.VerticalResolution).Width); Assert.AreEqual(52, renderer.GetBoundsInPixels(imageOptions.Scale, imageOptions.HorizontalResolution).Height); Assert.AreEqual(250, renderer.GetOpaqueBoundsInPixels(imageOptions.Scale, imageOptions.HorizontalResolution).Width); Assert.AreEqual(52, renderer.GetOpaqueBoundsInPixels(imageOptions.Scale, imageOptions.HorizontalResolution).Height); Assert.AreEqual(250, renderer.GetBoundsInPixels(imageOptions.Scale, imageOptions.VerticalResolution).Width); Assert.AreEqual(52, renderer.GetBoundsInPixels(imageOptions.Scale, imageOptions.VerticalResolution).Height); Assert.AreEqual((float)187.850006, renderer.OpaqueBoundsInPoints.Width); Assert.AreEqual((float)39.25, renderer.OpaqueBoundsInPoints.Height); }
internal override void Draw(GameTime gameTime) { ShapeRenderer.DrawRectangle(_backgroundColor, ClientAreaRectangle); ShapeRenderer.DrawBorder(Focused ? _borderColorFocused : _borderColorUnfocused, ClientAreaRectangle, BORDER_WIDTH); SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, _scissorState); Rectangle preScissor = GraphicsDevice.ScissorRectangle; GraphicsDevice.ScissorRectangle = _scissorRectangle; SpriteBatch.DrawString(ContentLibrary.UIFont_Small, _text, AbsoluteClientAreaPosition + new Vector2(2 - _currentOffset, (Height - ContentLibrary.UIFont_Small.LineSpacing) / 2f), TextColor); if (Focused) { if (Environment.TickCount - _lastSwitchCaretVisibility >= 500 || _forceCaretVisible) { _lastSwitchCaretVisibility = Environment.TickCount; _showCaret = !_showCaret || _forceCaretVisible; } if (_showCaret) { SpriteBatch.Draw(ContentLibrary.DummyTexture, new Rectangle((int)_caretPosition.X, (int)_caretPosition.Y, 1, ContentLibrary.UIFont_Small.LineSpacing), _textColor); } } GraphicsDevice.ScissorRectangle = preScissor; SpriteBatch.End(); }
public override bool OpenUrl(UIApplication application, NSUrl receivedurl, string sourceApplication, NSObject annotation) { AsNumAssemblyHelper.HoldAssembly(); global::Xamarin.Forms.Forms.Init(); FloatingActionButtonRenderer.InitRenderer(); OxyPlot.Xamarin.Forms.Platform.iOS.PlotViewRenderer.Init(); DependencyService.Register <ToastNotification>(); Plugin.Toasts.ToastNotification.Init(); //global::Xamarin.FormsMaps.Init(); FormsPlugin.Iconize.iOS.IconControls.Init(); var dummy = new FFImageLoading.Forms.Touch.CachedImageRenderer(); FFImageLoading.Forms.Touch.CachedImageRenderer.Init(); FormsPlugin.Iconize.iOS.IconControls.Init(); Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.FontAwesomeModule()); Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.IoniconsModule()); ShapeRenderer.Init(); ImageCircleRenderer.Init(); string url = receivedurl.ToString(); //string[] values = Intent.DataString.ToString().Split('/'); // string inttype = values[values.Length - 1]; string integrationtype = url.Trim().Contains("google_fit") ? "2" : "1"; string integration = url.Substring(url.IndexOf("code=") + 4 + 1); //LoadApplication(new App(integrationtype, integration)); LoadApplication(new App(integrationtype, integration)); /* now store the url somewhere in the app’s context. The url is in the url NSUrl object. The data is in url.Host if the link as a scheme as superduperapp://something_interesting */ return(true); }
/// <summary> /// Create thrusts backfire effect and attach to target gameobject. /// </summary> /// <param name="target">Object to add effect to.</param> private void AddBackfireEffect(GameObject target) { // create a particle type of the ship thrust fire effect BaseAnimatorProperties prop = BaseAnimatorProperties.Defaults; GameObject backfire = new GameObject("backfire"); // create a sphere renderer for the backfire particle ShapeRenderer renderer = backfire.AddComponent(new ShapeRenderer(ShapeMeshes.SphereSmooth)) as ShapeRenderer; renderer.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Effects; // add animators, jitter and time-to-live backfire.AddComponent(new TimeToLive(0.5f)); backfire.AddComponent(new SpawnRandomizer(minColor: Color.Red, maxColor: Color.Yellow)); backfire.AddComponent(new FadeAnimator(prop, 1.0f, 0f, 0.5f)); backfire.AddComponent(new ScaleAnimator(prop, 0.5f, 0.1f, 0.5f)); backfire.AddComponent(new MotionAnimator(prop, Vector3.Backward * 15)); // create particles system for the backfire effect GameObject backfireSystem = new GameObject("backfire-system"); backfireSystem.SceneNode.PositionZ = 1f; ParticleSystem system = backfireSystem.AddComponent(new ParticleSystem()) as ParticleSystem; // add our backfire particle and set frequency system.AddParticleType(new ParticleType(backfire, frequency: 1.0f)); system.Interval = 0.025f; system.AddParticlesToRoot = true; // attach particle system to player backfireSystem.Parent = target; }
private void SetRenderer(ShapeRenderer renderer) { if (_context != null) { _context.Renderer = renderer; } }
public override void Draw(SpriteBatch sb) { base.Draw(sb); ShapeRenderer.Rect(sb, Color, GetDrawPosition(), BoundingBox * 2); ShapeRenderer.Rect(sb, Color, (int)Position.X, (int)Position.Y, (int)BoundingBox.X, (int)BoundingBox.Y); Looking = Looking.Forward; float rotation = 0; if (LookingDown) { rotation = (float)Math.PI; } if (LookingUp) { } if (Facing == Facing.Right) { ShapeRenderer.Rect(sb, Color.DarkBlue, GetDrawPosition() + new Vector2(BoundingBox.X * 2, 0), new Vector2(30, 10)); } if (Facing == Facing.Left) { ShapeRenderer.Rect(sb, Color.DarkBlue, GetDrawPosition() - new Vector2(30, 0), new Vector2(30, 10)); } //ShapeRenderer.Rect(sb, Color.DarkBlue, GetDrawPosition(), new Vector2(20, 8), rotation); TextRenderer.Print(sb, Health.ToString(), GetDrawPosition(), Color.Green); }
public ExampleOne() : base(800, 450, GraphicsMode.Default, "Farseer Physics - Example One") { GL.ClearColor(Color4.White); shapeRenderer = new ShapeRenderer(800, 450); world = new World(new Vector2(0f, 9.8f)); //Create two rectangles, one that doesn't move and acts like a platform, and another that's a dynamic box Vector2 size = new Vector2(50f, 50f); body01 = BodyFactory.CreateRectangle(world, size.X * pixelToUnit, size.Y * pixelToUnit, 1f); body01.BodyType = BodyType.Dynamic; body01.Position = new Vector2(400f, 0f) * pixelToUnit; body01Shape = ShapeConstructor.ConstructShapeFromBody(body01); size = new Vector2(800f, 50f); body02 = BodyFactory.CreateRectangle(world, size.X * pixelToUnit, size.Y * pixelToUnit, 1f); body02.BodyType = BodyType.Kinematic; body02.Position = new Vector2(400f, 225f) * pixelToUnit; body02.Rotation = MathHelper.PiOver6; body02Shape = ShapeConstructor.ConstructShapeFromBody(body02); }
public void InitialiseGraphicsResources(GraphicsDevice device, AssetManager assets) { var viewportSize = device.Viewport.Size; this.camera = new OrthoCamera(viewportSize); this.renderer = device.CreateShapeRenderer(this.camera); }
protected override void DrawOverride(ref bool isGameViewFocused) { if (Context.SelectedAptWindow == null) { ImGui.Text("APT geometry is only available when an APT window has been selected in the APT Windows window."); return; } var geometryChanged = false; if (Context.SelectedAptWindow != _currentWindow) { _geometryNames = Context.SelectedAptWindow.AptFile.GeometryMap.Keys .Select(x => x.ToString()) .ToArray(); _currentWindow = Context.SelectedAptWindow; _currentGeometry = 0; geometryChanged = true; } if (ImGui.Combo("Geometry", ref _currentGeometry, _geometryNames, _geometryNames.Length)) { geometryChanged = true; } var geometry = Context.SelectedAptWindow.AptFile.GeometryMap[Convert.ToUInt32(_geometryNames[_currentGeometry])]; ImGui.BeginChild("geometry sidebar", new Vector2(150, 0), true, 0); ImGui.TextWrapped(geometry.RawText); ImGui.EndChild(); ImGui.SameLine(); if (geometryChanged) { _shapeRenderer = new ShapeRenderer( geometry, Context.Game.ContentManager, Context.Game.GraphicsLoadContext, Context.Game.AssetStore, Context.SelectedAptWindow.AptFile.ImageMap, Context.SelectedAptWindow.AptFile.MovieName); } var currentSize = ImGui.GetContentRegionAvail(); if (geometryChanged || _cachedSize != currentSize) { var newSize = new Size((int)currentSize.X, (int)currentSize.Y); _shapeRenderer.Update( Context.Game.GraphicsDevice, newSize); _cachedSize = currentSize; } _renderedView.Draw(); }
public static void SetAlpha(this ShapeRenderer obj, float alpha) { Color c = obj.Color; c.a = alpha; obj.Color = c; return; }
void OnEnable() { shapeRenderer = (ShapeRenderer)target; fillMaterialEditor = CreateEditor(shapeRenderer.FillMaterial); strokeMaterialEditor = CreateEditor(shapeRenderer.StrokeMaterial); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Rg.Plugins.Popup.Popup.Init(); global::Xamarin.Forms.Forms.Init(); ShapeRenderer.Init(); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
internal override void Draw(GameTime gameTime) { ShapeRenderer.DrawRectangle(Focused ? _backgroundFocused : _backgroundUnfocused, ControlRectangle); for (int i = 0; i < ChildControls.Count; i++) { ChildControls[i].Draw(gameTime); } }
internal void internal_setguimanager(GUIManager guiManager) { _guiManager = guiManager; _contentLibrary = guiManager.ContentLibrary; _gameInstance = guiManager.Game; _graphicsDevice = _gameInstance.GraphicsDevice; _spriteBatch = new SpriteBatch(_graphicsDevice); _shapeRenderer = guiManager.ShapeRenderer; }
private void RenderShapeToSize(ShapeBase shape, float x, float y, float width, float height) { ShapeRenderer renderer = new ShapeRenderer(shape); using (Graphics formGraphics = CreateGraphics()) { renderer.RenderToSize(formGraphics, x, y, width, height); } }
public void DrawEllipse(object dc, ShapeRenderer renderer, PointShape s, double radius, double dx, double dy) { _ellipse.Style = _strokeStyle; _ellipse.TopLeft.X = s.X - radius; _ellipse.TopLeft.Y = s.Y - radius; _ellipse.BottomRight.X = s.X + radius; _ellipse.BottomRight.Y = s.Y + radius; _ellipse.Draw(dc, renderer, dx, dy, null, null); }
private void RenderShapeToScale(ShapeBase shape, float x, float y, float scale) { ShapeRenderer renderer = new ShapeRenderer(shape); using (Graphics formGraphics = CreateGraphics()) { renderer.RenderToScale(formGraphics, x, y, scale); } }
public void DrawLine(object dc, ShapeRenderer renderer, PointShape a, PointShape b, double dx, double dy) { _line.Style = _strokeStyle; _line.StartPoint.X = a.X; _line.StartPoint.Y = a.Y; _line.Point.X = b.X; _line.Point.Y = b.Y; _line.Draw(dc, renderer, dx, dy, null, null); }
private void DrawOverflowBox() { SpriteBatch.Begin(); ShapeRenderer.Rect(SpriteBatch, Color.Black, new Vector2(0, 0), new Vector2(Camera.ViewportOffset.X, Window.ClientBounds.Height)); ShapeRenderer.Rect(SpriteBatch, Color.Black, new Vector2(Window.ClientBounds.Width - Camera.ViewportOffset.X, 0), new Vector2(Camera.ViewportOffset.X, Window.ClientBounds.Height)); ShapeRenderer.Rect(SpriteBatch, Color.Black, new Vector2(0, 0), new Vector2(Window.ClientBounds.Width, Camera.ViewportOffset.Y)); ShapeRenderer.Rect(SpriteBatch, Color.Black, new Vector2(0, Window.ClientBounds.Height - Camera.ViewportOffset.Y), new Vector2(Window.ClientBounds.Width, Camera.ViewportOffset.Y)); SpriteBatch.End(); }
public void Draw(TextRenderer textRenderer, ShapeRenderer shapeRenderer) { if (this.renderedAlpha > 0) { var colour = this.Colour; colour.A = this.renderedAlpha; shapeRenderer.DrawRectangle(this.Size, this.Position, colour); } }
/// <inheritdoc/> public override void Draw(object dc, ShapeRenderer renderer, double dx, double dy, ImmutableArray <XProperty> db, XRecord r) { var record = this.Data.Record ?? r; if (State.Flags.HasFlag(ShapeStateFlags.Visible)) { renderer.Draw(dc, this, dx, dy, db, record); base.Draw(dc, renderer, dx, dy, db, record); } }
public override void Draw(ShapeRenderer renderer) { Vector2 position = ConvertUnits.ToDisplayUnits(physicsBody.Position); renderer.SetTransform( Matrix4.CreateRotationZ(PhysicsBody.Rotation) * Matrix4.CreateTranslation(position.X, position.Y, 0f)); renderer.DrawShape(shape.VertexData, ColorUtils.Blend(Color4.Red, Color4.Green, currentHealth / 100f)); renderer.ClearTransform(); }
// Dillon Gould public L1Shape(Block anchor, ShapeRenderer.Orientation orientation = ShapeRenderer.Orientation.ORIENT_0) : base(anchor, orientation) { this.color = ShapeRenderer.GetL1Color(); anchor.SetColor(this.color); // Draw a grid and determine what the shape looks like when it is at 0, 90, 180, and 270 degrees. // Then determine the other block offsets. The anchor is (x, y), the block immediately on the right is (x+1, y), the block immediately below is (x, y-1), etc. // Handle adding/creating the other blocks for each potential orientation this.blocks.Add(anchor); switch (orientation) { case ShapeRenderer.Orientation.ORIENT_0: // 0 - Anchor is on the top left this.blocks.Add(anchor.Copy(new Vector2(0, -1))); // Block the the left 2 this.blocks.Add(anchor.Copy(new Vector2(1, 0))); // Block to the right 3 this.blocks.Add(anchor.Copy(new Vector2(2, 0))); // Block below 4 break; case ShapeRenderer.Orientation.ORIENT_1: // 90 - anchor is on the top right this.blocks.Add(anchor.Copy(new Vector2(1, 0))); // Block above 2 this.blocks.Add(anchor.Copy(new Vector2(0, 1))); // Block below 3 this.blocks.Add(anchor.Copy(new Vector2(0, 2))); // Block to the left 4 break; case ShapeRenderer.Orientation.ORIENT_2: // 180 - anchor is on the bottom right this.blocks.Add(anchor.Copy(new Vector2(0, 1))); // Block to the right 2 this.blocks.Add(anchor.Copy(new Vector2(-1, 0))); // Block to the left 3 this.blocks.Add(anchor.Copy(new Vector2(-2, 0))); // Block above 4 break; case ShapeRenderer.Orientation.ORIENT_3: // 270 - anchor is on the bottom left this.blocks.Add(anchor.Copy(new Vector2(-1, 0))); // Block below 2 this.blocks.Add(anchor.Copy(new Vector2(0, -1))); // Block above 3 this.blocks.Add(anchor.Copy(new Vector2(0, -2))); // Block to the right 4 break; default: throw new ArgumentException("Unexpected ShapeRenderer::Orientation in L1Shape constructor: " + orientation); } anchor.SetColor(ShapeRenderer.GetL1AnchorColor()); //rotation offset dictionary this.nextOriToOffsets = new Dictionary <ShapeRenderer.Orientation, List <Vector2> >(); // Note: Set the first Vector2 to (0, 0) to not move the anchor // 270 -> 0 nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_0, new[] { new Vector2(0, 0), new Vector2(1, -1), new Vector2(1, 1), new Vector2(2, 2) }.ToList()); // 0 -> 90 nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_1, new[] { new Vector2(0, 0), new Vector2(1, 1), new Vector2(-1, 1), new Vector2(-2, 2) }.ToList()); // 90 -> 180 nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_2, new[] { new Vector2(0, 0), new Vector2(-1, 1), new Vector2(-1, -1), new Vector2(-2, -2) }.ToList()); // 180 -> 270 nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_3, new[] { new Vector2(0, 0), new Vector2(-1, -1), new Vector2(1, -1), new Vector2(2, -2) }.ToList()); }
public void Init(Shape shape, ShapeRenderer renderer) { target = shape; this.manager = renderer; if (killRoutine != null) { StopCoroutine(killRoutine); } initRoutine = StartCoroutine(InitRoutine()); shape.OnTriggered += OnTriggered; }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Xamarin.Forms.Forms.Init(); ShapeRenderer.Init(); MaterialButtonRenderer.Initialize(); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
public override void LoadContent() { SpriteBatch = new SpriteBatch(GraphicsDevice); ShapeRenderer.Initialize(GraphicsDevice); TextRenderer.Initialize(Content); Editor.Initialize(); //Editor.OnViewportChange(GraphicsDevice); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { d3dDragHandler = new DragHandler(d3dCanvas) { CursorOver = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeAll, 1) }; d2dDragHandler = new DragHandler(d2dCanvas) { CursorOver = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeAll, 1) }; d3dBrush = new ImageBrush(); d3dRectangle.Fill = d3dBrush; d2dBrush = new ImageBrush(); d2dRectangle.Fill = d2dBrush; // Safely dispose any previous instance // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC) deviceManager = new DeviceManager(); // New CubeRenderer cubeRenderer = new CubeRenderer(); shapeRenderer = new ShapeRenderer(); int pixelWidth = (int)(d3dRectangle.Width * DisplayProperties.LogicalDpi / 96.0); int pixelHeight = (int)(d3dRectangle.Height * DisplayProperties.LogicalDpi / 96.0); // Use CoreWindowTarget as the rendering target (Initialize SwapChain, RenderTargetView, DepthStencilView, BitmapTarget) d3dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight); d3dBrush.ImageSource = d3dTarget.ImageSource; d2dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight); d2dBrush.ImageSource = d2dTarget.ImageSource; // Add Initializer to device manager deviceManager.OnInitialize += d3dTarget.Initialize; deviceManager.OnInitialize += d2dTarget.Initialize; deviceManager.OnInitialize += cubeRenderer.Initialize; deviceManager.OnInitialize += shapeRenderer.Initialize; // Render the cube within the CoreWindow d3dTarget.OnRender += cubeRenderer.Render; d2dTarget.OnRender += shapeRenderer.Render; // Initialize the device manager and all registered deviceManager.OnInitialize deviceManager.Initialize(DisplayProperties.LogicalDpi); // Setup rendering callback CompositionTarget.Rendering += CompositionTarget_Rendering; // Callback on DpiChanged DisplayProperties.LogicalDpiChanged += DisplayProperties_LogicalDpiChanged; }
protected override void LoadContent() { base.LoadContent(); SpriteBatch = new SpriteBatch(GraphicsDevice); CalculateViewportScale(); ShapeRenderer.Initialize(GraphicsDevice); TextRenderer.Initialize(Content); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.IoniconsModule()); LoadApplication(new App()); ShapeRenderer.Init(); FormsPlugin.Iconize.iOS.IconControls.Init(); return(base.FinishedLaunching(app, options)); }
/// <inheritdoc/> public override void Render(object dc, ShapeRenderer renderer, XContainer container, double dx, double dy) { renderer.Fill(dc, dx, dy, container.Width, container.Height, container.Background); var db = container.Data == null ? default(ImmutableArray<XProperty>) : container.Data.Properties; var r = container.Data == null ? default(XRecord) : container.Data.Record; if (container.Template != null) { renderer.Draw(dc, container.Template, dx, dy, db, r); } renderer.Draw(dc, container, dx, dy, db, r); }
public static void RenderShapeToStream(string dataDir, Shape shape) { ShapeRenderer r = new ShapeRenderer(shape); // Define custom options which control how the image is rendered. Render the shape to the vector format EMF. ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.Jpeg) { // Output the image in gray scale ImageColorMode = ImageColorMode.Grayscale, // Reduce the brightness a bit (default is 0.5f). ImageBrightness = 0.45f }; dataDir = dataDir + "TestFile.RenderToStream_out_.jpg"; FileStream stream = new FileStream(dataDir, FileMode.Create); // Save the rendered image to the stream using different options. r.Save(stream, imageOptions); Console.WriteLine("\nShape rendered to stream successfully.\nFile saved at " + dataDir); }