Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiFiremonkeyIOS

Perfect Line Thickness Using TCanvas DrawLine With Delphi XE5 Firemonkey On Android And IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Dlphi XE5 Firemonkey Clean Lines | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSIf you’re using Delphi XE5 Firemonkey to do any kind of drawing on TCanvas with DrawLine you may have run into this issue. The problem is that when you draw a one pixel line what you end up with doesn’t appear as a one pixel line. I believe this issue exists on both Android and IOS. Roman Yankovsky has a blog post demonstrating the problem and showing the solution. Here is an example of DrawLine where the problem manifests:

Canvas.DrawLine(PointF(50 + I * 25, 0), PointF(50 + I * 25, ClientHeight), 1);

And here is the an example of DrawLine with the extra code that fixes the problem:

Canvas.DrawLine(PointF(50 + I * 25 – (Canvas.Stroke.Thickness / 2), 0),
PointF(50 + I * 25 – (Canvas.Stroke.Thickness / 2), ClientHeight), 1);

Roman has much more comprehensive example code on his blog and even a second method for correcting the problem.

Head over to read the full blog post about correcting DrawLine on TCanvas.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLinuxOSXShowcaseWindows

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging

DelphiFiremonkeyShowcaseUtilityWindows

Unleashing Creativity With Song Writer AI: A Deep Dive

DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

Leave a Reply