For instance, this is the example code for LineXY():
Code: Select all
If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
Box(0, 0, 200, 200, RGB(255, 255, 255))
For Angle = 0 To 360 Step 3
LineXY(100, 100, 100+Cos(Radian(Angle))*90, 100+Sin(Radian(Angle))*90, RGB(Random(255), Random(255), Random(255)))
Next Angle
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
[ ] Enable DPI aware executable (Windows)
switched OFF, the result is fine:
But with that compiler option switched ON,
the result doesn't look as expected (DPI 125 %):
In order to make it look properly, we have to scale images and graphics functions by our own code.
Only windows and gadgets are scaled automatically by PureBasic.
So the code should be like this:
Code: Select all
If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateImage(0, DesktopScaledX(200), DesktopScaledY(200)) And StartDrawing(ImageOutput(0))
Box(0, 0, DesktopScaledX(200), DesktopScaledY(200), RGB(255, 255, 255))
For Angle = 0 To 360 Step 3
LineXY(DesktopScaledX(100), DesktopScaledY(100), DesktopScaledX(100+Cos(Radian(Angle))*90),
DesktopScaledY(100+Sin(Radian(Angle))*90), RGB(Random(255), Random(255), Random(255)))
Next Angle
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
[ ] Enable DPI aware executable (Windows)
is switched OFF or ON (PB 5.72 on Windows).