Description of the original:
Before using obj-c to develop IOS App, using geometry drawing is the norm, the quality is better no words, because of cross-platform requirements, to Delphi Firemonkey to develop, its cross-platform capability is satisfied (a code and interface can easily cross four platforms), But the mobile platform in the geometry of the graphics, the quality is always unsatisfactory, I have tried to fix (such as: correction curve smoothing problem), also looked for the third program (such as: Aggpas), but always not perfect, I have been thinking, mobile platform has such a strong ability and quality of drawing, if you can directly take to use, not very good? Why Firemonkey to rewrite itself (mobile platform segment processing compute unit in FMX. Strokebuilder.pas is interested in doing his own research, quality problems may be out here?! )?
Practical methods:
Everyone likes simple, if you can not change the original drawing code, just add a few lines of code, or compile the switch, that is the ideal, based on this concept, made the current native mapping scheme:
procedureTform1.paintbox1paint (sender:tobject; Canvas:tcanvas);varRect, DESRECT:TRECTF;beginRect:=Paintbox1.localrect; Canvas.Stroke.Thickness:=Ten; Canvas.Stroke.Kind:=Tbrushkind.solid; Canvas.Stroke.Dash:=Tstrokedash.dashdotdot; //Distance ShapeDesrect: =Rect; Inflaterect (Desrect,-(Canvas.Stroke.Thickness/2),-(Canvas.Stroke.Thickness/2));//line in the areaCanvas.fillrect (Desrect, -, -, Allcorners,1); Canvas.drawrect (Desrect, -, -, Allcorners,1);End;
Description |
Android |
Ios |
Windows |
MacOS |
The above code, using the FMX plotting method (mobile platform is problematic) |
|
|
|
|
The following code, using the native drawing method (All four platforms are the same) |
|
|
|
|
The following changes to the native mapping scheme, as long as the original maximum speed diagram code before adding two lines of code (the original drawing code does not change, but in some cases not necessarily):
{$i Nativedraw.inc}usesFMX. Graphics.native,procedure Tform1.paintbox1paint (sender:tobject; Canvas:tcanvas); var rect, desrect:trectf;begin rect: = Paintbox1.localrect; Canvas.Stroke.Thickness: = 10; Canvas.Stroke.Kind: = Tbrushkind.solid; Canvas.Stroke.Dash: = Tstrokedash.dashdotdot; {$IFDEF Usenativedraw}Canvas.nativedraw (Rect{Note: Do not change it in the name function},procedure begin {$ENDIF} //native Drawing by Aone, the name of the function added to the drawing method, the interior will be drawn first to Bitmap//Distance shape desrect: = Rect; Inflaterect (Desrect,-(CANVAS.STROKE.THICKNESS/2),-(CANVAS.STROKE.THICKNESS/2)); Line in the area canvas.fillrect (Desrect, 1, Allcorners, (); Canvas.drawrect (Desrect, allcorners, 1); {$IFDEF Usenativedraw}End);{$ENDIF} //native Drawing by Aone, this Bitmap will be displayed after the endend;
Principle of implementation:
- Its principle is very simple, is to first configure a native drawing area Bitmap, and then draw the geometry in this area, and finally the content in this area, back to Tbitmap, and then display in the Canvas
- This approach is only a workaround and is recommended for high-quality drawings that do not affect the overall performance of the program
The Canvas function has been implemented:
DrawLine |
Draw Line |
FillRect |
Round spacing Zone |
DrawRect |
Round pitch border |
FillPath |
Path area |
DrawPath |
Path Frame Line |
FillEllipse |
Oval Area |
DrawEllipse |
Oval Frame Line |
Fillarc |
Lone Line Area |
DrawArc |
Lone Frame Line |
FillPolygon |
Polygon Area |
DrawPolygon |
Polygon Frame Lines |
IntersectClipRect |
Intersect clipping area |
Excludecliprect |
Other trim areas |
Paint and Line Color brushes:
- Support for fade-layer coloring
- Bitmap coloring is not supported
Known Issues:
- Unfinished functions and features, we welcome you to improve
- Real IOS 64bit Unable to display dashed line (virtual machine no problem) (for unknown reason, TMS ICL control also has this problem)
- Geometry drawing only issues on mobile platforms Android & IOS, Windows & MacOS No problem
Resources:
- https://sourceforge.net/projects/dpfdelphiios/
- https://sourceforge.net/projects/alcinoe/
- http://www.applyingcode.com/
Source Download:(expected after years of sharing)
Original Firemonkey solving Canvas Geometry drawing quality issues (mobile platform)