internal static new void renderSprite( dfRenderData renderData, RenderOptions options ) { #if UNITY_EDITOR var atlas = options.atlas; if( atlas == null ) throw new NullReferenceException( "The Texture Atlas cannot be null" ); if( atlas.Texture == null ) throw new NullReferenceException( "The Texture Altas has no texture assigned or the texture was deleted" ); if( options.spriteInfo == null ) throw new ArgumentNullException( "The Sprite cannot be null" ); #endif options.baseIndex = renderData.Vertices.Count; rebuildTriangles( renderData, options ); rebuildVertices( renderData, options ); rebuildUV( renderData, options ); rebuildColors( renderData, options ); if( options.fillAmount < 1f ) { doFill( renderData, options ); } }
/// <summary> /// Draws bitmap. /// </summary> /// <param name="data"> /// Image pixel data. /// </param> /// <param name="width"> /// Output image width. /// </param> /// <param name="height"> /// Output image height. /// </param> /// <param name="options"> /// More rendering options. /// </param> /// <returns> /// Drawn bitmap. /// </returns> public static Bitmap DrawBitmap(byte[] data, int width, int height, RenderOptions options) { ImagePalette palette = options.Palette; Bitmap bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed); ColorPalette pal = bmp.Palette; palette.CopyTo(pal.Entries, 0); if(options.TransparentIndex >= 0)pal.Entries[options.TransparentIndex] = Color.Transparent; bmp.Palette = pal; BitmapData bmpdata = bmp.LockBits(new Rectangle(0,0,width,height), ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed); if(data.Length == 0){} else if(width%4 == 0) { Marshal.Copy(data, 0, bmpdata.Scan0, Math.Min(bmpdata.Stride*bmpdata.Height, data.Length)); }else{ for(int y = 0; y < height; y++) { if(y == height-1) { Marshal.Copy(data, width*y, bmpdata.Scan0+bmpdata.Stride*y, data.Length-width*y); }else{ Marshal.Copy(data, width*y, bmpdata.Scan0+bmpdata.Stride*y, width); } } } bmp.UnlockBits(bmpdata); return bmp; }
public BlendDemo(IntPtr hInstance) : base(hInstance) { _waterTexOffset = new Vector2(); _eyePosW = new Vector3(); _renderOptions = RenderOptions.TexturesAndFog; _theta = 1.3f * MathF.PI; _phi = 0.4f * MathF.PI; _radius = 80; MainWindowCaption = "Blend Demo"; Enable4XMsaa = false; _landWorld = Matrix.Identity; _wavesWorld = Matrix.Translation(0, -3.0f, 0); _view = Matrix.Identity; _proj = Matrix.Identity; _boxWorld = Matrix.Scaling(15.0f, 15.0f, 15.0f) * Matrix.Translation(8.0f, 5.0f, -15.0f); _grassTexTransform = Matrix.Scaling(5.0f, 5.0f, 0.0f); _dirLights = new[] { new DirectionalLight { Ambient = new Color4(0.2f, 0.2f, 0.2f), Diffuse = new Color4(0.5f, 0.5f, 0.5f), Specular = new Color4(0.5f, 0.5f, 0.5f), Direction = new Vector3(0.57735f, -0.57735f, 0.57735f) }, new DirectionalLight { Ambient = Color.Black, Diffuse = new Color4(0.2f, 0.2f, 0.2f), Specular = new Color4(0.25f, 0.25f, 0.25f), Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f) }, new DirectionalLight { Ambient = Color.Black, Diffuse = new Color4(0.2f, 0.2f, 0.2f), Specular = Color.Black, Direction = new Vector3(0.0f, -0.707f, -0.707f) } }; _landMat = new Material { Ambient = new Color4(0.5f, 0.5f, 0.5f), Diffuse = Color.White, Specular = new Color4(16.0f, 0.2f, 0.2f, 0.2f) }; _wavesMat = new Material { Ambient = new Color4(0.5f, 0.5f, 0.5f), Diffuse = new Color4(0.6f, 1.0f, 1.0f, 1.0f), Specular = new Color4(32.0f, 0.8f, 0.8f, 0.8f) }; _boxMat = new Material { Ambient = new Color4(0.5f, 0.5f, 0.5f), Diffuse = Color.White, Specular = new Color4(16.0f, 0.4f, 0.4f, 0.4f) }; }
public RenderControls(RenderOptions parent) { InitializeComponent(); _Parent = parent; RenderSliders(); PopulateCombos(); }
public Renderer(int passes, ViewportPolicy viewportPolicy, RenderOptions renderOptions) { this.Passes = passes; this.Policy = viewportPolicy; this.Options = renderOptions; this.sortMode = Renderer.ToSortMode(renderOptions); this.blendState = Renderer.ToBlendState(renderOptions); // Doing a GlobalRenderLock because Renderer objects might be constructed in different threads. lock (PhantomGame.Game.GlobalRenderLock) { if ((renderOptions & RenderOptions.Canvas) == RenderOptions.Canvas) this.canvas = new Canvas(PhantomGame.Game.GraphicsDevice); this.batch = new SpriteBatch(PhantomGame.Game.GraphicsDevice); } if (this.sortMode == SpriteSortMode.Immediate) this.activeRenderPass = this.RenderPassFullLock; else this.activeRenderPass = this.RenderPassEndLock; }
public override void RenderFrame(GPUContext context, ref StagingTexture frame, RenderOptions options, GPUTexture output) { // Copy texture back to the staging texture context.CopyTexture(frame.Texture, 0, 0, 0, 0, output, 0); }
public Robot() { InitializeComponent(); RenderOptions.SetBitmapScalingMode(Image, BitmapScalingMode.Fant); }
// Draw the pattern using the texture brush. void DrawPatternWithTexBrush(GraphicsTarget g, SymPathWithHoles path, float angle, SymColor color, RenderOptions renderOpts) { Brush brush = (Brush) patternBrushes[color]; Debug.Assert(brush != null); if (angle != 0.0F) { object graphicsState = g.Save(); try { // Set the clipping region to draw only inside the area. g.SetClip(path); // use a transform to rotate. Matrix matrix = GraphicsUtil.RotationMatrix(angle, new PointF(0, 0)); g.Transform(matrix); // Get the correct bounding rect. RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -angle); g.FillRectangle(brush, bounding); } finally { // restore the clip region and the transform g.Restore(graphicsState); } } else { path.Fill(g, brush); } }
/// <summary>Prints the FrameworkElement.</summary> /// <param name="fe">The FrameworkElement.</param> public static void Print(this FrameworkElement fe) { PrintDialog pd = new PrintDialog(); bool?result = pd.ShowDialog(); pd.PrintTicket.PageOrientation = PageOrientation.Portrait; if (!result.HasValue || !result.Value) { return; } System.Printing.PrintCapabilities capabilities = pd.PrintQueue.GetPrintCapabilities(pd.PrintTicket); try { fe.Dispatcher.Invoke(new Action(() => { //fe.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); //fe.Arrange(new Rect(fe.DesiredSize)); //fe.UpdateLayout(); // Change the layout of the UI Control to match the width of the printer page fe.Width = capabilities.PageImageableArea.ExtentWidth; fe.UpdateLayout(); fe.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Size size = new Size(capabilities.PageImageableArea.ExtentWidth, fe.DesiredSize.Height); fe.Measure(size); size = new Size(capabilities.PageImageableArea.ExtentWidth, fe.DesiredSize.Height); fe.Measure(size); fe.Arrange(new Rect(size)); }), System.Windows.Threading.DispatcherPriority.Render); int height = (int)pd.PrintTicket.PageMediaSize.Height; int width = (int)pd.PrintTicket.PageMediaSize.Width; int pages = (int)Math.Ceiling((fe.ActualHeight / height)); FixedDocument document = new FixedDocument(); for (int i = 0; i < pages; i++) { FixedPage page = new FixedPage(); page.Height = height; page.Width = width; page.PrintTicket = pd.PrintTicket; PageContent content = new PageContent(); content.Child = page; document.DocumentPaginator.PageSize = new Size(pd.PrintableAreaWidth + 50, pd.PrintableAreaHeight); document.Pages.Add(content); VisualBrush vb = new VisualBrush(fe); vb.AlignmentX = AlignmentX.Left; vb.AlignmentY = AlignmentY.Top; vb.Stretch = Stretch.None; vb.TileMode = TileMode.None; vb.Viewbox = new Rect(-11, i * height, width + 10, (i + 1) * height); vb.ViewboxUnits = BrushMappingMode.Absolute; RenderOptions.SetBitmapScalingMode(vb, BitmapScalingMode.Fant); Canvas canvas = new Canvas(); canvas.Background = vb; canvas.Height = height; canvas.Width = width; //FixedPage.SetLeft(canvas, 0); FixedPage.SetTop(canvas, 25); page.Children.Add(canvas); } pd.PrintDocument(document.DocumentPaginator, ((String.IsNullOrWhiteSpace(fe.Name) ? "Temp" : fe.Name) + " PRINT")); } finally { //// Scale UI control back to the original so we don't effect what is on the screen //fe.Width = double.NaN; //fe.UpdateLayout(); //fe.LayoutTransform = new ScaleTransform(1, 1); //Size size = new Size(capabilities.PageImageableArea.ExtentWidth, // capabilities.PageImageableArea.ExtentHeight); //fe.Measure(size); //fe.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, // capabilities.PageImageableArea.OriginHeight), size)); Mouse.OverrideCursor = null; } }
// Draw this point symbol at point pt with angle ang in this graphics (given color only). internal void Draw(GraphicsTarget g, PointF pt, float angle, float[] gaps, SymColor color, RenderOptions renderOpts) { glyph.Draw(g, pt, angle, GraphicsUtil.IdentityMatrix, gaps, color, renderOpts); }
// Draw the hatching into the interior of the SymPath. void DrawHatching(GraphicsTarget g, SymPathWithHoles path, float angle, RenderOptions renderOpts) { object graphicsState = g.Save(); try { // Set the clipping region to draw only inside the area. g.SetClip(path); // use a transform to rotate and then draw hatching. Matrix matrix = GraphicsUtil.RotationMatrix(hatchAngle1 + angle, new PointF(0, 0)); g.Transform(matrix); // Get the correct bounding rect. RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -(hatchAngle1 + angle)); DrawHatchLines(g, hatchPen, hatchSpacing, bounding, renderOpts); // and again for the second bound of hatching if (hatchMode == 2) { // Get the correct bounding rect. bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -(hatchAngle2 + angle)); matrix = GraphicsUtil.RotationMatrix(hatchAngle2 - hatchAngle1, new PointF(0, 0)); g.Transform(matrix); DrawHatchLines(g, hatchPen, hatchSpacing, bounding, renderOpts); } } finally { // restore the clip region and the transform g.Restore(graphicsState); } }
private static void OnCachingHintChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Viewport2DVisual3D viewport2D = (Viewport2DVisual3D)d; RenderOptions.SetCachingHint(viewport2D._visualBrush, (CachingHint)e.NewValue); }
// Draw the elements of the map that lie within the rectange rect // into the Graphics g, which already has its world coordinates set up // correctly and the clipping region. public void Draw(Graphics g, RectangleF rect, RenderOptions renderOpts) { CheckReadable(); TraceLine("Begin drawing rectangle ({0},{1})-({2},{3})", rect.Left, rect.Top, rect.Right, rect.Bottom); Trace.Indent(); GraphicsState graphicsState = g.Save(); GraphicsTarget grTarget = new GraphicsTarget(g); try { // Get clipping region and bounding rectangle. If the clipping region isn't a rectangle, // then it is worth doing extra work to eliminate symbols. // UNDONE: clipRegionIsRectangle is given false on full repaint. Need to fix this. Region clipRegion; rect.Intersect(g.ClipBounds); clipRegion = g.Clip.Clone(); clipRegion.Xor(rect); bool clipRegionIsRectangle = clipRegion.IsEmpty(g); clipRegion.Dispose(); g.TextRenderingHint = TextRenderingHint.AntiAlias; if (renderOpts.showSymbolBounds) boundsPen = new Pen(Color.FromArgb(100, Color.Red), 0); // Draw the image layer. DrawColor(grTarget, null, rect, clipRegionIsRectangle, renderOpts); // Draw each color separately, to get correct layering. foreach (SymColor curColor in colors) { DrawColor(grTarget, curColor, rect, clipRegionIsRectangle, renderOpts); } if (renderOpts.showSymbolBounds) boundsPen.Dispose(); Trace.Unindent(); } finally { g.Restore(graphicsState); } }
/// <summary> /// The 'Fill' command was executed. /// </summary> private void Fill_Executed(object sender, ExecutedRoutedEventArgs e) { zoomAndPanControl.AnimatedScaleToFit(); RenderOptions.SetBitmapScalingMode(content, scalingMode); }
/// <summary> /// The 'OneHundredPercent' command was executed. /// </summary> private void OneHundredPercent_Executed(object sender, ExecutedRoutedEventArgs e) { zoomAndPanControl.AnimatedZoomTo(1.0); RenderOptions.SetBitmapScalingMode(content, scalingMode); }
//TODO: Abstract this public LightsScene(string title, Sdl2Window contextWindow, GraphicsDeviceOptions graphicsDeviceOptions, RenderOptions renderOptions) : base(title, contextWindow, graphicsDeviceOptions, renderOptions) { }
// Model<VertexPositionColor> _floor; public LightsScene(string title, Resolution windowSize, GraphicsDeviceOptions graphicsDeviceOptions, RenderOptions renderOptions) : base(title, windowSize, graphicsDeviceOptions, renderOptions) { }
public Robot(string Text) { InitializeComponent(); Te.Text = Text; RenderOptions.SetBitmapScalingMode(Image, BitmapScalingMode.Fant); }
private void RestoreEdgeMode() { RenderOptions.SetEdgeMode(this, _edgeMode); }
private static void OnCacheInvalidationThresholdMaximumChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Viewport2DVisual3D viewport2D = (Viewport2DVisual3D)d; RenderOptions.SetCacheInvalidationThresholdMaximum(viewport2D._visualBrush, (double)e.NewValue); }
// Draw a particular color layer. If curColor is null, draw the image layer. private void DrawColor(GraphicsTarget g, SymColor curColor, RectangleF rect, bool clipRegionIsRectangle, RenderOptions renderOpts) { foreach (SymDef symdef in symdefs) { if (IsSymdefVisible(symdef) && symdef.HasColor(curColor)) { foreach (Symbol curSym in symdef.symbols) { // Only draw the symbol if it may intersect. Check // the bounding box first as it's faster exclusion than MayIntersectRect. RectangleF bounds = curSym.BoundingBox; if (bounds.IntersectsWith(rect) && #if true (clipRegionIsRectangle || g.Graphics.IsVisible(Util.InflateRect(bounds, renderOpts.minResolution))) && #endif curSym.MayIntersectRect(rect)) { curSym.Draw(g, curColor, renderOpts); if (renderOpts.showSymbolBounds) g.DrawRectangle(boundsPen, bounds); } } } } //TraceLine("Drawing color {0}: drew {1} of {2} symbols.", curColor, cDrawn, cSymbols); }
}//ToSerializableCanvas public static void ExtractHiddenData(DataStore data, Canvas canvas, int pos) { if ((int)data.BitmapScalingMode != 1) { RenderOptions.SetBitmapScalingMode(canvas, data.BitmapScalingMode); } if (data.pages[pos].IsImageBrush) { canvas.Background = new ImageBrush(data.archive.GetImage(data.pages[pos].ImageBrush.Path)); ((ImageBrush)canvas.Background).Stretch = data.pages[pos].ImageBrush.stretch; } else if (data.pages[pos].CustomBrush && !String.IsNullOrWhiteSpace(data.pages[pos].canvasbrush)) { canvas.Background = (Brush)SaveEditor.XMLDeserialize(data.pages[pos].canvasbrush); } else { if (data.IsImageBrush) { canvas.Background = new ImageBrush(data.archive.GetImage(data.ImageBrush.Path)); ((ImageBrush)canvas.Background).Stretch = data.ImageBrush.stretch; } else if (!String.IsNullOrEmpty(data.AllBackground)) { canvas.Background = (Brush)SaveEditor.XMLDeserialize(data.AllBackground); } else { canvas.Background = new SolidColorBrush(Colors.White); } } foreach (FrameworkElement frw in canvas.Children) { if (frw is Image) { Image img = (Image)frw; if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString())) { img.Source = new BitmapImage(new Uri("pack://application:,,,/Good Teacher;Component/Resources/Controls/image.png")); } else { DesignSave designSave = DesignSave.Deserialize(img.Tag.ToString()); designSave.ToImage(data, img); } } else if (frw is Shape) { Shape shape = (Shape)frw; if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString())) { } else { DesignSave designSave = DesignSave.Deserialize(shape.Tag.ToString()); designSave.ToShape(data, shape); } } else if (frw is Label || frw is CheckBox || frw is RadioButton) { Control control = (Control)frw; if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString())) { } else { DesignSave designSave = DesignSave.Deserialize(control.Tag.ToString()); designSave.ToControlWithForeground(data, control); } if (control.FontFamily.BaseUri != null && control.FontFamily.Source != null) { Debug.WriteLine("Ffontfamilysource: " + control.FontFamily.Source); string fontfamilyloc = ""; string fontfamilyfile = ""; if (control.FontFamily.Source.Length >= 5) { fontfamilyloc = control.FontFamily.Source.Substring(0, 3); fontfamilyfile = control.FontFamily.Source.Substring(0, 5); } if (!string.IsNullOrWhiteSpace(control.FontFamily.Source) && (fontfamilyloc == "./#" || fontfamilyfile == "file:")) { //Debug.WriteLine("-------------------\nBU: " + control.FontFamily.BaseUri + "\nFF: " + control.FontFamily + "\nAP: " + control.FontFamily.BaseUri.AbsolutePath + "\nAU: " + control.FontFamily.BaseUri.AbsoluteUri + "\nH: " + control.FontFamily.BaseUri.Host + "\nS: " + control.FontFamily.Source + "\n********\n"); FontFamily fontFamily; if (FontWorker.GetFontFamily(control.FontFamily, out fontFamily)) { control.FontFamily = fontFamily; } } } } else if (frw is MediaPlayer_Control) { //Nothing } else if (frw is Control) { Control control = (Control)frw; if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString())) { } else { DesignSave designSave = DesignSave.Deserialize(control.Tag.ToString()); designSave.ToControl(data, control); } if (control.FontFamily.BaseUri != null) { //Debug.WriteLine(""+ control.FontFamily.BaseUri+ " "+ control.FontFamily+" AP: "+control.FontFamily.BaseUri.AbsolutePath+" AU: "+control.FontFamily.BaseUri.AbsoluteUri+" H: "+control.FontFamily.BaseUri.Host+ " S: "+control.FontFamily.Source); FontFamily fontFamily; if (FontWorker.GetFontFamily(control.FontFamily, out fontFamily)) { control.FontFamily = fontFamily; } } } } DeserializeCustomControls(data, canvas, pos); }
private static void DrawDashedWithOffset(GraphicsTarget g, SymPath path, Pen pen, DashInfo dashes, float offsetRight, float miterLimit, RenderOptions renderOpts) { float[] distances; distances = ComputeDashDistances(path, LocationKind.DashAndGapLengths, dashes.dashLength, dashes.firstDashLength, dashes.lastDashLength, dashes.gapLength, dashes.minGaps, 0, dashes.secondaryEndGaps, dashes.secondaryEndLength, dashes.secondaryMiddleGaps, dashes.secondaryMiddleLength, 1.0F, false); if (distances.Length == 0 || (dashes.gapLength < renderOpts.minResolution && (dashes.secondaryMiddleGaps == 0 || dashes.secondaryMiddleLength < renderOpts.minResolution) && (dashes.secondaryEndGaps == 0 || dashes.secondaryEndLength < renderOpts.minResolution))) { // No dashes, or the dashes are too small to be visible. Draw solid. if (offsetRight != 0) { SymPath offsetPath = path.OffsetRight(offsetRight, miterLimit); offsetPath.Draw(g, pen); } else path.Draw(g, pen); } else { path.DrawDashedOffsetBizzarro(g, pen, distances, 0, offsetRight, miterLimit); } }
public MainWindow() { InitializeComponent(); RenderOptions.SetBitmapScalingMode(canvas, BitmapScalingMode.NearestNeighbor); GenerateWorld(); }
// Draw this text symbol along a path. internal void DrawTextOnPath(GraphicsTarget g, SymPath path, string text, SymColor color, RenderOptions renderOpts) { if (color == null) return; if (color != fontColor && (framing.framingStyle == FramingStyle.None || color != framing.framingColor)) return; if (!objectsCreated) CreateObjects(); // Get the location of each grapheme to print. List<GraphemePlacement> graphemeList = GetLineTextGraphemePlacement(path, text); PointF topAscentPoint = new PointF(0, -FontAscent); // Drawing is relative to top of char, we want to draw at baseline. foreach (GraphemePlacement grapheme in graphemeList) { object graphicsState; graphicsState = g.Save(); try { // Move location to draw at to the origin, set angle for drawing text. Matrix matrix = GraphicsUtil.TranslationMatrix(grapheme.pointStart.X, grapheme.pointStart.Y); matrix = GraphicsUtil.Multiply(GraphicsUtil.ScalingMatrix(1, -1), matrix); // Reverse Y so text is correct way aroun matrix = GraphicsUtil.Multiply(GraphicsUtil.RotationMatrix(-grapheme.angle, new PointF(0,0)), matrix); g.Transform(matrix); DrawStringWithEffects(g, color, grapheme.grapheme, topAscentPoint); } finally { g.Restore(graphicsState); // restore transform } } }
void IGraphicsBackend.BeginRendering(IDrawDevice device, RenderOptions options, RenderStats stats) { DebugCheckOpenGLErrors(); this.CheckRenderingCapabilities(); this.currentDevice = device; this.renderOptions = options; this.renderStats = stats; // Prepare a shared index buffer object, in case we don't have one yet if (this.sharedBatchIBO == null) { this.sharedBatchIBO = new NativeGraphicsBuffer(GraphicsBufferType.Index); } // Prepare the target surface for rendering NativeRenderTarget.Bind(options.Target as NativeRenderTarget); // Determine whether masked blending should use alpha-to-coverage mode if (this.msaaIsDriverDisabled) { this.useAlphaToCoverageBlend = false; } else if (NativeRenderTarget.BoundRT != null) { this.useAlphaToCoverageBlend = NativeRenderTarget.BoundRT.Samples > 0; } else if (this.activeWindow != null) { this.useAlphaToCoverageBlend = this.activeWindow.IsMultisampled; } else { this.useAlphaToCoverageBlend = this.defaultGraphicsMode.Samples > 0; } // Determine the available size on the active rendering surface Point2 availableSize; if (NativeRenderTarget.BoundRT != null) { availableSize = new Point2(NativeRenderTarget.BoundRT.Width, NativeRenderTarget.BoundRT.Height); } else if (this.activeWindow != null) { availableSize = new Point2(this.activeWindow.Width, this.activeWindow.Height); } else { availableSize = this.externalBackbufferSize; } // Translate viewport coordinates to OpenGL screen coordinates (borrom-left, rising), unless rendering // to a texture, which is laid out Duality-like (top-left, descending) Rect openGLViewport = options.Viewport; if (NativeRenderTarget.BoundRT == null) { openGLViewport.Y = (availableSize.Y - openGLViewport.H) - openGLViewport.Y; } // Setup viewport and scissor rects GL.Viewport((int)openGLViewport.X, (int)openGLViewport.Y, (int)MathF.Ceiling(openGLViewport.W), (int)MathF.Ceiling(openGLViewport.H)); GL.Scissor((int)openGLViewport.X, (int)openGLViewport.Y, (int)MathF.Ceiling(openGLViewport.W), (int)MathF.Ceiling(openGLViewport.H)); // Clear buffers ClearBufferMask glClearMask = 0; ColorRgba clearColor = options.ClearColor; if ((options.ClearFlags & ClearFlag.Color) != ClearFlag.None) { glClearMask |= ClearBufferMask.ColorBufferBit; } if ((options.ClearFlags & ClearFlag.Depth) != ClearFlag.None) { glClearMask |= ClearBufferMask.DepthBufferBit; } GL.ClearColor(clearColor.R / 255.0f, clearColor.G / 255.0f, clearColor.B / 255.0f, clearColor.A / 255.0f); GL.ClearDepth((double)options.ClearDepth); // The "float version" is from OpenGL 4.1.. GL.Clear(glClearMask); // Configure Rendering params GL.Enable(EnableCap.ScissorTest); GL.Enable(EnableCap.DepthTest); if (options.DepthTest) { GL.DepthFunc(DepthFunction.Lequal); } else { GL.DepthFunc(DepthFunction.Always); } // Prepare shared matrix stack for rendering Matrix4 viewMatrix = options.ViewMatrix; Matrix4 projectionMatrix = options.ProjectionMatrix; if (NativeRenderTarget.BoundRT != null) { Matrix4 flipOutput = Matrix4.CreateScale(1.0f, -1.0f, 1.0f); projectionMatrix = projectionMatrix * flipOutput; } this.renderOptions.ShaderParameters.Set( BuiltinShaderFields.ViewMatrix, viewMatrix); this.renderOptions.ShaderParameters.Set( BuiltinShaderFields.ProjectionMatrix, projectionMatrix); this.renderOptions.ShaderParameters.Set( BuiltinShaderFields.ViewProjectionMatrix, viewMatrix * projectionMatrix); }
// Draw the pattern (at the given angle) inside the path. void DrawPattern(GraphicsTarget g, SymPathWithHoles path, float angle, SymColor color, RenderOptions renderOpts) { object graphicsState = g.Save(); try { // Set the clipping region to draw only inside the area. g.SetClip(path); // use a transform to rotate Matrix matrix = GraphicsUtil.RotationMatrix(patternAngle + angle, new PointF(0, 0)); g.Transform(matrix); // Get the correct bounding rect. RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -(patternAngle + angle)); DrawPatternRows(g, bounding, color, renderOpts); } finally { // restore the clip region and the transform g.Restore(graphicsState); } }
private Grid CreateModItem(ModInfo modInfo, string path, bool enabled, bool validMod) { // <Grid Height="55" Width="240" Background="White"> Grid grid = new Grid() { Background = Brushes.Transparent, HorizontalAlignment = HorizontalAlignment.Stretch, Height = 45 }; CheckBox checkBox = new CheckBox() { Width = 20, Height = 20, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(3, 4, 0, 0), IsChecked = enabled }; checkBox.Checked += ModItemChecked; checkBox.Unchecked += ModItemUnchecked; // <Image HorizontalAlignment="Left" Height="55" VerticalAlignment="Top" Width="55"/> ImageSource img = null; try { img = BitmapFromUri(new Uri($"{path}\\{modInfo.Icon}")); } catch (Exception exception) { img = BitmapFromUri(new Uri("pack://application:,,,/SMLLoader;component/Images/oee.png")); } Image image = new Image() { Source = img, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Stretch, Width = 55, Margin = new Thickness(20, 0, 0, 0) }; RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.HighQuality); // <Label Content="Label" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="60,8,0,0" VerticalAlignment="Top" Height="35" Width="170" FontSize="20"/> TextBlock label = new TextBlock() { Name = "Title", FontSize = 16, Foreground = Brushes.White, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(70, 0, 0, 0), Width = 170, Height = 50 }; label.Inlines.Add(new Bold(new Run(modInfo.Name))); TextBlock versionLabel = new TextBlock { Text = modInfo.Version, Name = "Version", FontSize = 12, Foreground = Brushes.White, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, TextAlignment = TextAlignment.Right, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 25, 0, 0), Width = 170, Height = 50 }; TextBlock loaderVersionLabel = new TextBlock { Text = modInfo.LauncherVersion, Name = "Version", FontSize = 12, Foreground = validMod ? Brushes.White : Brushes.Red, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, TextAlignment = TextAlignment.Right, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 0, 0, 0), Width = 170, Height = 50 }; TextBlock authorLabel = new TextBlock { Text = modInfo.Authors, Name = "Author", FontSize = 12, Foreground = Brushes.White, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(70, 25, 0, 0), Width = 300, Height = 50 }; grid.Children.Add(checkBox); grid.Children.Add(image); grid.Children.Add(label); grid.Children.Add(versionLabel); grid.Children.Add(loaderVersionLabel); grid.Children.Add(authorLabel); _mods.Add(checkBox, label); return(grid); }
void CreatePatternBrush(float pixelSize) { // Determine adjusted pixel size of the brush to create. const float MAX_PATTERN_SIZE = 80; const float MIN_PATTERN_SIZE = 10; if (pixelSize < patternWidth / MAX_PATTERN_SIZE) pixelSize = patternWidth / MAX_PATTERN_SIZE; if (pixelSize < patternHeight / MAX_PATTERN_SIZE) pixelSize = patternHeight / MAX_PATTERN_SIZE; if (pixelSize > patternWidth / MIN_PATTERN_SIZE) pixelSize = patternWidth / MIN_PATTERN_SIZE; if (pixelSize > patternHeight / MIN_PATTERN_SIZE) pixelSize = patternHeight / MIN_PATTERN_SIZE; if (patternBrushes != null && Math.Abs(pixelSize - pixelSizeCached) / pixelSize < 0.01) return; // the pattern brush is already OK size. // Get size of bitmap to create with the image of the pattern. float width = (float) Math.Round(patternWidth / pixelSize); float height = (float) Math.Round(patternHeight / pixelSize); // Create dictionary to hold brushes for each color. patternBrushes = new Dictionary<SymColor, Brush>(2); pixelSizeCached = pixelSize; RenderOptions renderOpts = new RenderOptions(); renderOpts.minResolution = pixelSize; renderOpts.usePatternBitmaps = false; foreach (SymColor color in map.colors) { if (!patternGlyph.HasColor(color)) continue; // Create a new bitmap and fill it transparent. Bitmap bitmap = new Bitmap((int) width, (int) (offsetRows ? height * 2 : height)); Graphics g = Graphics.FromImage(bitmap); g.CompositingMode = CompositingMode.SourceCopy; g.SmoothingMode = SmoothingMode.HighQuality; g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, bitmap.Width, bitmap.Height); // Set the center of the bitmap to 0,0, and scale to mm (each pixel is 0.01 mm). g.TranslateTransform(width / 2.0F, height / 2.0F); g.ScaleTransform(width / patternWidth, height / patternHeight); // Draw the pattern into the bitmap. GraphicsTarget grTarget = new GraphicsTarget(g); patternGlyph.Draw(grTarget, new PointF(0F, 0F), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts); if (offsetRows) { patternGlyph.Draw(grTarget, new PointF(patternWidth / 2, patternHeight), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts); patternGlyph.Draw(grTarget, new PointF(-patternWidth / 2, patternHeight), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts); } // Create a TextureBrush on the bitmap. TextureBrush brush = new TextureBrush(bitmap); // Scale and the texture brush. brush.RotateTransform(patternAngle); brush.ScaleTransform(patternWidth / width, patternHeight / height); brush.TranslateTransform(-width / 2.0F, -height / 2.0F); // Dispose of the graphics. g.Dispose(); // Add it to the collection of brushes. patternBrushes.Add(color, brush); } }
private static void rebuildTriangles( dfRenderData renderData, RenderOptions options ) { var baseIndex = options.baseIndex; var triangles = renderData.Triangles; for( int i = 0; i < triangleIndices.Length; i++ ) { triangles.Add( baseIndex + triangleIndices[ i ] ); } }
public abstract void CollectFrame(GPUContext context, ref StagingTexture frame, RenderOptions options);
private static void rebuildVertices( dfRenderData renderData, RenderOptions options ) { float meshLeft = 0; float meshTop = 0; float meshRight = Mathf.Ceil( options.size.x ); float meshBottom = Mathf.Ceil( -options.size.y ); #region Borders var spriteInfo = options.spriteInfo; float borderLeft = spriteInfo.border.left; float borderTop = spriteInfo.border.top; float borderRight = spriteInfo.border.right; float borderBottom = spriteInfo.border.bottom; if( options.flip.IsSet( dfSpriteFlip.FlipHorizontal ) ) { float temp = borderRight; borderRight = borderLeft; borderLeft = temp; } if( options.flip.IsSet( dfSpriteFlip.FlipVertical ) ) { float temp = borderBottom; borderBottom = borderTop; borderTop = temp; } #endregion // Top left corner verts[ 0 ] = new Vector3( meshLeft, meshTop, 0 ) + options.offset; verts[ 1 ] = verts[ 0 ] + new Vector3( borderLeft, 0, 0 ); verts[ 2 ] = verts[ 0 ] + new Vector3( borderLeft, -borderTop, 0 ); verts[ 3 ] = verts[ 0 ] + new Vector3( 0, -borderTop, 0 ); // Top right corner verts[ 4 ] = new Vector3( meshRight - borderRight, meshTop, 0 ) + options.offset; verts[ 5 ] = verts[ 4 ] + new Vector3( borderRight, 0, 0 ); verts[ 6 ] = verts[ 4 ] + new Vector3( borderRight, -borderTop, 0 ); verts[ 7 ] = verts[ 4 ] + new Vector3( 0, -borderTop, 0 ); // Bottom left corner verts[ 8 ] = new Vector3( meshLeft, meshBottom + borderBottom, 0 ) + options.offset; verts[ 9 ] = verts[ 8 ] + new Vector3( borderLeft, 0, 0 ); verts[ 10 ] = verts[ 8 ] + new Vector3( borderLeft, -borderBottom, 0 ); verts[ 11 ] = verts[ 8 ] + new Vector3( 0, -borderBottom, 0 ); // Bottom right corner verts[ 12 ] = new Vector3( meshRight - borderRight, meshBottom + borderBottom, 0 ) + options.offset; verts[ 13 ] = verts[ 12 ] + new Vector3( borderRight, 0, 0 ); verts[ 14 ] = verts[ 12 ] + new Vector3( borderRight, -borderBottom, 0 ); verts[ 15 ] = verts[ 12 ] + new Vector3( 0, -borderBottom, 0 ); for( int i = 0; i < verts.Length; i++ ) { renderData.Vertices.Add( ( verts[ i ] * options.pixelsToUnits ).Quantize( options.pixelsToUnits ) ); } }
public OxySKElement() { this.designMode = DesignerProperties.GetIsInDesignMode(this); RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.NearestNeighbor); }
public GetCropBounds(RenderOptions options, ILogger <GetCropBounds> logger) { _options = options; _logger = logger; }
private static void rebuildUV( dfRenderData renderData, RenderOptions options ) { var atlas = options.atlas; var textureSize = new Vector2( atlas.Texture.width, atlas.Texture.height ); var spriteInfo = options.spriteInfo; float offsetTop = spriteInfo.border.top / textureSize.y; float offsetBottom = spriteInfo.border.bottom / textureSize.y; float offsetLeft = spriteInfo.border.left / textureSize.x; float offsetRight = spriteInfo.border.right / textureSize.x; var rect = spriteInfo.region; // Top left corner uv[ 0 ] = new Vector2( rect.x, rect.yMax ); uv[ 1 ] = new Vector2( rect.x + offsetLeft, rect.yMax ); uv[ 2 ] = new Vector2( rect.x + offsetLeft, rect.yMax - offsetTop ); uv[ 3 ] = new Vector2( rect.x, rect.yMax - offsetTop ); // Top right corner uv[ 4 ] = new Vector2( rect.xMax - offsetRight, rect.yMax ); uv[ 5 ] = new Vector2( rect.xMax, rect.yMax ); uv[ 6 ] = new Vector2( rect.xMax, rect.yMax - offsetTop ); uv[ 7 ] = new Vector2( rect.xMax - offsetRight, rect.yMax - offsetTop ); // Bottom left corner uv[ 8 ] = new Vector2( rect.x, rect.y + offsetBottom ); uv[ 9 ] = new Vector2( rect.x + offsetLeft, rect.y + offsetBottom ); uv[ 10 ] = new Vector2( rect.x + offsetLeft, rect.y ); uv[ 11 ] = new Vector2( rect.x, rect.y ); // Bottom right corner uv[ 12 ] = new Vector2( rect.xMax - offsetRight, rect.y + offsetBottom ); uv[ 13 ] = new Vector2( rect.xMax, rect.y + offsetBottom ); uv[ 14 ] = new Vector2( rect.xMax, rect.y ); uv[ 15 ] = new Vector2( rect.xMax - offsetRight, rect.y ); #region Flip UV if requested if( options.flip != dfSpriteFlip.None ) { for( int i = 0; i < uv.Length; i += 4 ) { Vector2 temp = Vector2.zero; if( options.flip.IsSet( dfSpriteFlip.FlipHorizontal ) ) { temp = uv[ i + 0 ]; uv[ i + 0 ] = uv[ i + 1 ]; uv[ i + 1 ] = temp; temp = uv[ i + 2 ]; uv[ i + 2 ] = uv[ i + 3 ]; uv[ i + 3 ] = temp; } if( options.flip.IsSet( dfSpriteFlip.FlipVertical ) ) { temp = uv[ i + 0 ]; uv[ i + 0 ] = uv[ i + 3 ]; uv[ i + 3 ] = temp; temp = uv[ i + 1 ]; uv[ i + 1 ] = uv[ i + 2 ]; uv[ i + 2 ] = temp; } } if( options.flip.IsSet( dfSpriteFlip.FlipHorizontal ) ) { var th = new Vector2[ uv.Length ]; Array.Copy( uv, th, uv.Length ); // Swap top-left and top-right corners Array.Copy( uv, 0, uv, 4, 4 ); Array.Copy( th, 4, uv, 0, 4 ); // Swap bottom-left and bottom-right corners Array.Copy( uv, 8, uv, 12, 4 ); Array.Copy( th, 12, uv, 8, 4 ); } if( options.flip.IsSet( dfSpriteFlip.FlipVertical ) ) { var tv = new Vector2[ uv.Length ]; Array.Copy( uv, tv, uv.Length ); // Swap top-left and bottom-left corners Array.Copy( uv, 0, uv, 8, 4 ); Array.Copy( tv, 8, uv, 0, 4 ); // Swap top-right and bottom-right corners Array.Copy( uv, 4, uv, 12, 4 ); Array.Copy( tv, 12, uv, 4, 4 ); } } #endregion for( int i = 0; i < uv.Length; i++ ) { renderData.UV.Add( uv[ i ] ); } }
protected override void OnRebuildRenderData() { if( Atlas == null ) return; var spriteInfo = SpriteInfo; if( spriteInfo == null ) { return; } renderData.Material = Atlas.Material; if( spriteInfo.border.horizontal == 0 || spriteInfo.border.vertical == 0 ) { base.OnRebuildRenderData(); return; } var color = ApplyOpacity( IsEnabled ? this.color : this.disabledColor ); var options = new RenderOptions() { atlas = atlas, color = color, fillAmount = fillAmount, fillDirection = fillDirection, flip = flip, invertFill = invertFill, offset = pivot.TransformToUpperLeft( Size ), pixelsToUnits = PixelsToUnits(), size = Size, spriteInfo = SpriteInfo }; renderSprite( renderData, options ); }
public byte[] ResizeImage(byte[] image_data, int new_width, int new_height, int quality) { BitmapImage original_image = new BitmapImage(); original_image.BeginInit(); original_image.StreamSource = new MemoryStream(image_data); original_image.EndInit(); // Calculate crop section int orig_width = original_image.PixelWidth; int orig_height = original_image.PixelHeight; float width_ratio = (float)new_width / orig_width; float height_ratio = (float)new_height / orig_height; float ratio = Math.Max(width_ratio, height_ratio); int resized_pre_crop_width = (int)Math.Round(orig_width * ratio); int resized_pre_crop_height = (int)Math.Round(orig_height * ratio); // full area to crop on resized image int resized_crop_x = resized_pre_crop_width - new_width; int resized_crop_y = resized_pre_crop_height - new_height; int cropped_width = (int)((resized_pre_crop_width - resized_crop_x) / ratio); int cropped_height = (int)((resized_pre_crop_height - resized_crop_y) / ratio); // half of area to crop on original image int crop_x = (int)(resized_crop_x / ratio / 2); int crop_y = (int)(resized_crop_y / ratio / 2); // End of calculate crop section var cropped_image = new CroppedBitmap(original_image, new Int32Rect(crop_x, crop_y, cropped_width, cropped_height)); var rect = new System.Windows.Rect(0, 0, new_width, new_height); var group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(group, BitmapScalingMode.HighQuality); group.Children.Add(new ImageDrawing(cropped_image, rect)); var drawing_visual = new DrawingVisual(); using (var drawing_context = drawing_visual.RenderOpen()) drawing_context.DrawDrawing(group); var resized_image = new RenderTargetBitmap( new_width, new_height, // Resized dimensions 96, 96, // Default DPI values PixelFormats.Default); // Default pixel format resized_image.Render(drawing_visual); JpegBitmapEncoder jbe = new JpegBitmapEncoder(); jbe.Frames.Add(BitmapFrame.Create(resized_image)); jbe.QualityLevel = quality; using (MemoryStream stream = new MemoryStream()) { jbe.Save(stream); image_data = stream.ToArray(); } return(image_data); }
/// <summary> /// Draws the animated image to bitmap. /// </summary> /// <param name="index"> /// Zero-based frame index. /// </param> /// <param name="options"> /// More rendering options. /// </param> /// <returns> /// Drawn image. /// </returns> public Image Render(byte index, RenderOptions options) { return Drawing.DrawBitmap(Frames[index].ImageData, Frames[index].Width, Frames[index].Height, options); }
// Render a description to a map, then to a bitmap for testing purposes. Hardcoded 6 mm box size. internal static Bitmap RenderToMapThenToBitmap(SymbolDB symbolDB, DescriptionLine[] description, DescriptionKind kind, int numColumns) { DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB); descriptionRenderer.Description = description; descriptionRenderer.DescriptionKind = kind; descriptionRenderer.CellSize = 6.0F; descriptionRenderer.Margin = 0.7F; descriptionRenderer.NumberOfColumns = numColumns; PointF location = new PointF(30, -100); SizeF size = descriptionRenderer.Measure(); Bitmap bm = new Bitmap((int) size.Width * 8, (int) size.Height * 8); Graphics g = Graphics.FromImage(bm); g.ScaleTransform(bm.Width / size.Width, -bm.Height / size.Height); g.TranslateTransform(-location.X, -location.Y); g.Clear(Color.White); Map map = new Map(new GDIPlus_TextMetrics(), null); using (map.Write()) { Dictionary<object, SymDef> dict = new Dictionary<object, SymDef>(); // Create white color and white-out symdef. SymColor white = map.AddColorBottom("White", 44, 0, 0, 0, 0, false); AreaSymDef whiteArea = new AreaSymDef("White out", "890", white, null); whiteArea.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.WhiteOut_OcadToolbox); map.AddSymdef(whiteArea); dict[CourseLayout.KeyWhiteOut] = whiteArea; SymColor color = map.AddColor("Purple", 11, 0.045F, 0.59F, 0, 0.255F, false); descriptionRenderer.RenderToMap(map, color, location, dict); } InputOutput.WriteFile(TestUtil.GetTestFile("descriptions\\desc_temp.ocd"), map, new MapFileFormat(MapFileFormatKind.OCAD, 8)); using (map.Read()) { RenderOptions renderOpts = new RenderOptions(); renderOpts.usePatternBitmaps = true; renderOpts.minResolution = 0.1F; renderOpts.renderTemplates = RenderTemplateOption.MapAndTemplates; map.Draw(new GDIPlus_GraphicsTarget(g), new RectangleF(location.X, location.Y - size.Height, size.Width, size.Height), renderOpts, null); } g.Dispose(); return bm; }
protected override void OnRender(DrawingContext dc) { if (PointsToDisplay != null) { Log.Debug("PointsToDisplay is not empty - rendering points"); var canvasWidth = (int)ActualWidth; var canvasHeight = (int)ActualHeight; if (canvasWidth > 0 && canvasHeight > 0) { //Create the bitModeScreenCoordinateToKeyMap var wb = new WriteableBitmap(canvasWidth, canvasHeight, 96, 96, PixelFormats.Bgra32, null); //Create a new image var img = new Image { Source = wb, Stretch = Stretch.None, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; //Set scaling mode, edge mode and z index on canvas RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.NearestNeighbor); RenderOptions.SetEdgeMode(img, EdgeMode.Aliased); SetZIndex(img, -100); //Each "dot" is 3x3 rectangle (centered on the coordinate detected) var rect = new Int32Rect(0, 0, 3, 3); int size = rect.Width * rect.Height * 4; var pixels = new byte[size]; int screenCoordinatesIndex = 0; int screenCoordinatesIndexUpperBound = PointsToDisplay.Count - 1; foreach (Point capturedCoordinate in PointsToDisplay) { Point canvasPoint = PointFromScreen(capturedCoordinate); //Convert screen to canvas point if (canvasPoint.X >= 0 && canvasPoint.X < canvasWidth && canvasPoint.Y >= 0 && canvasPoint.Y < canvasHeight) { SetPixelValuesToRainbow(pixels, rect, screenCoordinatesIndex, screenCoordinatesIndexUpperBound); //Set up pixel colours (as RGB and Alpha array of bytes) //We are drawing a 3x3 dot so try to start one pixel up and left (center pixel of rectangle will be the co-ordinate) //If coord in against the top or left side (x=0 and/or y=0) this cannot be done, so just place as close as possible //If coord in against the bottom or right side (x>=canvasWidth-1 and/or y>=canvasHeight-1) this cannot be done either, so just place as close as possible rect.X = (int)canvasPoint.X == 0 ? (int)canvasPoint.X : (int)canvasPoint.X > 0 && (int)canvasPoint.X < canvasWidth - 1 ? (int)canvasPoint.X - 1 : (int)canvasPoint.X - 2; rect.Y = (int)canvasPoint.Y == 0 ? (int)canvasPoint.Y : (int)canvasPoint.Y > 0 && (int)canvasPoint.Y < canvasHeight - 1 ? (int)canvasPoint.Y - 1 : (int)canvasPoint.Y - 2; wb.WritePixels(rect, pixels, rect.Width * 4, 0); screenCoordinatesIndex++; } } dc.DrawImage(wb, new Rect(0, 0, canvasWidth, canvasHeight)); } } else { Log.Debug("OnRender - PointsToDisplay is empty - nothing to render"); } base.OnRender(dc); }
/// <summary> /// Draws the image to bitmap. /// </summary> /// <param name="options"> /// More rendering options. /// </param> /// <returns> /// Drawn image. /// </returns> public override Image Render(RenderOptions options) { return Render(0, options); }
void IGraphicsBackend.BeginRendering(IDrawDevice device, RenderOptions options, RenderStats stats) { this.currentDevice = device; this.renderStats = stats; // Prepare the target surface for rendering NativeRenderTarget.Bind(options.Target as NativeRenderTarget); if (this.primaryVBO == 0) { GL.GenBuffers(1, out this.primaryVBO); } GL.BindBuffer(BufferTarget.ArrayBuffer, this.primaryVBO); // Setup viewport Rect viewportRect = options.Viewport; GL.Viewport((int)viewportRect.X, (int)viewportRect.Y, (int)viewportRect.W, (int)viewportRect.H); GL.Scissor((int)viewportRect.X, (int)viewportRect.Y, (int)viewportRect.W, (int)viewportRect.H); // Clear buffers ClearBufferMask glClearMask = 0; ColorRgba clearColor = options.ClearColor; if ((options.ClearFlags & ClearFlag.Color) != ClearFlag.None) { glClearMask |= ClearBufferMask.ColorBufferBit; } if ((options.ClearFlags & ClearFlag.Depth) != ClearFlag.None) { glClearMask |= ClearBufferMask.DepthBufferBit; } GL.ClearColor(clearColor.R / 255.0f, clearColor.G / 255.0f, clearColor.B / 255.0f, clearColor.A / 255.0f); GL.ClearDepth((double)options.ClearDepth); // The "float version" is from OpenGL 4.1.. GL.Clear(glClearMask); // Configure Rendering params if (options.RenderMode == RenderMatrix.OrthoScreen) { GL.Enable(EnableCap.ScissorTest); GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Always); } else { GL.Enable(EnableCap.ScissorTest); GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); } OpenTK.Matrix4 openTkModelView; Matrix4 modelView = options.ModelViewMatrix; GetOpenTKMatrix(ref modelView, out openTkModelView); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref openTkModelView); OpenTK.Matrix4 openTkProjection; Matrix4 projection = options.ProjectionMatrix; GetOpenTKMatrix(ref projection, out openTkProjection); GL.MatrixMode(MatrixMode.Projection); GL.LoadMatrix(ref openTkProjection); if (NativeRenderTarget.BoundRT != null) { if (options.RenderMode == RenderMatrix.OrthoScreen) { GL.Translate(0.0f, NativeRenderTarget.BoundRT.Height * 0.5f, 0.0f); } GL.Scale(1.0f, -1.0f, 1.0f); if (options.RenderMode == RenderMatrix.OrthoScreen) { GL.Translate(0.0f, -NativeRenderTarget.BoundRT.Height * 0.5f, 0.0f); } } }
public void Draw(DrawingContext dc, RectangleF rect, RenderOptions renderOpts) { CheckReadable(); TraceLine("Begin drawing rectangle ({0},{1})-({2},{3})", rect.Left, rect.Top, rect.Right, rect.Bottom); Trace.Indent(); GraphicsTarget grTarget = new GraphicsTarget(dc); if (renderOpts.showSymbolBounds) boundsPen = GraphicsUtil.CreateSolidPen(Color.FromArgb(100, 255, 0, 0), 0.01F, LineStyle.Mitered); // Draw the image layer. DrawColor(grTarget, null, rect, true, renderOpts); // Draw each color separately, to get correct layering. foreach (SymColor curColor in colors) { DrawColor(grTarget, curColor, rect, true, renderOpts); } if (renderOpts.showSymbolBounds) GraphicsUtil.DisposePen(boundsPen); Trace.Unindent(); }
public OptionExecutor(RenderOptions renderOptions) { _renderOptions = renderOptions; }
private static void DrawDashed(GraphicsTarget g, SymPath path, Pen pen, DashInfo dashes, RenderOptions renderOpts) { DrawDashedWithOffset(g, path, pen, dashes, 0, 1, renderOpts); }
/// <summary> /// Handles the ContextMenuOpening event of the ListViewItem control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Controls.ContextMenuEventArgs"/> instance containing the event data.</param> private void ListViewItemContextMenuOpening(object sender, ContextMenuEventArgs e) { e.Handled = true; if (listView.SelectedIndex == -1) { return; } var cm = new ContextMenu(); ((FrameworkElement)e.Source).ContextMenu = cm; var link = (LinkItem)listView.SelectedValue; if (!string.IsNullOrWhiteSpace(link.InfoURL)) { var oib = new MenuItem(); oib.Header = "Open details in browser"; oib.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/page.png")) }; oib.Click += (s, r) => Utils.Run(link.InfoURL); cm.Items.Add(oib); } if (!string.IsNullOrWhiteSpace(link.FileURL) && !link.FileURL.StartsWith("magnet:") && !(link.Source.Downloader is BinSearchDownloader)) { var oib = new MenuItem(); oib.Header = "Download file in browser"; oib.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/page-dl.png")) }; oib.Click += (s, r) => ProcessLink(link, x => { foreach (var url in x.FileURL.Split('\0')) { Utils.Run(url); } }); cm.Items.Add(oib); } if (!string.IsNullOrWhiteSpace(link.FileURL) && !(link.Source.Downloader is ExternalDownloader) && !link.FileURL.StartsWith("magnet:")) { var df = new MenuItem(); df.Header = "Download file"; df.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/torrents.png")) }; df.Click += DownloadFileClick; cm.Items.Add(df); } if (_assocTorrent != null && !string.IsNullOrWhiteSpace(link.FileURL) && link.Source.Type == Types.Torrent && !(link.Source.Downloader is ExternalDownloader)) { var sap = new MenuItem(); sap.Header = "Send to " + CleanExeName(_assocTorrent.Item1); sap.Icon = new Image { Source = _assocTorrent.Item2, Height = 16, Width = 16 }; sap.Click += (s, r) => DownloadFileClick("UseAssociated", r); // was SendToTorrent cm.Items.Add(sap); } if (_assocUsenet != null && !string.IsNullOrWhiteSpace(link.FileURL) && link.Source.Type == Types.Usenet && !(link.Source.Downloader is ExternalDownloader)) { var sap = new MenuItem(); sap.Header = "Send to " + CleanExeName(_assocUsenet.Item1); sap.Icon = new Image { Source = _assocUsenet.Item2, Height = 16, Width = 16 }; sap.Click += (s, r) => DownloadFileClick("UseAssociated", r); // was SendToUsenet cm.Items.Add(sap); } if (_assocLinks != null && !string.IsNullOrWhiteSpace(link.FileURL) && link.Source.Type == Types.DirectHTTP) { var jd = new MenuItem(); jd.Header = "Send to " + CleanExeName(_assocLinks.Item1); jd.Icon = new Image { Source = _assocLinks.Item2, Height = 16, Width = 16 }; jd.Click += (s, r) => ProcessLink(link, SendToLinkContainerDownloader); cm.Items.Add(jd); } if (!string.IsNullOrWhiteSpace(link.FileURL) && _typeAssocMap.ContainsKey(link.Source.Type) && _altAssoc[_typeAssocMap[link.Source.Type]].Count != 0) { foreach (var alt in _altAssoc[_typeAssocMap[link.Source.Type]]) { var app = alt; var snd = new MenuItem(); snd.Header = "Send to " + CleanExeName(app.Item1); snd.Icon = new Image { Source = app.Item3, Height = 16, Width = 16 }; if (link.Source.Type == Types.DirectHTTP) { snd.Click += (s, r) => ProcessLink(link, x => new LinkDownloadTaskDialog().Download(RewriteHTTPLinksToDLC(x), "SendTo|" + app.Item2)); } else { snd.Click += (s, r) => DownloadFileClick("SendTo|" + app.Item2, r); } cm.Items.Add(snd); } } foreach (var se in Senders) { if (se.Value.Type == link.Source.Type) { var id = se.Key; var cmi = new MenuItem(); cmi.Tag = se; cmi.Header = "Send to " + se.Value.Title; cmi.Icon = new Image { Source = new BitmapImage(new Uri(se.Value.Icon)), Height = 16, Width = 16 }; if (Signature.IsActivated) { cmi.Click += (s, r) => DownloadFileClick("SendToSender|" + id, r); } else { ((Image)cmi.Icon).SetValue(ImageGreyer.IsGreyableProperty, true); cmi.IsEnabled = false; } cm.Items.Add(cmi); } } if (!string.IsNullOrWhiteSpace(link.FileURL) && _typeAssocMap.ContainsKey(link.Source.Type) && _destDirs[_typeAssocMap[link.Source.Type]].Count != 0) { foreach (var alt in _destDirs[_typeAssocMap[link.Source.Type]]) { var app = alt; var snd = new MenuItem(); snd.Header = "Save to " + Path.GetFileName(app); snd.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/folder-open-document.png")), Height = 16, Width = 16 }; if (link.Source.Type == Types.DirectHTTP) { snd.Click += (s, r) => ProcessLink(link, x => new LinkDownloadTaskDialog().Download(RewriteHTTPLinksToDLC(x), "SendToFolder|" + app)); } else { snd.Click += (s, r) => DownloadFileClick("SendToFolder|" + app, r); } cm.Items.Add(snd); } } foreach (var dlcm in Extensibility.GetNewInstances <DownloadLinkContextMenu>()) { foreach (var dlcmi in dlcm.GetMenuItems(link)) { var cmi = new MenuItem(); cmi.Tag = dlcmi; cmi.Header = dlcmi.Name; cmi.Icon = dlcmi.Icon; cmi.Click += (s, r) => ((ContextMenuItem <Link>)cmi.Tag).Click(link); cm.Items.Add(cmi); } } TextOptions.SetTextFormattingMode(cm, TextFormattingMode.Display); TextOptions.SetTextRenderingMode(cm, TextRenderingMode.ClearType); RenderOptions.SetBitmapScalingMode(cm, BitmapScalingMode.HighQuality); cm.IsOpen = true; }
// Draw the glyphs along the path. "longPath" is the same as path unless shortening of the ends has occurred, in which case // path is the shortened path (used for all glyphs except start and end), and longPath is used for the start and end. private void DrawGlyphs(GraphicsTarget g, GlyphInfo glyphInfo, SymPath path, SymPath longPath, SymColor color, RenderOptions renderOpts) { float[] distances; PointF[] points; float[] perpAngles, subtendedAngles; float firstDistance; // Figure out the distances of the glyphs along the line. switch (glyphInfo.location) { case GlyphLocation.Corners: // Corner points are done somewhat differently. Only can have 1 symbol. // There is an interesting feature in OCAD where the dimensions of corner glyphs are stretched a certain amount at // very acute angles. This is so that power line crossbars always extend beyond the power lines themselves. // This is handled by stretching the glyph based on the subtended angle at the corner. points = path.FindCornerPoints(out perpAngles, out subtendedAngles); if (points != null) { for (int i = 0; i < points.Length; ++i) { float subtendedAngle = subtendedAngles[i]; float stretch; if (subtendedAngle != 0) stretch = Util.MiterFactor(subtendedAngle); else stretch = 1.0F; stretch = Math.Min(stretch, CORNER_GLYPH_STRETCH_LIMIT); Matrix stretchMatrix = new Matrix(); stretchMatrix.Scale(1.0F, stretch); glyphInfo.glyph.Draw(g, points[i], perpAngles[i] + 90.0F, stretchMatrix, null, color, renderOpts); } } return; case GlyphLocation.Spaced: distances = ComputeDashDistances(path, LocationKind.GapCenters, glyphInfo.distance, glyphInfo.firstDistance, glyphInfo.lastDistance, 0, glyphInfo.minimum, 0, 0, 0, 0, 0, 1.0F, false); break; case GlyphLocation.SpacedOffset: distances = ComputeDashDistances(path, LocationKind.GapCentersOffset, glyphInfo.distance, glyphInfo.firstDistance, glyphInfo.lastDistance, 0, glyphInfo.minimum, glyphInfo.offset, 0, 0, 0, 0, 1.0F, false); break; case GlyphLocation.SpacedDecrease: distances = ComputeDashDistances(path, LocationKind.GapCentersDecrease, glyphInfo.distance, glyphInfo.firstDistance, glyphInfo.lastDistance, 0, glyphInfo.minimum, 0, 0, 0, 0, 0, glyphInfo.decreaseLimit, glyphInfo.decreaseBothEnds); if (distances != null && distances.Length > 0) { firstDistance = distances[0]; for (int n = 0; n < glyphInfo.number; ++n) { distances[0] = Math.Max(0.0F, firstDistance - ((glyphInfo.number - 1 - n * 2) * (glyphInfo.spacing / 2.0F))); points = path.FindPointsAlongLineBizzarro(distances, out perpAngles); for (int i = 0; i < points.Length; ++i) { float decreaseFactor; if (glyphInfo.decreaseBothEnds) { if (points.Length <= 2) decreaseFactor = glyphInfo.decreaseLimit; else decreaseFactor = 1.0F - (Math.Abs(i - ((points.Length-1) / 2F)) * (1 - glyphInfo.decreaseLimit) / ((points.Length-1) / 2F)); } else { if (i == 0) decreaseFactor = 1.0F; else decreaseFactor = 1.0F - (i * (1 - glyphInfo.decreaseLimit) / (points.Length - 1)); } Matrix matrixTransform = new Matrix(); matrixTransform.Scale(decreaseFactor, decreaseFactor); glyphInfo.glyph.Draw(g, points[i], perpAngles[i], matrixTransform, null, color, renderOpts); } } } return; case GlyphLocation.DashCenters: distances = ComputeDashDistances(path, LocationKind.DashCenters, dashInfo.dashLength, dashInfo.firstDashLength, dashInfo.lastDashLength, dashInfo.gapLength, dashInfo.minGaps, 0, 0, 0, 0, 0, 1.0F, false); break; case GlyphLocation.MiddleDashCenters: distances = ComputeDashDistances(path, LocationKind.MiddleDashCenters, dashInfo.dashLength, dashInfo.firstDashLength, dashInfo.lastDashLength, dashInfo.gapLength, dashInfo.minGaps, 0, 0, 0, 0, 0, 1.0F, false); break; case GlyphLocation.GapCenters: // OCAD doesn't respect the "0 minimum gaps" for the symbols, although it does for the gaps. Always have at least one symbol. This is handled on import by having glyphInfo.minimum be 1. distances = ComputeDashDistances(path, LocationKind.GapCenters, dashInfo.dashLength, dashInfo.firstDashLength, dashInfo.lastDashLength, dashInfo.gapLength, Math.Max(glyphInfo.minimum, dashInfo.minGaps), 0, 0, 0, 0, 0, 1.0F, false); break; case GlyphLocation.Start: distances = new float[1] { 0 }; break; case GlyphLocation.End: distances = new float[1] { longPath.BizzarroLength }; break; default: Debug.Fail("bad glyph location"); return; } if (distances == null || distances.Length == 0) return; firstDistance = distances[0]; for (int n = 0; n < glyphInfo.number; ++n) { distances[0] = Math.Max(0.0F, firstDistance - ((glyphInfo.number - 1 - n * 2) * (glyphInfo.spacing / 2.0F))); if (glyphInfo.location == GlyphLocation.Start || glyphInfo.location == GlyphLocation.End) points = longPath.FindPointsAlongLineBizzarro(distances, out perpAngles); else points = path.FindPointsAlongLineBizzarro(distances, out perpAngles); for (int i = 0; i < points.Length; ++i) { glyphInfo.glyph.Draw(g, points[i], perpAngles[i], GraphicsUtil.IdentityMatrix, null, color, renderOpts); } } }
/// <summary> /// Builds and renders the heatmap. /// </summary> private void BuildHeatmap() { // Prepare datapoints for a bit more efficient calculation _logger("Preparing dataset ..."); HashSet <HeatDatapoint>[,] datapointMap = new HashSet <HeatDatapoint> [_heatmap.GetLength(0), _heatmap.GetLength(1)]; foreach (var datapoint in _dataPoints) { int xIndex = (int)(datapoint.X / _tier.GetInfoLength() * _heatmap.GetLength(0)); int yIndex = (int)(datapoint.Y / _tier.GetInfoWidth() * _heatmap.GetLength(1)); if (datapointMap[xIndex, yIndex] == null) { datapointMap[xIndex, yIndex] = new HashSet <HeatDatapoint>(); } datapointMap[xIndex, yIndex].Add(datapoint); } // Actually calculate all the heat information _logger("Calculating heatmap ..."); DateTime lastLog = DateTime.MinValue; TimeSpan minLogInterval = TimeSpan.FromSeconds(3); int counter = 0; int overallCount = _heatmap.GetLength(0) * _heatmap.GetLength(1); Parallel.For(0, _heatmap.GetLength(0), (int x) => // Calculate heat values in parallel across the rows { for (int y = 0; y < _heatmap.GetLength(1); y++) { _heatmap[x, y] = GetHeatValue(datapointMap, x, y); counter++; if (DateTime.Now - lastLog > minLogInterval) { _logger(counter + " / " + overallCount); lastLog = DateTime.Now; } } }); _logger(overallCount + " / " + overallCount); // Handle logarithmic transformation, if desired if (_config.Logarithmic) { // If logarithmic values are desired, shift all values to numbers greater or equal to 1 first double minValue = _heatmap.Cast <double>().Min(v => v); double offsetForLog = minValue < 1 ? 1 - minValue : 0; if (_config.Logarithmic && offsetForLog > 0) { for (int x = 0; x < _heatmap.GetLength(0); x++) { for (int y = 0; y < _heatmap.GetLength(1); y++) { _heatmap[x, y] += offsetForLog; } } } // Transform to logarithmic values if desired for (int x = 0; x < _heatmap.GetLength(0); x++) { for (int y = 0; y < _heatmap.GetLength(1); y++) { _heatmap[x, y] = _heatmap[x, y] <= 0 ? 0 : Math.Log10(_heatmap[x, y]); } } } // Normalize the heat to [0,1] _logger("Normalizing heatmap ..."); double maxHeat = double.MinValue; for (int x = 0; x < _heatmap.GetLength(0); x++) { for (int y = 0; y < _heatmap.GetLength(1); y++) { maxHeat = Math.Max(maxHeat, _heatmap[x, y]); } } for (int x = 0; x < _heatmap.GetLength(0); x++) { for (int y = 0; y < _heatmap.GetLength(1); y++) { _heatmap[x, y] /= maxHeat; } } // Render the heat overlay _logger("Rendering heatmap ..."); _contentControl.Dispatcher.Invoke(() => { // Init image Image image = new Image(); RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.NearestNeighbor); image.Opacity = 0.7; int bitmapWidth = (int)_transformer.ProjectXLength(_heatmap.GetLength(0)); int bitmapHeight = (int)_transformer.ProjectYLength(_heatmap.GetLength(1)); WriteableBitmap writeableBitmap = BitmapFactory.New(bitmapWidth + 1, bitmapHeight + 1); // TODO hotfixing the missing 1-pixel column and row by increasing the size of the bitmap by 1 in each direction // Draw all tiles for (int x = 0; x < _heatmap.GetLength(0); x++) { for (int y = 0; y < _heatmap.GetLength(1); y++) { int x1 = (int)_transformer.ProjectX(x); int y1 = (int)_transformer.ProjectY(y + 1.0); int x2 = (int)_transformer.ProjectX(x + 1.0); int y2 = (int)_transformer.ProjectY(y); Color color = _config.BichromaticColoring ? HeatVisualizer.GenerateBiChromaticHeatColor(_config.BichromaticColorOne, _config.BichromaticColorTwo, _heatmap[x, y]) : HeatVisualizer.GenerateHeatColor(_heatmap[x, y]); writeableBitmap.FillRectangle(x1, y1, x2, y2, color); } } image.Source = writeableBitmap; ResultImage = image; // Add the image to the canvas (in background, if desired) if (_config.DrawInBackground) { _contentControl.Children.Insert(0, image); } else { _contentControl.Children.Add(image); } }); // Finished _logger("Heatmap done!"); }
// Draw this text symbol at point pt with angle ang in this graphics (given color only). internal void Draw(GraphicsTarget g, string[] text, float[] lineWidths, PointF location, float angle, float fullWidth, SymColor color, RenderOptions renderOpts) { if (color == null) return; if (color != fontColor && (framing.framingStyle == FramingStyle.None || color != framing.framingColor) && (!underline.underlineOn || color != underline.underlineColor)) return; if (!objectsCreated) CreateObjects(); // Move location to draw at to the origin. object graphicsState = g.Save(); Matrix matrix = GraphicsUtil.TranslationMatrix(location.X, location.Y); matrix = GraphicsUtil.Multiply(GraphicsUtil.ScalingMatrix(1, -1), matrix); // Reverse Y direction so text is correct way around. if (angle != 0) matrix = GraphicsUtil.Multiply(GraphicsUtil.RotationMatrix(-angle, new PointF(0,0)), matrix); g.Transform(matrix); try { // Draw all the lines of text. PointF pt = new PointF(0F, 0F); float baselineOfLine = 0; // y coordinate of baseline of line. bool firstLineOfPara = true, lastLineOfPara; for (int lineIndex = 0; lineIndex < text.Length; ++lineIndex) { string line = text[lineIndex]; float lineWidth = lineWidths[lineIndex]; lastLineOfPara = (lineIndex == text.Length - 1 || text[lineIndex + 1] == ParagraphMark); // are we on the last line of a paragraph? if (line == ParagraphMark) { pt.Y += paraSpacing; firstLineOfPara = true; } else { float indent = 0; float leftEdge; // tabs are relative to this X position. if (fontAlign == TextSymDefAlignment.Right) pt.X = leftEdge = -lineWidth; else if (fontAlign == TextSymDefAlignment.Center) pt.X = leftEdge = -(lineWidth / 2F); else { leftEdge = 0; pt.X = indent = firstLineOfPara ? firstIndent : restIndent; // indents only used for left align or justified } // Get the size of spaces. Justification is done by adjusting this. float sizeOfSpace = wordSpacing * spaceWidth; // basic width of spaces as set by the symdef if (fontAlign == TextSymDefAlignment.Justified && !lastLineOfPara && fullWidth > 0) sizeOfSpace += JustifyText(line, lineWidth, fullWidth - indent); // Draw all the text segments in the line. (A text segment is a word, unless charSpacing>0, in which case it is graphemes). int index = 0; for (; ; ) { string textSegment; if (charSpacing > 0) textSegment = StringInfo.GetNextTextElement(line.Substring(index)); else textSegment = GetNextTextSegment(line.Substring(index)); if (string.IsNullOrEmpty(textSegment)) break; if (textSegment == " ") pt.X += sizeOfSpace; else if (textSegment == "\t") pt.X += WidthOfTextSegment("\t", pt.X - leftEdge); else { DrawStringWithEffects(g, color, textSegment, pt); pt.X += MeasureStringWidth(textSegment); if (charSpacing > 0) pt.X += charSpacing * spaceWidth; } index += textSegment.Length; } baselineOfLine = pt.Y + FontAscent; // Set the bottom of the text. if (lastLineOfPara) DrawUnderline(g, color, baselineOfLine, Math.Max(fullWidth, lineWidth), (fullWidth == 0) ? indent : 0); pt.Y += lineSpacing; firstLineOfPara = false; } } // Draw the framing rectangle, if any. if (underline.underlineOn) baselineOfLine += underline.underlineDistance + underline.underlineWidth; DrawFramingRectangle(g, lineWidths, fullWidth, color, baselineOfLine); } finally { g.Restore(graphicsState); } }
private void SetBitmap() { int width = (int)textbox.ActualWidth; int height = (int)textbox.ActualHeight; if (width <= 0 || height <= 0) { return; } WriteableBitmap buffer; var bgColor = Color.FromRgb(0xF9, 0xF9, 0xF9); textImage1.Width = width; textImage1.Height = height; buffer = BitmapFactory.New(width, height); buffer.Clear(bgColor); //buffer.DrawString(0, 0, Colors.Black, new Typeface("Arial"), 12, "ABC 123 Gfijdr"); buffer.DrawString(0, 0, Colors.Black, new PortableFontDesc(isbold: true), "Transparency"); buffer.DrawLine(0, 10, 50, 10, Colors.Black); buffer.DrawLine(50, 0, 50, 40, Colors.Black); textImage1.Source = buffer; textImage2.Width = width; textImage2.Height = height; buffer = BitmapFactory.New(width, height); buffer.Clear(bgColor); buffer.DrawString(0, 0, Colors.Black, bgColor, new PortableFontDesc(cleartype: true), "ABC 123 Gfijdr"); textImage2.Source = buffer; textImage3.Width = width; textImage3.Height = height; var text = new FormattedText("ABC l 123 Gfijdr", CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Arial"), 12, new SolidColorBrush(Colors.Black)); var drawingVisual = new DrawingVisual(); RenderOptions.SetBitmapScalingMode(drawingVisual, BitmapScalingMode.NearestNeighbor); RenderOptions.SetClearTypeHint(drawingVisual, ClearTypeHint.Enabled); RenderOptions.SetEdgeMode(drawingVisual, EdgeMode.Aliased); TextOptions.SetTextRenderingMode(drawingVisual, TextRenderingMode.ClearType); TextOptions.SetTextFormattingMode(drawingVisual, TextFormattingMode.Display); TextOptions.SetTextHintingMode(drawingVisual, TextHintingMode.Fixed); using (var drawingContext = drawingVisual.RenderOpen()) { //var brush = new VisualBrush(new TextBlock {Text = "ABC 123 Gfijdr"}); //drawingContext.DrawRectangle(brush, null, new Rect(0, 0, width, height)); //Double halfPenWidth = 0.5; //var face = new Typeface("Arial"); //GlyphTypeface gt; //face.TryGetGlyphTypeface(out gt); //var indexes = new ushort[] {gt.CharacterToGlyphMap['A']}; //var widths = new double[] {gt.AdvanceWidths['A']*12}; //var glyphRun = new GlyphRun(gt, 0, false, 12, indexes, new Point(0, 14), widths, null, null, null, null, null, null); //var rect = glyphRun.ComputeAlignmentBox(); //Double halfPenWidth = 0.5; ////var rect = new Rect(0, 0, width, height); //GuidelineSet guidelines = new GuidelineSet(); //guidelines.GuidelinesX.Add(rect.Left + halfPenWidth); //guidelines.GuidelinesX.Add(rect.Right + halfPenWidth); //guidelines.GuidelinesY.Add(rect.Top + halfPenWidth); //guidelines.GuidelinesY.Add(rect.Bottom + halfPenWidth); drawingContext.DrawRectangle(new SolidColorBrush(bgColor), null, new Rect(0, 0, width, height)); drawingContext.DrawText(text, new Point(0, 0)); drawingContext.DrawLine(new Pen(Brushes.Black, 1), new Point(0.5, 10.5), new Point(50.5, 10.5)); drawingContext.DrawLine(new Pen(Brushes.Black, 1), new Point(35.5, 0.5), new Point(35.5, 40.5)); //drawingContext.PushGuidelineSet(guidelines); //drawingContext.DrawGlyphRun(Brushes.Black, glyphRun); //drawingContext.Pop(); } //drawingVisual.Transform = new ScaleTransform(0.9, 0.9); //drawingVisual.Transform = new ScaleTransform(1, 1); //drawingVisual.Transform = new TranslateTransform(0, -0.25); var tb = new TextBlock { Text = "ABC l 123 Gfijdr" }; tb.Measure(new Size(width, height)); tb.Arrange(new Rect(new Point(0, 0), new Size(width, height))); var bmp = new RenderTargetBitmap(width, height, DpiDetector.DpiXKoef * 96, DpiDetector.DpiYKoef * 96, PixelFormats.Pbgra32); RenderOptions.SetBitmapScalingMode(bmp, BitmapScalingMode.NearestNeighbor); RenderOptions.SetClearTypeHint(bmp, ClearTypeHint.Enabled); RenderOptions.SetEdgeMode(bmp, EdgeMode.Aliased); TextOptions.SetTextRenderingMode(bmp, TextRenderingMode.ClearType); TextOptions.SetTextFormattingMode(bmp, TextFormattingMode.Display); TextOptions.SetTextHintingMode(bmp, TextHintingMode.Fixed); //RenderOptions.SetCachingHint(bmp, CachingHint.Cache); //RenderOptions.SetBitmapScalingMode(bmp, BitmapScalingMode.LowQuality); bmp.Render(drawingVisual); //bmp.Render(tb); //bmp.Freeze(); BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); var ms = new MemoryStream(); encoder.Save(ms); BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = ms; bi.EndInit(); encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); using (var fs = System.IO.File.OpenWrite("file1.png")) { encoder.Save(fs); } textImage3.Stretch = Stretch.None; textImage3.Source = bmp; }
// Draw this area symbol in the graphics inside/around the path provided, with // the given color only. internal void Draw(GraphicsTarget g, SymPathWithHoles path, SymColor color, float angle, RenderOptions renderOpts) { if (!pensAndBrushesCreated) CreatePensAndBrushes(); if (color == fillColor) { path.Fill(g, color.Brush); } if (hatchMode != 0 && hatchColor == color) { DrawHatching(g, path, angle, renderOpts); } if (drawPattern && patternGlyph.HasColor(color)) { // Faster to draw the pattern with a texture brush that has a bitmap // of the pattern in it. Better quality to do it all with glyph drawing. // Choose based on the renderOptions. #if false DrawPatternWithTexBrush(g, path, angle, color, renderOpts); #else if (renderOpts.usePatternBitmaps) { CreatePatternBrush(renderOpts.minResolution); DrawPatternWithTexBrush(g, path, angle, color, renderOpts); } else DrawPattern(g, path, angle, color, renderOpts); #endif } // Draw the border. Take into account the subpaths defined by start/stop flags along the paths. if (borderSymdef != null && borderSymdef.HasColor(color)) { // Draw main part of border. foreach (SymPath subpath in path.MainPath.GetSubpaths(SymPath.AREA_BOUNDARY_STARTSTOPFLAG)) borderSymdef.Draw(g, subpath, color, renderOpts); // Draw the holes. if (path.Holes != null) foreach (SymPath hole in path.Holes) foreach (SymPath subpath in hole.GetSubpaths(SymPath.AREA_BOUNDARY_STARTSTOPFLAG)) borderSymdef.Draw(g, subpath, color, renderOpts); } }
public SingleFilenameProvider(RenderOptions options) => _options = options;
// Draw a set of horizontal hatching lines at the given spacing with // the given pen. A line should be centered on the zero y coordinate. void DrawHatchLines(GraphicsTarget g, Pen pen, float spacing, RectangleF boundingRect, RenderOptions renderOpts) { double firstLine = Math.Round(boundingRect.Top / spacing) * spacing; double lastLine = (Math.Round(boundingRect.Bottom / spacing) + 0.5) * spacing; for (double y = firstLine; y <= lastLine; y += spacing) { g.DrawLine(pen, new PointF(boundingRect.Left, (float) y), new PointF(boundingRect.Right, (float) y)); } }
private static void OnIsAliasedPropertyChanged([NotNull] DependencyObject sender, DependencyPropertyChangedEventArgs e) { RenderOptions.SetEdgeMode(sender, (bool)e.NewValue ? EdgeMode.Aliased : EdgeMode.Unspecified); }
// Draw a set of rows of the pattern with the given rectangle void DrawPatternRows(GraphicsTarget g, RectangleF boundingRect, SymColor color, RenderOptions renderOpts) { double topLine = Math.Round(boundingRect.Top / patternHeight) * patternHeight; double bottomLine = (Math.Round(boundingRect.Bottom / patternHeight) + 0.5) * patternHeight; double leftLine = Math.Round(boundingRect.Left / patternWidth) * patternWidth; double rightLine = (Math.Round(boundingRect.Right / patternWidth) + 0.5) * patternWidth; double offsetLeftLine = leftLine - (patternWidth / 2); double offsetRightLine = rightLine + (patternWidth / 2); bool firstLineOffset = ((long) Math.Round(boundingRect.Top / patternHeight) & 1) != 0; bool offsetThisLine = offsetRows && firstLineOffset; for (double y = topLine; y <= bottomLine; y += patternHeight) { if (offsetThisLine) { for (double x = offsetLeftLine; x <= offsetRightLine; x += patternWidth) { patternGlyph.Draw(g, new PointF((float) x, (float) y), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts); } } else { for (double x = leftLine; x <= rightLine; x += patternWidth) { patternGlyph.Draw(g, new PointF((float) x, (float) y), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts); } } if (offsetRows) offsetThisLine = !offsetThisLine; } }
void IGraphicsBackend.BeginRendering(IDrawDevice device, RenderOptions options, RenderStats stats) { DebugCheckOpenGLErrors(); this.currentDevice = device; this.renderOptions = options; this.renderStats = stats; // Prepare the target surface for rendering NativeRenderTarget.Bind(options.Target as NativeRenderTarget); // Determine the available size on the active rendering surface //Point2 availableSize; //if (NativeRenderTarget.BoundRT != null) { // availableSize = new Point2(NativeRenderTarget.BoundRT.Width, NativeRenderTarget.BoundRT.Height); //} else { // availableSize = this.externalBackbufferSize; //} Rect openGLViewport = options.Viewport; // Setup viewport and scissor rects GL.Viewport((int)openGLViewport.X, (int)openGLViewport.Y, (int)MathF.Ceiling(openGLViewport.W), (int)MathF.Ceiling(openGLViewport.H)); GL.Scissor((int)openGLViewport.X, (int)openGLViewport.Y, (int)MathF.Ceiling(openGLViewport.W), (int)MathF.Ceiling(openGLViewport.H)); // Clear buffers ClearBufferMask glClearMask = 0; ColorRgba clearColor = options.ClearColor; if ((options.ClearFlags & ClearFlag.Color) != ClearFlag.None) { glClearMask |= ClearBufferMask.ColorBufferBit; } if ((options.ClearFlags & ClearFlag.Depth) != ClearFlag.None) { glClearMask |= ClearBufferMask.DepthBufferBit; } GL.ClearColor(clearColor.R / 255.0f, clearColor.G / 255.0f, clearColor.B / 255.0f, clearColor.A / 255.0f); GL.ClearDepth(options.ClearDepth); GL.Clear(glClearMask); // Configure Rendering params GL.Enable(EnableCap.ScissorTest); GL.Enable(EnableCap.DepthTest); if (options.DepthTest) { GL.DepthFunc(DepthFunction.Lequal); } else { GL.DepthFunc(DepthFunction.Always); } Matrix4 view = options.ViewMatrix; Matrix4 projection = options.ProjectionMatrix; if (NativeRenderTarget.BoundRT != null) { Matrix4 flipOutput = Matrix4.CreateScale(1.0f, -1.0f, 1.0f); projection = projection * flipOutput; } // Convert matrices to float arrays GetArrayMatrix(ref view, viewData); GetArrayMatrix(ref projection, projectionData); // All EBOs can be used again lastUsedEBO = 0; }
void CreatePatternBrush() { patternBrushes = new Dictionary<SymColor, Brush>(2); foreach (SymColor color in map.colors) { if (!patternGlyph.HasColor(color)) continue; RenderOptions renderOpts = new RenderOptions(); renderOpts.minResolution = 0.001F; renderOpts.usePatternBitmaps = false; // Create a visual with the glyph to tile in it. DrawingVisual visual = new DrawingVisual(); DrawingContext dc = visual.RenderOpen(); GraphicsTarget grTarget = new GraphicsTarget(dc); patternGlyph.Draw(grTarget, new PointF(0F, 0F), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts); if (offsetRows) { patternGlyph.Draw(grTarget, new PointF(patternWidth / 2, patternHeight), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts); patternGlyph.Draw(grTarget, new PointF(-patternWidth / 2, patternHeight), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts); } dc.Close(); // Get a drawing from the drawingvisual Drawing drawing = visual.Drawing; drawing.Freeze(); // Create a brush from the drawing. DrawingBrush brush = new DrawingBrush(drawing); brush.Stretch = Stretch.Fill; brush.TileMode = TileMode.Tile; brush.ViewboxUnits = BrushMappingMode.Absolute; brush.ViewportUnits = BrushMappingMode.Absolute; if (offsetRows) brush.Viewbox = brush.Viewport = new Rect(-patternWidth / 2, -patternHeight / 2, patternWidth, patternHeight * 2); else brush.Viewbox = brush.Viewport = new Rect(-patternWidth / 2, -patternHeight / 2, patternWidth, patternHeight); brush.Transform = new RotateTransform(patternAngle); // Set the minimum and maximum relative sizes for regenerating the tiled brush. // The tiled brush will be regenerated when the size is // 0.5x, 0.25x (and so forth) // and // 2x, 4x, 8x (and so forth) // of the original size. System.Windows.Media.RenderOptions.SetCacheInvalidationThresholdMinimum(brush, 0.5); System.Windows.Media.RenderOptions.SetCacheInvalidationThresholdMaximum(brush, 2.0); // Set the caching hint option for the brush. System.Windows.Media.RenderOptions.SetCachingHint(brush, CachingHint.Cache); // Freeze the brush. brush.Freeze(); // Add it to the collection of brushes. patternBrushes.Add(color, brush); } }
public void terkeprajzolas() { m = App.jatek.terkep.magassag * (2 * offsetY()) + offsetY(); sz = App.jatek.terkep.szelesseg * (offsetX() + oldalhossz) + offsetX(); //if (sz>100 && sz<2000 && m>100 && m < 2000) { canvas.Height = m; canvas.Width = sz; //} canvas.Children.Clear(); //if (terkepAllapot == ETerkepAllapot.egysegmozgatas) //{ // Dijkstra(aktualisEgyseg.aktualisCella); //} //if (terkepAllapot == ETerkepAllapot.harc) // Dijkstra(aktualisEgyseg.aktualisCella); List <Line> lines = new List <Line>(); for (int j = 0; j < App.jatek.terkep.magassag; j++) { for (int i = 0; i < App.jatek.terkep.szelesseg; i++) { PointCollection curvePoints = getScreenCoords(App.jatek.terkep.sorok[j][i]); Polygon p = new Polygon(); RenderOptions.SetEdgeMode((DependencyObject)p, EdgeMode.Aliased); p.Stroke = Brushes.Black; if (App.jatek.terkep.sorok[j][i].tulaj != null) { p.Fill = getSzin(App.jatek.terkep.sorok[j][i].tulaj); } else { p.Fill = Brushes.Gray; } if (App.jatek.terkep.terkepAllapot == ETerkepAllapot.egysegmozgatas) { //if (Tavolsag(cellak[i][j], aktualisEgyseg.aktualisCella) <= ((CMozgoTerkepiEgyseg)aktualisEgyseg).range) //Console.WriteLine("Tavolsag:{0}", dist[j][i]); if (App.jatek.terkep.tavolsagTabla[j][i] <= ((CMozgoTerkepiEgyseg)aktualisEgyseg).range) { p.StrokeThickness = 2; p.Stroke = Brushes.Yellow; } else { //p.StrokeThickness = 0.8; p.Stroke = Brushes.Black; } } else { p.StrokeThickness = 1; } p.HorizontalAlignment = HorizontalAlignment.Left; p.VerticalAlignment = VerticalAlignment.Center; p.Points = curvePoints; canvas.Children.Add(p); //Line myLine = new Line(); //myLine.Stroke = System.Windows.Media.Brushes.LightSteelBlue; //myLine.X1 = 1; //myLine.X2 = 500; //myLine.Y1 = 1; //myLine.Y2 = 500; //myLine.HorizontalAlignment = HorizontalAlignment.Left; //myLine.VerticalAlignment = VerticalAlignment.Center; //myLine.StrokeThickness = 10; //canvas.Children.Add(myLine); if (App.jatek.terkep.sorok[j][i].extraSzomszed != null) { foreach (CTerkepiCella extra in App.jatek.terkep.sorok[j][i].extraSzomszed) { if (extra != null && extra.tulaj != null) { Line myLine1 = new Line(); myLine1.Stroke = getVonalszín(App.jatek.terkep.sorok[j][i].tulaj); Point from = getCanvasCoord(App.jatek.terkep.sorok[j][i]); myLine1.X1 = from.X + oldalhossz / 1.5; myLine1.Y1 = from.Y + oldalhossz / 2; Point to = getCanvasCoord(extra); myLine1.X2 = to.X + oldalhossz / 1.5; myLine1.Y2 = to.Y + oldalhossz / 2; //myLine1.HorizontalAlignment = HorizontalAlignment.Left; //myLine1.VerticalAlignment = VerticalAlignment.Center; myLine1.StrokeThickness = 1; lines.Add(myLine1); } } } //if (terkepAllapot == ETerkepAllapot.egysegmozgatas) //{ // if (tavolsagTabla[j][i] < 50000) // { // TextBlock textBlock = new TextBlock(); // textBlock.Text = tavolsagTabla[j][i].ToString(); // //textBlock.Foreground = new SolidColorBrush(Brushes.Black); // Canvas.SetLeft(textBlock, cellak[j][i].getScreenCoord().X + oldalhossz / 1.5); // Canvas.SetTop(textBlock, cellak[j][i].getScreenCoord().Y + oldalhossz / 2-5); // canvas.Children.Add(textBlock); // } //} //TextBlock textBlock1 = new TextBlock(); //textBlock1.Text = String.Format("{0},{1}",j,i); ////textBlock.Foreground = new SolidColorBrush(Brushes.Black); //Canvas.SetLeft(textBlock1, cellak[j][i].getScreenCoord().X + oldalhossz / 1.5); //Canvas.SetTop(textBlock1, cellak[j][i].getScreenCoord().Y - oldalhossz+2); //canvas.Children.Add(textBlock1); } } foreach (Line l in lines) { canvas.Children.Add(l); } CTerkepiImage myImage = null; ContextMenu contextMenu = new ContextMenu(); //contextMenu.Items.Add("Mozgás"); //contextMenu.Items.Add("Harc"); //if (App.jatek.aktualisallapot == EJatekAllapotok.egysegmozgatas) //{ // MenuItem item = new MenuItem(); // item.Header = "mozgás"; // item.Click += delegate { MyImage_Mozgas(); }; // contextMenu.Items.Add(item); //} if (App.jatek.aktualisallapot == EJatekAllapotok.harc) { MenuItem item1 = new MenuItem(); item1.Header = "harc"; item1.Click += delegate { MyImage_Harc(); }; contextMenu.Items.Add(item1); } int szamlalo = 0; foreach (CJatekos j in App.jatek.jatekosok) { szamlalo++; foreach (CTerkepiEgyseg te in j.egysegekLista) { if (te.aktualisCella == null) { break; } // Create Image Element myImage = new CTerkepiImage(te); myImage.Width = 20; // Create source BitmapImage myBitmapImage = new BitmapImage(); // BitmapImage.UriSource must be in a BeginInit/EndInit block myBitmapImage.BeginInit(); myBitmapImage.UriSource = new Uri(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, te.bitmap + "_" + szamlalo.ToString() + ".png"), UriKind.Absolute); myBitmapImage.DecodePixelWidth = 20; myBitmapImage.EndInit(); //set image source myImage.Source = myBitmapImage; canvas.Children.Add(myImage); //myImage.MouseUp += MyImage_MouseUp; //myImage.MouseRightButtonDown += MyImage_RightMouseDown; myImage.MouseLeftButtonDown += MyImage_MouseLeftButtonDown; myImage.ContextMenu = contextMenu; Canvas.SetTop(myImage, getCanvasCoord(te.aktualisCella).Y - oldalhossz / 2); Canvas.SetLeft(myImage, getCanvasCoord(te.aktualisCella).X + oldalhossz / 2); TextBlock textBlockElet = new TextBlock(); textBlockElet.Text = String.Format("{0}", te.elet.ToString()); //textBlock.Foreground = new SolidColorBrush(Brushes.Black); Canvas.SetTop(textBlockElet, getCanvasCoord(te.aktualisCella).Y - oldalhossz / 2 - 12); Canvas.SetLeft(textBlockElet, getCanvasCoord(te.aktualisCella).X + oldalhossz / 2 + 12); canvas.Children.Add(textBlockElet); if (App.jatek.aktualisallapot == EJatekAllapotok.egysegmozgatas && ((CMozgoTerkepiEgyseg)te != null) && !((CMozgoTerkepiEgyseg)te).lepettMar) { Line myLine1 = new Line(); myLine1.Stroke = getVonalszín(j); Point from = getCanvasCoord(te.aktualisCella); from.Offset(oldalhossz / 1.5, oldalhossz / 3); myLine1.X1 = from.X; myLine1.Y1 = from.Y; Point to = from; to.Offset(oldalhossz / 2, 0); myLine1.X2 = to.X; myLine1.Y2 = to.Y; //myLine1.HorizontalAlignment = HorizontalAlignment.Left; //myLine1.VerticalAlignment = VerticalAlignment.Center; myLine1.StrokeThickness = 1; canvas.Children.Add(myLine1); } if (te.elet == 0) { Image myImage1 = new Image(); myImage1.Width = 20; // Create source BitmapImage myBitmapImage1 = new BitmapImage(); // BitmapImage.UriSource must be in a BeginInit/EndInit block myBitmapImage1.BeginInit(); myBitmapImage1.UriSource = new Uri(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "megsemmisult.png"), UriKind.Absolute); myBitmapImage1.DecodePixelWidth = 20; myBitmapImage1.EndInit(); myImage1.Source = myBitmapImage1; canvas.Children.Add(myImage1); Canvas.SetTop(myImage1, getCanvasCoord(te.aktualisCella).Y - oldalhossz / 2); Canvas.SetLeft(myImage1, getCanvasCoord(te.aktualisCella).X + oldalhossz / 2); } } } canvas.InvalidateVisual(); }
// Draw this line symbol in the graphics along the path provided, with // the given color only. internal void Draw(GraphicsTarget g, SymPath path, SymColor color, RenderOptions renderOpts) { Debug.Assert(map != null); if (path.Length == 0) return; // Don't draw anything for a zero-length path. if (!pensCreated) CreatePens(); SymPath mainPath = path; // the path for the main part of the line (might be shortened). if (shortenInfo.shortenBeginning > 0.0F || shortenInfo.shortenEnd > 0.0F) { mainPath = path.ShortenBizzarro(shortenInfo.shortenBeginning, shortenInfo.shortenEnd); // NOTE: mainPath can be NULL below here!!! } if (color == lineColor && thickness > 0.0F && mainPath != null) { if (!isDashed) { // simple drawing. mainPath.Draw(g, mainPen); } else { // Draw the dashed line. DrawDashed(g, mainPath, mainPen, dashInfo, renderOpts); } } // Draw the pointy ends of the line. If mainPath is null, this is all the line! if (color == lineColor && shortenInfo.pointyEnds && thickness > 0.0F && (shortenInfo.shortenBeginning > 0.0F || shortenInfo.shortenEnd > 0.0F)) DrawPointyEnds(g, path, shortenInfo.shortenBeginning, shortenInfo.shortenEnd, thickness); if (color == secondLineColor && secondThickness > 0.0F && path != null) { // note that shortened path not used for secondary line, the full length path is. path.Draw(g, secondPen); } // Double lines don't use the shortened path, but the full-length path. if (isDoubleLine) { if (doubleLines.doubleFillColor == color) { if (doubleLines.doubleFillDashed) DrawDashed(g, path, doubleFillPen, doubleLines.doubleDashes, renderOpts); else path.Draw(g, doubleFillPen); } if (doubleLines.doubleLeftColor == color && doubleLines.doubleLeftWidth > 0.0F) { foreach (SymPath subpath in path.GetSubpaths(SymPath.DOUBLE_LEFT_STARTSTOPFLAG)) { float offsetRight = -(doubleLines.doubleThick + doubleLines.doubleLeftWidth) / 2F; if (doubleLines.doubleLeftDashed) { DrawDashedWithOffset(g, subpath, doubleLeftPen, doubleLines.doubleDashes, offsetRight, GraphicsUtil.MITER_LIMIT, renderOpts); } else { SymPath leftPath = subpath.OffsetRight(offsetRight, GraphicsUtil.MITER_LIMIT); leftPath.Draw(g, doubleLeftPen); } } } if (doubleLines.doubleRightColor == color && doubleLines.doubleRightWidth > 0.0F) { foreach (SymPath subpath in path.GetSubpaths(SymPath.DOUBLE_RIGHT_STARTSTOPFLAG)) { float offsetRight = (doubleLines.doubleThick + doubleLines.doubleRightWidth) / 2F; if (doubleLines.doubleRightDashed) { DrawDashedWithOffset(g, subpath, doubleRightPen, doubleLines.doubleDashes, offsetRight, GraphicsUtil.MITER_LIMIT, renderOpts); } else { SymPath rightPath = subpath.OffsetRight(offsetRight, GraphicsUtil.MITER_LIMIT); rightPath.Draw(g, doubleRightPen); } } } } if (glyphs != null && mainPath != null) { foreach (GlyphInfo glyphInfo in glyphs) { if (glyphInfo.glyph.HasColor(color)) DrawGlyphs(g, glyphInfo, mainPath, path, color, renderOpts); } } }
public abstract void RenderFrame(GPUContext context, ref StagingTexture frame, RenderOptions options, GPUTexture output);