public void Draw(PixelFarm.DrawingGL.CanvasGL2d canvas) { if (myvxs == null) { var transform = Affine.NewMatix( AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y), AffinePlan.Scale(spriteScale, spriteScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(Width / 2, Height / 2) ); myvxs = transform.TransformToVxs(lionShape.Path.Vxs); } //--------------------------------------------------------------------------------------------- { int j = lionShape.NumPaths; int[] pathList = lionShape.PathIndexList; ColorRGBA[] colors = lionShape.Colors; //graphics2D.UseSubPixelRendering = true; for (int i = 0; i < j; ++i) { var color = colors[i]; //? canvas.FillVxsSnap( new PixelFarm.Drawing.Color(color.alpha, color.blue, color.green, color.red), new VertexStoreSnap(myvxs, pathList[i])); } } }
public override void Render(PixelFarm.Drawing.Painter p) { if (_currentTx == null) { _currentTx = Affine.NewMatix( AffinePlan.Translate(-_spriteShape.Center.x, -_spriteShape.Center.y), AffinePlan.Scale(_spriteScale, _spriteScale), AffinePlan.Rotate(_angle + Math.PI), AffinePlan.Skew(_skewX / 1000.0, _skewY / 1000.0), AffinePlan.Translate(Width / 2, Height / 2) ); } if (JustMove) { float ox = p.OriginX; float oy = p.OriginY; p.SetOrigin(ox + _posX, oy + _posY); _spriteShape.Paint(p); p.SetOrigin(ox, oy); } else { _spriteShape.Paint(p, _currentTx); } }
public override void Draw(Graphics2D g) { int width = 800; int height = 600; //clear the image to white g.Clear(ColorRGBA.White); // draw a circle Ellipse ellipsePro = new Ellipse(0, 0, 100, 50); for (double angleDegrees = 0; angleDegrees < 180; angleDegrees += 22.5) { var mat = Affine.NewMatix( AffinePlan.Rotate(MathHelper.DegreesToRadians(angleDegrees)), AffinePlan.Translate(width / 2, 150)); VertexStore sp1 = mat.TransformToVxs(ellipsePro.MakeVxs()); g.Render(sp1, ColorRGBA.Yellow); //Stroke ellipseOutline = new Stroke(sp1, 3); g.Render(StrokeHelp.MakeVxs(sp1, 3), ColorRGBA.Blue); } // and a little polygon PathWriter littlePoly = new PathWriter(); littlePoly.MoveTo(50, 50); littlePoly.LineTo(150, 50); littlePoly.LineTo(200, 200); littlePoly.LineTo(50, 150); littlePoly.LineTo(50, 50); g.Render(littlePoly.MakeVertexSnap(), ColorRGBA.Cyan); // draw some text // draw some text var textPrinter = new TextPrinter(); textPrinter.CurrentFont = SvgFontStore.LoadFont(SvgFontStore.DEFAULT_SVG_FONTNAME, 30); //new TypeFacePrinter("Printing from a printer", 30, justification: Justification.Center); VertexStore vxs = textPrinter.CreateVxs("Printing from a printer".ToCharArray()); var affTx = Affine.NewTranslation(width / 2, height / 4 * 3); VertexStore s1 = affTx.TransformToVxs(vxs); g.Render(s1, ColorRGBA.Black); g.Render(StrokeHelp.MakeVxs(s1, 1), ColorRGBA.Red); var aff2 = Affine.NewMatix( AffinePlan.Rotate(MathHelper.DegreesToRadians(90)), AffinePlan.Translate(40, height / 2)); g.Render(aff2.TransformToVertexSnap(vxs), ColorRGBA.Black); }
public override void OnDraw(Graphics2D graphics2D) { if (myvxs == null) { var transform = Affine.NewMatix( AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y), AffinePlan.Scale(spriteScale, spriteScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(Width / 2, Height / 2) ); //create vertextStore again from origiinal path myvxs = transform.TransformToVxs(lionShape.Path.Vxs); } //--------------------------------------------------------------------------------------------- { int j = lionShape.NumPaths; int[] pathList = lionShape.PathIndexList; ColorRGBA[] colors = lionShape.Colors; //graphics2D.UseSubPixelRendering = true; for (int i = 0; i < j; ++i) { graphics2D.Render(new VertexStoreSnap(myvxs, pathList[i]), colors[i]); } } //--------------------------------------------------------------------------------------------- }
static Affine CreateAffine(double destX, double destY, double hotspotOffsetX, double hotSpotOffsetY, double scaleX, double scaleY, double angleRad) { AffinePlan[] plans = new AffinePlan[4]; int i = 0; if (hotspotOffsetX != 0.0f || hotSpotOffsetY != 0.0f) { plans[i] = AffinePlan.Translate(-hotspotOffsetX, -hotSpotOffsetY); i++; } if (scaleX != 1 || scaleY != 1) { plans[i] = AffinePlan.Scale(scaleX, scaleY); i++; } if (angleRad != 0) { plans[i] = AffinePlan.Rotate(angleRad); i++; } if (destX != 0 || destY != 0) { plans[i] = AffinePlan.Translate(destX, destY); i++; } return(Affine.NewMatix2(plans)); }
void DrawWithWinGdi(GdiPlusPainter p) { int w = 800, h = 600; p.Clear(Drawing.Color.White); p.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; if (isMaskSliderValueChanged) { GenerateMaskWithWinGdiPlus(w, h); } using (System.Drawing.Bitmap background = CreateBackgroundBmp(w, h)) { p.DrawImage(background, 0, 0); } //draw lion on background Affine transform = Affine.NewMatix( AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y), AffinePlan.Scale(lionScale, lionScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(w / 2, h / 2)); using (System.Drawing.Bitmap lionBmp = new System.Drawing.Bitmap(w, h)) using (System.Drawing.Graphics lionGfx = System.Drawing.Graphics.FromImage(lionBmp)) { //lionGfx.Clear(System.Drawing.Color.White); //int n = lionShape.NumPaths; //int[] indexList = lionShape.PathIndexList; //TODO: review here again throw new NotSupportedException(); //Color[] colors = lionShape.Colors; ////var lionVxs = lionShape.Path.Vxs;// transform.TransformToVxs(lionShape.Path.Vxs); //var lionVxs = new VertexStore(); //transform.TransformToVxs(lionShape.Vxs, lionVxs); //for (int i = 0; i < n; ++i) //{ // VxsHelper.FillVxsSnap(lionGfx, // new VertexStoreSnap(lionVxs, indexList[i]), // colors[i]); //} //using (var mergeBmp = MergeAlphaChannel(lionBmp, a_alphaBmp)) //{ // //gx.InternalGraphics.DrawImage(this.a_alphaBmp, new System.Drawing.PointF(0, 0)); // //gx.InternalGraphics.DrawImage(bmp, new System.Drawing.PointF(0, 0)); // p.DrawImage(mergeBmp, 0, 0); //} } }
Affine BuildImageBoundsPath(IImageReaderWriter sourceImage, VertexStore drawImageRectPath, double destX, double destY, double hotspotOffsetX, double hotSpotOffsetY, double scaleX, double scaleY, double angleRad) { AffinePlan[] plan = new AffinePlan[4]; int i = 0; if (hotspotOffsetX != 0.0f || hotSpotOffsetY != 0.0f) { plan[i] = AffinePlan.Translate(-hotspotOffsetX, -hotSpotOffsetY); i++; } if (scaleX != 1 || scaleY != 1) { plan[i] = AffinePlan.Scale(scaleX, scaleY); i++; } if (angleRad != 0) { plan[i] = AffinePlan.Rotate(angleRad); i++; } if (destX != 0 || destY != 0) { plan[i] = AffinePlan.Translate(destX, destY); i++; } int srcW = sourceImage.Width; int srcH = sourceImage.Height; drawImageRectPath.Clear(); drawImageRectPath.AddMoveTo(0, 0); drawImageRectPath.AddLineTo(srcW, 0); drawImageRectPath.AddLineTo(srcW, srcH); drawImageRectPath.AddLineTo(0, srcH); drawImageRectPath.AddCloseFigure(); return(Affine.NewMatix(plan)); }
public override void Draw(PixelFarm.Drawing.Painter p) { if (myvxs == null) { var transform = Affine.NewMatix( AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y), AffinePlan.Scale(spriteScale, spriteScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(Width / 2, Height / 2) ); //create vertextStore again from original path myvxs = new VertexStore(); transform.TransformToVxs(lionShape.Vxs, myvxs); if (AutoFlipY) { //flip the lion PixelFarm.Agg.Transform.Affine aff = PixelFarm.Agg.Transform.Affine.NewMatix( PixelFarm.Agg.Transform.AffinePlan.Scale(-1, -1), PixelFarm.Agg.Transform.AffinePlan.Translate(0, 600)); // var v2 = new VertexStore(); myvxs = transform.TransformToVxs(myvxs, v2); } } //--------------------------------------------------------------------------------------------- { int j = lionShape.NumPaths; int[] pathList = lionShape.PathIndexList; Drawing.Color[] colors = lionShape.Colors; //graphics2D.UseSubPixelRendering = true; for (int i = 0; i < j; ++i) { p.FillColor = colors[i]; p.Fill(new VertexStoreSnap(myvxs, pathList[i])); } } //test if (SharpenRadius > 0) { //p.DoFilter(new RectInt(0, p.Height, p.Width, 0), 2); //PixelFarm.Agg.Imaging.SharpenFilterARGB.Sharpen() } }
static Affine BuildImageBoundsPath( int srcW, int srcH, double destX, double destY, double hotspotOffsetX, double hotSpotOffsetY, double scaleX, double scaleY, double angleRad, VertexStore outputDestImgRect) { AffinePlan[] plans = new AffinePlan[4]; int i = 0; if (hotspotOffsetX != 0.0f || hotSpotOffsetY != 0.0f) { plans[i] = AffinePlan.Translate(-hotspotOffsetX, -hotSpotOffsetY); i++; } if (scaleX != 1 || scaleY != 1) { plans[i] = AffinePlan.Scale(scaleX, scaleY); i++; } if (angleRad != 0) { plans[i] = AffinePlan.Rotate(angleRad); i++; } if (destX != 0 || destY != 0) { plans[i] = AffinePlan.Translate(destX, destY); i++; } outputDestImgRect.Clear(); outputDestImgRect.AddMoveTo(0, 0); outputDestImgRect.AddLineTo(srcW, 0); outputDestImgRect.AddLineTo(srcW, srcH); outputDestImgRect.AddLineTo(0, srcH); outputDestImgRect.AddCloseFigure(); return(Affine.NewMatix(plans)); }
public override void Draw(CanvasPainter p) { int strokeWidth = 1; int width = p.Width; int height = p.Height; Affine affTx = Affine.NewMatix( AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y), AffinePlan.Scale(spriteScale, spriteScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(width / 2, height / 2)); var p1 = p as AggCanvasPainter; if (p1 == null) { int j = lionShape.NumPaths; int[] pathList = lionShape.PathIndexList; Drawing.Color[] colors = lionShape.Colors; //graphics2D.UseSubPixelRendering = true; var vxs = GetFreeVxs(); affTx.TransformToVxs(lionShape.Path.Vxs, vxs); p.StrokeWidth = 1; for (int i = 0; i < j; ++i) { p.StrokeColor = colors[i]; p.Draw(new VertexStoreSnap(vxs, pathList[i])); } //not agg Release(ref vxs); return; //** } Graphics2D graphics2D = p1.Graphics; //var widgetsSubImage = ImageHelper.CreateChildImage(graphics2D.DestImage, graphics2D.GetClippingRect()); //int width = widgetsSubImage.Width; //int height = widgetsSubImage.Height; var widgetsSubImage = ImageHelper.CreateChildImage(graphics2D.DestImage, graphics2D.GetClippingRect()); var clippedSubImage = new ChildImage(widgetsSubImage, new PixelBlenderBGRA()); ClipProxyImage imageClippingProxy = new ClipProxyImage(clippedSubImage); imageClippingProxy.Clear(PixelFarm.Drawing.Color.White); if (RenderAsScanline) { var rasterizer = graphics2D.ScanlineRasterizer; rasterizer.SetClipBox(0, 0, width, height); Stroke stroke = new Stroke(strokeWidth); stroke.LineJoin = LineJoin.Round; var vxs = GetFreeVxs(); affTx.TransformToVxs(lionShape.Path.Vxs, vxs); ScanlineRasToDestBitmapRenderer sclineRasToBmp = graphics2D.ScanlineRasToDestBitmap; sclineRasToBmp.RenderSolidAllPaths( imageClippingProxy, rasterizer, graphics2D.ScanlinePacked8, vxs, lionShape.Colors, lionShape.PathIndexList, lionShape.NumPaths); Release(ref vxs); } else { double w = strokeWidth * affTx.GetScale(); LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(w, new GammaNone()); OutlineRenderer outlineRenderer = new OutlineRenderer(imageClippingProxy, new PixelBlenderBGRA(), lineProfile); OutlineAARasterizer rasterizer = new OutlineAARasterizer(outlineRenderer); rasterizer.LineJoin = (RenderAccurateJoins ? OutlineAARasterizer.OutlineJoin.AccurateJoin : OutlineAARasterizer.OutlineJoin.Round); rasterizer.RoundCap = true; //VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform); var vxs = GetFreeVxs(); affTx.TransformToVxs(lionShape.Path.Vxs, vxs);// trans.DoTransformToNewVxStorage(); int j = lionShape.NumPaths; for (int i = 0; i < j; ++i) { rasterizer.RenderVertexSnap( new VertexStoreSnap(vxs, lionShape.PathIndexList[i]), lionShape.Colors[i]); } Release(ref vxs); } base.Draw(p); }
public override void Draw(CanvasPainter p) { if (p is GdiPlusCanvasPainter) { DrawWithWinGdi((GdiPlusCanvasPainter)p); return; } AggCanvasPainter p2 = (AggCanvasPainter)p; Graphics2D gx = p2.Graphics; var widgetsSubImage = gx.DestImage; var scline = gx.ScanlinePacked8; int width = (int)widgetsSubImage.Width; int height = (int)widgetsSubImage.Height; //change value *** if (isMaskSliderValueChanged) { generate_alpha_mask(gx.ScanlineRasToDestBitmap, gx.ScanlinePacked8, gx.ScanlineRasterizer, width, height); this.isMaskSliderValueChanged = false; } var rasterizer = gx.ScanlineRasterizer; rasterizer.SetClipBox(0, 0, width, height); //alphaMaskImageBuffer.AttachBuffer(alphaByteArray, 0, width, height, width, 8, 1); PixelFarm.Agg.Imaging.AlphaMaskAdaptor imageAlphaMaskAdaptor = new PixelFarm.Agg.Imaging.AlphaMaskAdaptor(widgetsSubImage, alphaMask); ClipProxyImage alphaMaskClippingProxy = new ClipProxyImage(imageAlphaMaskAdaptor); ClipProxyImage clippingProxy = new ClipProxyImage(widgetsSubImage); ////Affine transform = Affine.NewIdentity(); ////transform *= Affine.NewTranslation(-lionShape.Center.x, -lionShape.Center.y); ////transform *= Affine.NewScaling(lionScale, lionScale); ////transform *= Affine.NewRotation(angle + Math.PI); ////transform *= Affine.NewSkewing(skewX / 1000.0, skewY / 1000.0); ////transform *= Affine.NewTranslation(Width / 2, Height / 2); Affine transform = Affine.NewMatix( AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y), AffinePlan.Scale(lionScale, lionScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(width / 2, height / 2)); clippingProxy.Clear(Drawing.Color.White); ScanlineRasToDestBitmapRenderer sclineRasToBmp = gx.ScanlineRasToDestBitmap; // draw a background to show how the mask is working better int rect_w = 30; var v1 = GetFreeVxs(); for (int i = 0; i < 40; i++) { for (int j = 0; j < 40; j++) { if ((i + j) % 2 != 0) { VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * rect_w, j * rect_w, (i + 1) * rect_w, (j + 1) * rect_w, 0); rect.NormalizeRadius(); // Drawing as an outline rasterizer.AddPath(rect.MakeVxs(v1)); v1.Clear(); sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, scline, Drawing.Color.Make(.9f, .9f, .9f)); } } } ReleaseVxs(ref v1); ////int x, y; //// Render the lion ////VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform); ////var vxlist = new System.Collections.Generic.List<VertexData>(); ////trans.DoTransform(vxlist); var tmpVxs1 = new VertexStore(); transform.TransformToVxs(lionShape.Path.Vxs, tmpVxs1); sclineRasToBmp.RenderSolidAllPaths(alphaMaskClippingProxy, rasterizer, scline, tmpVxs1, lionShape.Colors, lionShape.PathIndexList, lionShape.NumPaths); ///* //// Render random Bresenham lines and markers //agg::renderer_markers<amask_ren_type> m(r); //for(i = 0; i < 50; i++) //{ // m.line_color(agg::rgba8(randGenerator.Next() & 0x7F, // randGenerator.Next() & 0x7F, // randGenerator.Next() & 0x7F, // (randGenerator.Next() & 0x7F) + 0x7F)); // m.fill_color(agg::rgba8(randGenerator.Next() & 0x7F, // randGenerator.Next() & 0x7F, // randGenerator.Next() & 0x7F, // (randGenerator.Next() & 0x7F) + 0x7F)); // m.line(m.coord(randGenerator.Next() % width), m.coord(randGenerator.Next() % height), // m.coord(randGenerator.Next() % width), m.coord(randGenerator.Next() % height)); // m.marker(randGenerator.Next() % width, randGenerator.Next() % height, randGenerator.Next() % 10 + 5, // agg::marker_e(randGenerator.Next() % agg::end_of_markers)); //} //// Render random anti-aliased lines //double w = 5.0; //agg::line_profile_aa profile; //profile.width(w); //typedef agg::renderer_outline_aa<amask_ren_type> renderer_type; //renderer_type ren(r, profile); //typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type; //rasterizer_type ras(ren); //ras.round_cap(true); //for(i = 0; i < 50; i++) //{ // ren.Color = agg::rgba8(randGenerator.Next() & 0x7F, // randGenerator.Next() & 0x7F, // randGenerator.Next() & 0x7F, // //255)); // (randGenerator.Next() & 0x7F) + 0x7F); // ras.move_to_d(randGenerator.Next() % width, randGenerator.Next() % height); // ras.line_to_d(randGenerator.Next() % width, randGenerator.Next() % height); // ras.render(false); //} //// Render random circles with gradient //typedef agg::gradient_linear_color<color_type> grad_color; //typedef agg::gradient_circle grad_func; //typedef agg::span_interpolator_linear<> interpolator_type; //typedef agg::span_gradient<color_type, // interpolator_type, // grad_func, // grad_color> span_grad_type; //agg::trans_affine grm; //grad_func grf; //grad_color grc(agg::rgba8(0,0,0), agg::rgba8(0,0,0)); //agg::ellipse ell; //agg::span_allocator<color_type> sa; //interpolator_type inter(grm); //span_grad_type sg(inter, grf, grc, 0, 10); //agg::renderer_scanline_aa<amask_ren_type, // agg::span_allocator<color_type>, // span_grad_type> rg(r, sa, sg); //for(i = 0; i < 50; i++) //{ // x = randGenerator.Next() % width; // y = randGenerator.Next() % height; // double r = randGenerator.Next() % 10 + 5; // grm.reset(); // grm *= agg::trans_affine_scaling(r / 10.0); // grm *= agg::trans_affine_translation(x, y); // grm.invert(); // grc.colors(agg::rgba8(255, 255, 255, 0), // agg::rgba8(randGenerator.Next() & 0x7F, // randGenerator.Next() & 0x7F, // randGenerator.Next() & 0x7F, // 255)); // sg.color_function(grc); // ell.init(x, y, r, r, 32); // g_rasterizer.add_path(ell); // agg::render_scanlines(g_rasterizer, g_scanline, rg); //} // */ ////m_num_cb.Render(g_rasterizer, g_scanline, clippingProxy); }
public override void Render(PixelFarm.Drawing.Painter p) { int strokeWidth = 1; int width = p.Width; int height = p.Height; Affine affTx = Affine.NewMatix( AffinePlan.Translate(-_spriteShape.Center.x, -_spriteShape.Center.y), AffinePlan.Scale(_spriteScale, _spriteScale), AffinePlan.Rotate(_angle + Math.PI), AffinePlan.Skew(_skewX / 1000.0, _skewY / 1000.0), AffinePlan.Translate(width / 2, height / 2)); var p1 = p as AggPainter; if (p1 == null) { //TODO: review here _spriteShape.Paint(p, affTx); //int j = lionShape.NumPaths; //int[] pathList = lionShape.PathIndexList; //Drawing.Color[] colors = lionShape.Colors; ////graphics2D.UseSubPixelRendering = true; //var vxs = GetFreeVxs(); //affTx.TransformToVxs(lionShape.Vxs, vxs); //p.StrokeWidth = 1; //for (int i = 0; i < j; ++i) //{ // p.StrokeColor = colors[i]; // p.Draw(new PixelFarm.Drawing.VertexStoreSnap(vxs, pathList[i])); //} ////not agg //Release(ref vxs); //return; //** } if (UseBitmapExt) { p.RenderQuality = Drawing.RenderQuality.Fast; p.Clear(Drawing.Color.White); p.StrokeWidth = 1; //------------------------- _spriteShape.DrawOutline(p); } else { p.RenderQuality = Drawing.RenderQuality.HighQuality; } //----------------------- AggRenderSurface aggsx = p1.RenderSurface; //----------------------- //TODO: make this reusable ... // SubBitmapBlender widgetsSubImage = BitmapBlenderExtension.CreateSubBitmapBlender(aggsx.DestBitmapBlender, aggsx.GetClippingRect()); SubBitmapBlender clippedSubImage = new SubBitmapBlender(widgetsSubImage, new PixelBlenderBGRA()); ClipProxyImage imageClippingProxy = new ClipProxyImage(clippedSubImage); imageClippingProxy.Clear(PixelFarm.Drawing.Color.White); AggPainter aggPainter = (AggPainter)p; if (RenderAsScanline) { //a low-level example, expose scanline rasterizer ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer; rasterizer.SetClipBox(0, 0, width, height); //lionShape.ApplyTransform(affTx); //--------------------- using (VgPaintArgsPool.Borrow(aggPainter, out VgPaintArgs paintArgs)) { paintArgs._currentTx = affTx; paintArgs.PaintVisitHandler = (vxs, painterA) => { //use external painter handler //draw only outline with its fill-color. rasterizer.Reset(); rasterizer.AddPath(vxs); aggsx.BitmapRasterizer.RenderWithColor( imageClippingProxy, rasterizer, aggsx.ScanlinePacked8, aggPainter.FillColor); //draw line with external drawing handler }; _spriteShape.Paint(paintArgs); } //---------------------------- //lionShape.ResetTransform(); } else { if (UseBuiltInAggOutlineAATech) { aggPainter.StrokeWidth = 1; aggPainter.LineRenderingTech = AggPainter.LineRenderingTechnique.OutlineAARenderer; //------ using (VgPaintArgsPool.Borrow(aggPainter, out VgPaintArgs paintArgs)) { paintArgs._currentTx = affTx; paintArgs.PaintVisitHandler = (vxs, painterA) => { //use external painter handler //draw only outline with its fill-color. Drawing.Painter m_painter = paintArgs.P; Drawing.Color prevStrokeColor = m_painter.StrokeColor; m_painter.StrokeColor = m_painter.FillColor; m_painter.Draw(vxs); m_painter.StrokeColor = prevStrokeColor; }; _spriteShape.Paint(paintArgs); } } else { //low-level implementation aggPainter.StrokeWidth = 1; //------------------------- //Draw with LineProfile: //LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(strokeWidth * affTx.GetScale(), new GammaNone()); //with gamma LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(strokeWidth * affTx.GetScale(), null); OutlineRenderer outlineRenderer = new OutlineRenderer(imageClippingProxy, new PixelBlenderBGRA(), lineProfile); outlineRenderer.SetClipBox(0, 0, this.Width, this.Height); OutlineAARasterizer rasterizer = new OutlineAARasterizer(outlineRenderer); rasterizer.LineJoin = (RenderAccurateJoins ? OutlineAARasterizer.OutlineJoin.AccurateJoin : OutlineAARasterizer.OutlineJoin.Round); rasterizer.RoundCap = true; //lionShape.ApplyTransform(affTx); //---------------------------- using (VgPaintArgsPool.Borrow(aggPainter, out VgPaintArgs paintArgs)) { paintArgs._currentTx = affTx; paintArgs.PaintVisitHandler = (vxs, painterA) => { //use external painter handler //draw only outline with its fill-color. rasterizer.RenderVertexSnap( vxs, painterA.P.FillColor); }; _spriteShape.Paint(paintArgs); } //---------------------------- //lionShape.ResetTransform(); } } }
VgVisualElement CreatePolyline(VgVisualElement parentNode, SvgPolylineSpec polylineSpec) { VgVisualElement vgPolyline = new VgVisualElement(WellknownSvgElementName.Polyline, polylineSpec, _vgVisualDoc); PointF[] points = polylineSpec.Points; int j = points.Length; if (j > 1) { using (VxsTemp.Borrow(out var v1)) { PointF p = points[0]; v1.AddMoveTo(p.X, p.Y); for (int i = 1; i < j; ++i) { p = points[i]; v1.AddLineTo(p.X, p.Y); } vgPolyline.VxsPath = v1.CreateTrim(); } AssignAttributes(polylineSpec); //-------------------------------------------------------------------- ResolveMarkers(vgPolyline, polylineSpec); if (vgPolyline._pathMarkers != null) { //create primary instance plan for this polyline VgPathVisualMarkers pathMarkers = vgPolyline._pathMarkers; pathMarkers.AllPoints = points; //start, mid, end if (pathMarkers.StartMarker != null) { //turn marker to the start direction PointF p0 = points[0]; PointF p1 = points[1]; //find rotation angle double rotateRad = Math.Atan2(p0.Y - p1.Y, p0.X - p1.X); SvgMarkerSpec markerSpec = (SvgMarkerSpec)pathMarkers.StartMarker._visualSpec; //create local-transformation matrix pathMarkers.StartMarkerPos = new PointF(p0.X, p0.Y); pathMarkers.StartMarkerAffine = Affine.NewMatix( AffinePlan.Translate(-markerSpec.RefX.Number, -markerSpec.RefY.Number), //move to the ref point AffinePlan.Rotate(rotateRad) //rotate ); } //------------------------------- if (pathMarkers.MidMarker != null) { SvgMarkerSpec markerSpec = (SvgMarkerSpec)pathMarkers.StartMarker._visualSpec; pathMarkers.MidMarkerAffine = Affine.NewTranslation(-markerSpec.RefX.Number, -markerSpec.RefY.Number); } //------------------------------- if (pathMarkers.EndMarker != null) { //turn marker to the start direction PointF p0 = points[j - 2]; //before the last one PointF p1 = points[j - 1]; //the last one //find rotation angle double rotateRad = Math.Atan2(p1.Y - p0.Y, p1.X - p0.X); SvgMarkerSpec markerSpec = (SvgMarkerSpec)pathMarkers.EndMarker._visualSpec; //create local-transformation matrix pathMarkers.EndMarkerPos = new PointF(p1.X, p1.Y); pathMarkers.EndMarkerAffine = Affine.NewMatix( AffinePlan.Translate(-markerSpec.RefX.Number, -markerSpec.RefY.Number), //move to the ref point AffinePlan.Rotate(rotateRad) //rotate ); } } } return(vgPolyline); }
public override void OnDraw(Graphics2D graphics2D) { //freeze to bitmap ? if (vxStorage == null) { var transform = Affine.NewMatix( AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y), AffinePlan.Scale(spriteScale, spriteScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(Width / 2, Height / 2) ); //convert //System.Collections.Generic.List<VertexData> list = new System.Collections.Generic.List<VertexData>(); vxStorage = transform.TransformToVxs(lionShape.Path.Vxs); //transformedPathStorage = new VertexSourceApplyTransform(lionShape.Path, transform); //transformedPathStorage.DoTransform(list); //vxStorage = new VertexStorage(list); } //----------------------------------------------------------------------------------- { int j = lionShape.NumPaths; int[] pathList = lionShape.PathIndexList; ColorRGBA[] colors = lionShape.Colors; for (int i = 0; i < j; ++i) { graphics2D.Render(new VertexStoreSnap(vxStorage, pathList[i]), colors[i]); } } //----------------------------------------------------------------------------------- if (!IsFreezed) { //var destImage = graphics2D.DestImage; //var buffer = destImage.GetBuffer(); //var w = destImage.Width; //var h = destImage.Height; ////snap to bmp //System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(w, h); //BitmapHelper.CopyToWindowsBitmap(buffer, 0, // destImage.StrideInBytes(), // destImage.Height, // destImage.BitDepth, // bmp, new RectangleInt(0, 0, w, h)); //bmp.Save("d:\\WImageTest\\01.bmp"); //this.Freeze(); //var bmpData = bmp.LockBits(new System.Drawing.Rectangle(0, 0, w, h), // System.Drawing.Imaging.ImageLockMode.ReadWrite, // System.Drawing.Imaging.PixelFormat.Format32bppArgb); } base.OnDraw(graphics2D); }
public override void Draw(Painter p) { if (UseBitmapExt) { p.RenderQuality = RenderQualtity.Fast; } else { p.RenderQuality = RenderQualtity.HighQuality; } p.Clear(Drawing.Color.White); p.UseSubPixelLcdEffect = false; //string teststr = "ABCDE pqyt 1230"; //p.FillColor = Color.Black; //p.CurrentFont = new RequestFont("tahoma", 10); //p.StrokeColor = Color.Red; p.RenderQuality = RenderQualtity.Fast; // //---red reference line-- p.DrawLine(0, 400, 800, 400); p.DrawLine(0, 400, 800, 500); //test oblique line //p.DrawString(teststr, 300, 400); // p.DrawRect(0.5, 400, 40, 40); // p.FillColor = Color.Yellow; p.StrokeColor = Color.Blue; p.FillEllipse(100.5, 400, 40, 60); p.DrawEllipse(50.5, 400, 40, 60); //---red reference line-- p.StrokeColor = Color.Red; p.DrawLine(0, 500, 800, 500); p.StrokeColor = Color.Blue; p.FillColor = Color.Yellow; p.FillRect(0.5, 500, 40, 40); //---red reference line-- //p.DrawImage(lionImg, 0, 0); //reference at 0,0 p.DrawImage(lionImg, 300, 0); int _imgW = lionImg.Width; int _imgH = lionImg.Height; p.RenderQuality = RenderQualtity.Fast; p.DrawImage(lionImg, //move to center of the image (hotspot x,y) AffinePlan.Translate(-_imgW / 2, -_imgH / 2), AffinePlan.Rotate(AggMath.deg2rad(45)), AffinePlan.Scale(0.75, 0.75), //move to target AffinePlan.Translate(400, 200)); }
public override void Draw(Painter p) { if (UseBitmapExt) { p.RenderQuality = RenderQualtity.Fast; } else { p.RenderQuality = RenderQualtity.HighQuality; } int width = 800; int height = 600; //clear the image to white // draw a circle p.Clear(Drawing.Color.White); Ellipse ellipseVxsGen = new Ellipse(0, 0, 100, 50); for (double angleDegrees = 0; angleDegrees < 180; angleDegrees += 22.5) { var mat = Affine.NewMatix( AffinePlan.Rotate(MathHelper.DegreesToRadians(angleDegrees)), AffinePlan.Translate(width / 2, 150)); VectorToolBox.GetFreeVxs(out var v1, out var v2, out var v3); mat.TransformToVxs(ellipseVxsGen.MakeVxs(v1), v2); p.FillColor = Drawing.Color.Yellow; p.Fill(v2); //------------------------------------ //g.Render(sp1, ColorRGBA.Yellow); //Stroke ellipseOutline = new Stroke(sp1, 3); p.FillColor = Drawing.Color.Blue; stroke.Width = 3; p.Fill(stroke.MakeVxs(v2, v3)); //g.Render(StrokeHelp.MakeVxs(sp1, 3), ColorRGBA.Blue); VectorToolBox.ReleaseVxs(ref v1, ref v2, ref v3); } // and a little polygon PathWriter littlePoly = new PathWriter(); littlePoly.MoveTo(50, 50); littlePoly.LineTo(150, 50); littlePoly.LineTo(200, 200); littlePoly.LineTo(50, 150); littlePoly.LineTo(50, 50); p.FillColor = Drawing.Color.Blue; p.Fill(littlePoly.MakeVertexSnap()); //---- //test draw img // //g.Render(littlePoly.MakeVertexSnap(), ColorRGBA.Cyan); // draw some text // draw some text //var textPrinter = new TextPrinter(); //textPrinter.CurrentActualFont = svgFontStore.LoadFont(SvgFontStore.DEFAULT_SVG_FONTNAME, 30); //new TypeFacePrinter("Printing from a printer", 30, justification: Justification.Center); //VertexStore vxs = textPrinter.CreateVxs("Printing from a printer".ToCharArray()); //var affTx = Affine.NewTranslation(width / 2, height / 4 * 3); //VertexStore s1 = affTx.TransformToVxs(vxs); //p.FillColor = Drawing.Color.Black; //p.Fill(s1); ////g.Render(s1, ColorRGBA.Black); //p.FillColor = Drawing.Color.Red; //p.Fill(StrokeHelp.MakeVxs(s1, 1)); ////g.Render(StrokeHelp.MakeVxs(s1, 1), ColorRGBA.Red); //var aff2 = Affine.NewMatix( // AffinePlan.Rotate(MathHelper.DegreesToRadians(90)), // AffinePlan.Translate(40, height / 2)); //p.FillColor = Drawing.Color.Black; //p.Fill(aff2.TransformToVertexSnap(vxs)); ////g.Render(aff2.TransformToVertexSnap(vxs), ColorRGBA.Black); }
public override void Draw(PixelFarm.Drawing.Painter p) { int strokeWidth = 1; int width = p.Width; int height = p.Height; Affine affTx = Affine.NewMatix( AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y), AffinePlan.Scale(spriteScale, spriteScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(width / 2, height / 2)); var p1 = p as AggPainter; if (p1 == null) { //TODO: review here lionShape.Paint(p, affTx); //int j = lionShape.NumPaths; //int[] pathList = lionShape.PathIndexList; //Drawing.Color[] colors = lionShape.Colors; ////graphics2D.UseSubPixelRendering = true; //var vxs = GetFreeVxs(); //affTx.TransformToVxs(lionShape.Vxs, vxs); //p.StrokeWidth = 1; //for (int i = 0; i < j; ++i) //{ // p.StrokeColor = colors[i]; // p.Draw(new PixelFarm.Drawing.VertexStoreSnap(vxs, pathList[i])); //} ////not agg //Release(ref vxs); //return; //** } if (UseBitmapExt) { p.RenderQuality = Drawing.RenderQualtity.Fast; p.Clear(Drawing.Color.White); p.StrokeWidth = 1; //------------------------- lionShape.DrawOutline(p); } else { p.RenderQuality = Drawing.RenderQualtity.HighQuality; } //----------------------- AggRenderSurface aggsx = p1.RenderSurface; //var widgetsSubImage = ImageHelper.CreateChildImage(graphics2D.DestImage, graphics2D.GetClippingRect()); //int width = widgetsSubImage.Width; //int height = widgetsSubImage.Height; SubImageRW widgetsSubImage = ImageHelper.CreateSubImgRW(aggsx.DestImage, aggsx.GetClippingRect()); SubImageRW clippedSubImage = new SubImageRW(widgetsSubImage, new PixelBlenderBGRA()); ClipProxyImage imageClippingProxy = new ClipProxyImage(clippedSubImage); imageClippingProxy.Clear(PixelFarm.Drawing.Color.White); if (RenderAsScanline) { ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer; rasterizer.SetClipBox(0, 0, width, height); //Stroke stroke = new Stroke(strokeWidth); //stroke.LineJoin = LineJoin.Round; lionShape.ApplyTransform(affTx); DrawAsScanline(imageClippingProxy, aggsx, rasterizer, aggsx.ScanlineRasToDestBitmap); lionShape.ResetTransform(); } else { //LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(strokeWidth * affTx.GetScale(), new GammaNone()); LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(strokeWidth * affTx.GetScale(), null); OutlineRenderer outlineRenderer = new OutlineRenderer(imageClippingProxy, new PixelBlenderBGRA(), lineProfile); OutlineAARasterizer rasterizer = new OutlineAARasterizer(outlineRenderer); rasterizer.LineJoin = (RenderAccurateJoins ? OutlineAARasterizer.OutlineJoin.AccurateJoin : OutlineAARasterizer.OutlineJoin.Round); rasterizer.RoundCap = true; SvgRenderVx renderVx = lionShape.GetRenderVx(); lionShape.ApplyTransform(affTx); DrawWithLineProfile(rasterizer); lionShape.ResetTransform(); } base.Draw(p); }
public override void Draw(Painter p) { if (UseBitmapExt) { p.RenderQuality = RenderQuality.Fast; } else { p.RenderQuality = RenderQuality.HighQuality; } p.Clear(Drawing.Color.Yellow); p.UseSubPixelLcdEffect = false; // //---red reference line-- p.StrokeColor = Color.Black; p.DrawLine(0, 400, 800, 400); //draw reference line p.DrawImage(_lionImg, 300, 0); int _imgW = _lionImg.Width; int _imgH = _lionImg.Height; int x_pos = 0; for (int i = 0; i < 360; i += 30) { p.DrawImage(_lionImg, //move to center of the image (hotspot x,y) AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f), AffinePlan.Scale(0.50, 0.50), AffinePlan.Rotate(AggMath.deg2rad(i)), AffinePlan.Translate((_imgW / 2f) + x_pos, _imgH / 2f) //translate back ); x_pos += _imgW / 3; } using (VxsTemp.Borrow(out var vxs1, out var vxs2)) { SimpleRect sRect = new SimpleRect(); int x = 0, y = 0, w = 100, h = 100; sRect.SetRect(x, y, x + w, y + h); sRect.MakeVxs(vxs1); p.Fill(vxs1, Color.Blue); //------------------- Affine af = Affine.NewMatix( AffinePlan.Translate(-w / 2f, -h / 2f), AffinePlan.Rotate(AggMath.deg2rad(30)), AffinePlan.Translate(w / 2f, h / 2f) ); af.TransformToVxs(vxs1, vxs2); p.Fill(vxs2, Color.Red); //------------------- } }
public override void Draw(Painter p) { if (UseBitmapExt) { p.RenderQuality = RenderQuality.Fast; } else { p.RenderQuality = RenderQuality.HighQuality; } p.Clear(Drawing.Color.White); p.UseSubPixelLcdEffect = false; //---red reference line-- p.StrokeColor = Color.Black; p.DrawLine(0, 400, 800, 400); //draw reference line p.DrawImage(_lionImg, 300, 0); //p.DrawImage(lionImg, 0, 0, 10, 10, 100, 100); // //p.DrawImage(halfLion, 50, 0); int _imgW = _lionImg.Width; int _imgH = _lionImg.Height; int x_pos = 0; int y_pos = 0; var affPlans = new AffinePlan[4]; //1. create new half-size lion image //for (int i = 0; i < 360; i += 30) //{ // affPlans[0] = AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f); // affPlans[1] = AffinePlan.Scale(1, 1); // affPlans[2] = AffinePlan.Rotate(AggMath.deg2rad(i)); // affPlans[3] = AffinePlan.Translate((_imgW / 2f) + x_pos, (_imgH / 2f) + y_pos); // p.DrawImage(halfLion, affPlans); // x_pos += _imgW / 3; //} x_pos = 0; y_pos = 100; for (int i = 0; i < 360; i += 30) { affPlans[0] = AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f); affPlans[1] = AffinePlan.Scale(0.50, 0.50); affPlans[2] = AffinePlan.Rotate(AggMath.deg2rad(i)); affPlans[3] = AffinePlan.Translate((_imgW / 2f) + x_pos, (_imgH / 2f) + y_pos); p.DrawImage(_lionImg, affPlans); x_pos += _imgW / 3; } //---- // using (VxsTemp.Borrow(out var vxs1, out var vxs2)) { SimpleRect sRect = new SimpleRect(); int x = 0, y = 0, w = 100, h = 100; sRect.SetRect(x, y, x + w, y + h); sRect.MakeVxs(vxs1); p.Fill(vxs1, Color.Blue); //------------------- Affine af = Affine.NewMatix( AffinePlan.Translate(-w / 2f, -h / 2f), AffinePlan.Rotate(AggMath.deg2rad(30)), AffinePlan.Translate(w / 2f, h / 2f) ); af.TransformToVxs(vxs1, vxs2); p.Fill(vxs2, Color.Red); } }
public override void Draw(PixelFarm.Drawing.Painter p) { if (recreatePathAgain) { recreatePathAgain = false; var transform = Affine.NewMatix( AffinePlan.Translate(-_spriteShape.Center.x, -_spriteShape.Center.y), AffinePlan.Scale(spriteScale, spriteScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(Width / 2, Height / 2) ); //create vertextStore again from original path //temp fix SvgRenderVx renderVx = _spriteShape.GetRenderVx(); int count = renderVx.SvgVxCount; for (int i = 0; i < count; ++i) { SvgPart vx = renderVx.GetInnerVx(i); if (vx.Kind != SvgRenderVxKind.Path) { continue; } //Temp fix, //TODO: review here, //permanent transform each part? //or create a copy. vx.RestoreOrg(); VertexStore vxvxs = vx.GetVxs(); VertexStore newVxs = new VertexStore(); transform.TransformToVxs(vxvxs, newVxs); vx.SetVxs(newVxs); } _spriteShape.UpdateBounds(); //if (AutoFlipY) //{ // //flip the lion // PixelFarm.Agg.Transform.Affine aff = PixelFarm.Agg.Transform.Affine.NewMatix( // PixelFarm.Agg.Transform.AffinePlan.Scale(-1, -1), // PixelFarm.Agg.Transform.AffinePlan.Translate(0, 600)); // // // var v2 = new VertexStore(); // myvxs = transform.TransformToVxs(myvxs, v2); //} } //--------------------------------------------------------------------------------------------- { float ox = p.OriginX; float oy = p.OriginY; p.SetOrigin(ox + _posX, oy + _posY); _spriteShape.Paint(p); //#if DEBUG // RectD bounds = lionShape.Bounds; // bounds.Offset(_posX, _posY); // //draw lion bounds // var savedStrokeColor = p.StrokeColor; // var savedFillColor = p.FillColor; // var savedSmoothMode = p.SmoothingMode; // p.SmoothingMode = SmoothingMode.HighSpeed; // p.StrokeColor = Color.Black; // p.DrawRect(bounds.Left, bounds.Top - bounds.Height, bounds.Width, bounds.Height); // p.StrokeColor = Color.Red; // p.DrawRect(_mouseDownX, _mouseDownY, 4, 4); // //restore // p.SmoothingMode = savedSmoothMode; // p.StrokeColor = savedStrokeColor; // p.FillColor = savedFillColor; //#endif p.SetOrigin(ox, oy); //int j = lionShape.NumPaths; //int[] pathList = lionShape.PathIndexList; //Drawing.Color[] colors = lionShape.Colors; ////graphics2D.UseSubPixelRendering = true; //for (int i = 0; i < j; ++i) //{ // p.FillColor = colors[i]; // p.Fill(new VertexStoreSnap(myvxs, pathList[i])); //} } //test if (SharpenRadius > 0) { //p.DoFilter(new RectInt(0, p.Height, p.Width, 0), 2); //PixelFarm.Agg.Imaging.SharpenFilterARGB.Sharpen() } }
public override void OnDraw(Graphics2D graphics2D) { //render var widgetsSubImage = ImageHelper.CreateChildImage(graphics2D.DestImage, graphics2D.GetClippingRect()); int width = widgetsSubImage.Width; int height = widgetsSubImage.Height; int strokeWidth = 1; var clippedSubImage = new ChildImage(widgetsSubImage, new PixelBlenderBGRA()); ClipProxyImage imageClippingProxy = new ClipProxyImage(clippedSubImage); imageClippingProxy.Clear(ColorRGBA.White); Affine affTx = Affine.NewMatix( AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y), AffinePlan.Scale(spriteScale, spriteScale), AffinePlan.Rotate(angle + Math.PI), AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0), AffinePlan.Translate(width / 2, height / 2)); //transform *= Affine.NewTranslation(-lionShape.Center.x, -lionShape.Center.y); //transform *= Affine.NewScaling(spriteScale, spriteScale); //transform *= Affine.NewRotation(angle + Math.PI); //transform *= Affine.NewSkewing(skewX / 1000.0, skewY / 1000.0); //transform *= Affine.NewTranslation(width / 2, height / 2); if (RenderAsScanline) { var rasterizer = graphics2D.ScanlineRasterizer; rasterizer.SetClipBox(0, 0, width, height); Stroke stroke = new Stroke(strokeWidth); stroke.LineJoin = LineJoin.Round; var vxs = affTx.TransformToVxs(lionShape.Path.Vxs); ScanlineRasToDestBitmapRenderer sclineRasToBmp = graphics2D.ScanlineRasToDestBitmap; sclineRasToBmp.RenderSolidAllPaths( imageClippingProxy, rasterizer, graphics2D.ScanlinePacked8, vxs, lionShape.Colors, lionShape.PathIndexList, lionShape.NumPaths); } else { double w = strokeWidth * affTx.GetScale(); LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(w, new GammaNone()); OutlineRenderer outlineRenderer = new OutlineRenderer(imageClippingProxy, new PixelBlenderBGRA(), lineProfile); OutlineAARasterizer rasterizer = new OutlineAARasterizer(outlineRenderer); rasterizer.LineJoin = (RenderAccurateJoins ? OutlineAARasterizer.OutlineJoin.AccurateJoin : OutlineAARasterizer.OutlineJoin.Round); rasterizer.RoundCap = true; //VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform); var vxs = affTx.TransformToVxs(lionShape.Path.Vxs);// trans.DoTransformToNewVxStorage(); int j = lionShape.NumPaths; for (int i = 0; i < j; ++i) { rasterizer.RenderVertexSnap( new VertexStoreSnap(vxs, lionShape.PathIndexList[i]), lionShape.Colors[i]); } } base.OnDraw(graphics2D); }