Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / rounding problems with DrawLine

Author
Message
hectic
7
Years of Service
User Offline
Joined: 19th Feb 2017
Location:
Posted: 8th Apr 2017 18:12 Edited at: 9th Apr 2017 16:18
edit > sorry, wrong Forum. please move to AGK2 < edit

The command DrawLine produces erroneous representation (rounding error?):





System: Lubuntu LXDE (based on Ubuntu 16.10)
Kernel: Linux 4.8.0-45-generic (x86_64)
Processor: Intel Core i7-4790K @ 4.00 GHz
Mainboard: Asus Maximus VII Gene
Grafik: OnBoard
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 8th Apr 2017 22:07
Seems to have landed in the wrong forum. Maybe a moderator can move it to the AppGameKit forums
PSY LABS Games
Coders don't die, they just gosub without return
hectic
7
Years of Service
User Offline
Joined: 19th Feb 2017
Location:
Posted: 12th Apr 2017 15:49
Thanks for the fixes (V2017.4.11)

Unfortunately has now a new error





Here an more accurate error analysis



PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 15th Apr 2017 18:26
is there also a problem with DrawEllipse, I can not seem to draw a perfect circle, its always wider to the left with same x,y radius, Im trying to draw a simple radio button and such a simple task has proven to be not so simple!
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 16th Apr 2017 00:34
You could try using floats (in your constant values)

so..

drawline( 50.0+cos(count)*30.0,50.0+sin(count)*30.0, 50.0+cos(count)*40.0,50.0+sin(count)*40.0, -1,-1 )

I got into the habit of doing that some time ago - could be it?

try debugging the values into a variable first:

x=50+cos(count)*30

vs

x=50.0+cos(count)*30.0

to see if it's more precise...

hectic
7
Years of Service
User Offline
Joined: 19th Feb 2017
Location:
Posted: 17th Apr 2017 07:29
PartTimeCoder
I have tested DrawEllipse and can confirm that a circle is not drawn correctly.

nz0
It's all the same. Have tried all the combinations. The second code (of: Posted: 12th Apr 2017 15:49) should only show how DrawLine drawing lines.

this:

result:
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 18th Apr 2017 15:34
I've attached what I see when I run your code in version 2017.04.11

Attachments

Login to view attachments
hectic
7
Years of Service
User Offline
Joined: 19th Feb 2017
Location:
Posted: 18th Apr 2017 16:55
ok thank you, then is this error only under linux.

System: Lubuntu LXDE (based on Ubuntu 16.10)
Kernel: Linux 4.8.0-45-generic (x86_64)
Processor: Intel Core i7-4790K @ 4.00 GHz
Mainboard: Asus Maximus VII Gene
Grafik: OnBoard

AppGameKit IDE 2017.04.11
A fast and lightweight IDE
Built on Geany 1.24.1
(built on 2017-04-11)
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 18th Apr 2017 19:03
Getting the same results as Paul with 2017.04.11
PSY LABS Games
Coders don't die, they just gosub without return
programming is ace
User Banned
Posted: 18th Apr 2017 19:07
Fine pixel drawing requires to be floats not integers

programming is ace
User Banned
Posted: 18th Apr 2017 19:21
A lot better precision for me


PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 18th Apr 2017 19:28 Edited at: 18th Apr 2017 19:33
count is a float, so he IS using floats ^^

50+cos(count)*30,50+sin(count)*30 = 2 floats
50+cos(count)*40,50+sin(count)*40 = 2 floats

Declaring dx and dy as float makes no sense, as all resolutions are always integer.
By using a float during a calculation, the result is also a float as long there is no type casting, and drawline( 50+cos(count)*30,50+sin(count)*30, 50+cos(count)*40,50+sin(count)*40, -1,-1 ) doesn't do any casting at all
PSY LABS Games
Coders don't die, they just gosub without return
programming is ace
User Banned
Posted: 18th Apr 2017 19:33
Oh yeah - didn't see that one.. Cheers

I would increase the step from 0.1 to a bit further 0.001 or something

0.1 makes it looks like there is spaces in the circle.. 0.001 makes it smoother

PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 18th Apr 2017 19:36
Seems to be a Linux issue
PSY LABS Games
Coders don't die, they just gosub without return
Ranietz
AGK Gold Backer
20
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 19th Apr 2017 02:32
Yeah. It seems to be a Linux issue.

I tried the following code on both Windows Vista and Linux Mint 18.1 and I attached the results.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-24 16:58:06
Your offset time is: 2024-11-24 16:58:06