private void drawTemporalUncertaintyGlyph(float wingLength, float x, float y, float lat, float lng, float width, Brush brush) { float rotationAngle = (float)Math.Atan((lng - lat) / width) * div; this.RenderTarget.Transform = Matrix3x2F.Rotation(rotationAngle, new D2D.Point2F(x, y)); this.RenderTarget.DrawLine(new D2D.Point2F(x - wingLength - 5, y - 2), new D2D.Point2F(x + wingLength + 5, y - 2), brush, 1.5f); this.RenderTarget.DrawLine(new D2D.Point2F(x - wingLength - 5, y + 2), new D2D.Point2F(x + wingLength + 5, y + 2), brush, 1.5f); this.RenderTarget.Transform = Matrix3x2F.Identity; }
protected internal Matrix3x2F RandomMatrix3x2() { var which = Random.NextDouble(); //return Matrix3x2F.Skew(90, 0); //check for bug 730701 Matrix3x2F ret; if (which < 0.5) { ret = new Matrix3x2F( 1.0f - (float)Random.NextDouble() * (float)Random.NextDouble(), (float)Random.NextDouble() * (float)Random.NextDouble(), (float)Random.NextDouble() * (float)Random.NextDouble(), 1.0f - (float)Random.NextDouble() * (float)Random.NextDouble(), (float)Random.NextDouble() * (float)Random.NextDouble(), (float)Random.NextDouble() * (float)Random.NextDouble() ); TraceMatrix(ret); return(ret); } if (which < 0.8) { ret = Matrix3x2F.Identity; TraceMatrix(ret); return(ret); } if (which < 0.85) { ret = Matrix3x2F.Translation( Random.Next(-20, 20), Random.Next(-20, 20)); TraceMatrix(ret); return(ret); } if (which < 0.90) { ret = Matrix3x2F.Skew( (float)(Random.NextDouble() * Random.NextDouble() * 89), (float)(Random.NextDouble() * Random.NextDouble() * 89), CoinFlip ? new Point2F(0, 0) : RandomPoint()); TraceMatrix(ret); return(ret); } if (which < 0.95) { ret = Matrix3x2F.Scale( 1 + (float)((Random.NextDouble() - 0.5) * Random.NextDouble()), 1 + (float)((Random.NextDouble() - 0.5) * Random.NextDouble()), CoinFlip ? new Point2F(0, 0) : RandomPoint()); TraceMatrix(ret); return(ret); } ret = Matrix3x2F.Rotation( (float)((Random.NextDouble() - 0.5) * Random.NextDouble() * 720), CoinFlip ? new Point2F(0, 0) : RandomPoint()); TraceMatrix(ret); return(ret); }
private void drawUGlyph(float wingLength, float x, float y, float lat, float lng, float width, Brush brush) { float rotationAngle = (float)Math.Atan((lng - lat) / width) * div; //rotationAngle += rotationAngle < 0 ? 90f : 45f; this.RenderTarget.Transform = Matrix3x2F.Rotation(rotationAngle, new D2D.Point2F(x, y)); float hw = WINGLENGTHX / 2; PathGeometry pLinesGeometry = this.Factory.CreatePathGeometry(); GeometrySink gs = pLinesGeometry.Open(); gs.SetFillMode(FillMode.Winding); gs.BeginFigure(new D2D.Point2F(x, y), FigureBegin.Filled); gs.AddLine(new D2D.Point2F(x + hw, y + hw)); gs.AddLine(new D2D.Point2F(x + hw, y - wingLength)); gs.AddLine(new D2D.Point2F(x, y)); gs.AddLine(new D2D.Point2F(x - hw, y + hw)); gs.AddLine(new D2D.Point2F(x - hw, y - wingLength)); gs.EndFigure(FigureEnd.Closed); gs.Close(); brush.Opacity = 0.5f; this.RenderTarget.FillGeometry(pLinesGeometry, brush); //brush.Opacity = 0.2f; //this.RenderTarget.FillGeometry(pLinesGeometry,brush); //brush.Opacity = 0.8f; //this.RenderTarget.DrawGeometry(pLinesGeometry, brush, 0.8f); //this.RenderTarget.DrawRectangle(new D2D.RectF(x - RECTSIZE, y - RECTSIZE, x + RECTSIZE, y + RECTSIZE), brush, 0.8f); this.RenderTarget.Transform = Matrix3x2F.Identity; }
void RenderD2DContentIntoTexture() { SizeF rtSize = textureRenderTarget.Size; textureRenderTarget.BeginDraw(); textureRenderTarget.Transform = Matrix3x2F.Identity; textureRenderTarget.Clear(new ColorF(GetColorValues(System.Windows.Media.Colors.White))); textureRenderTarget.FillRectangle( new RectF(0.0f, 0.0f, rtSize.Width, rtSize.Height), gridPatternBitmapBrush); SizeF size = d2dBitmap.Size; textureRenderTarget.DrawBitmap( d2dBitmap, 1.0f, BitmapInterpolationMode.Linear, new RectF( 0.0f, 0.0f, size.Width, size.Height) ); // Draw the bitmap at the bottom corner of the window textureRenderTarget.DrawBitmap( d2dBitmap, 1.0f, BitmapInterpolationMode.Linear, new RectF( rtSize.Width - size.Width, rtSize.Height - size.Height, rtSize.Width, rtSize.Height)); // Set the world transform to rotatate the drawing around the center of the render target // and write "Hello World" float angle = 0.1f * Environment.TickCount; textureRenderTarget.Transform = Matrix3x2F.Rotation( angle, new Point2F( rtSize.Width / 2, rtSize.Height / 2 )); textureRenderTarget.DrawText( HelloWorldText, textFormat, new RectF( 0, 0, rtSize.Width, rtSize.Height ), blackBrush ); // Reset back to the identity transform textureRenderTarget.Transform = Matrix3x2F.Translation( 0, rtSize.Height - 200 ); textureRenderTarget.FillGeometry( pathGeometry, linearGradientBrush); textureRenderTarget.Transform = Matrix3x2F.Translation( rtSize.Width - 200, 0 ); textureRenderTarget.FillGeometry( pathGeometry, linearGradientBrush ); textureRenderTarget.EndDraw(); }