Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Bug reports ➜ gauge.lua bugs

gauge.lua bugs

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Fiendish   USA  (2,551 posts)  Bio   Global Moderator
Date Sun 21 Nov 2010 04:17 AM (UTC)

Amended on Sun 21 Nov 2010 04:18 AM (UTC) by Fiendish

Message
gauge.lua draws the bar wider than the border
So
local gauge_width = width * Fraction

should be
local gauge_width = (width-2) * Fraction


Also, the hotspots don't get redone if the miniwindow is resized and the gauges are redrawn in different places.
So

-- mouse-over information: add hotspot if not there
if not WindowHotspotInfo(win, name, 1) then
   WindowAddHotspot (win, name, left, top, left + width, top + height, "", "", "", "", "", "", 0, 0)
end -- if

should just be

-- mouse-over information: add hotspot
WindowAddHotspot (win, name, left, top, left + width, top + height,"", "", "", "", "", "", 0, 0)

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Fiendish   USA  (2,551 posts)  Bio   Global Moderator
Date Reply #1 on Sun 21 Nov 2010 04:35 AM (UTC)

Amended on Sun 21 Nov 2010 04:36 AM (UTC) by Fiendish

Message
Also, the gradient content is off by a pixel, so I think that

-- top half
WindowGradient (win, left, top, 
            left + gauge_width, top + height / 2, 
            0x000000, -- black
            fg_colour, 2)  -- vertical top to bottom

should be

-- top half
WindowGradient (win, left, top-1, 
            left + gauge_width, top + height / 2, 
            0x000000, -- black
            fg_colour, 2)  -- vertical top to bottom

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 21 Nov 2010 04:41 AM (UTC)
Message
Fixed in version 4.71, thanks!

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,551 posts)  Bio   Global Moderator
Date Reply #3 on Mon 13 Dec 2010 02:38 PM (UTC)
Message
I don't see a change to the top half windowgradient in 4.71's version

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #4 on Mon 13 Dec 2010 09:18 PM (UTC)
Message
It doesn't seem off by 1 to me.



Code to reproduce:


win = "test"

WindowCreate (win , 
  0, -- left
  0, -- top
  200, -- width
  200, -- height
  miniwin.pos_top_left, -- mode
  0, -- flags
  ColourNameToRGB ("navajowhite"))

 WindowRectOp (win, miniwin.rect_frame, 10, 10, 50, 50, ColourNameToRGB ("red"))
 

 WindowGradient (win, 10, 10, 50, 50, 
                    ColourNameToRGB ("green"),
                    ColourNameToRGB ("blue"), 2)


 WindowRectOp (win, miniwin.rect_frame, 10, 10, 50, 50, ColourNameToRGB ("cyan"))
 

require "gauge"

gauge (win,    
        "hp",                  
        50, 100,              
        10, 60, 40, 20,  
        ColourNameToRGB ("green"), 
        ColourNameToRGB ("red"),       
        0, 0x000000,       
        ColourNameToRGB ("cyan"),           
        nil)             

 WindowShow (win  , true)



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #5 on Tue 14 Dec 2010 03:06 AM (UTC)
Message
I did another test with a 10 x 10 gauge (rest of the above code the same), that is:


gauge (win,    
        "hp",                  
        50, 100,              
        10, 60, 10, 10,  
...


Then zooming in with Photoshop, I see this:



The box is exactly 10 x 10 pixels (one pixel border, 8 pixels in the middle for the gradient). There doesn't seem to be any rogue pixels in there. The gradient is a bit different on the bottom to the top, but I put that down to rounding errors when generating the colours for each line.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #6 on Tue 14 Dec 2010 05:42 AM (UTC)

Amended on Tue 14 Dec 2010 05:44 AM (UTC) by Nick Gammon

Message
Well now, the fascinating thing about this is, assuming you are complaining about the slightly off-center band in the middle, if you change to the older behaviour (and not use the GradientFill function that Twisol suggested) then the thing is more symmetrical:



In fact, if I comment out the second WindowGradient, I get the first five bars of gradient, starting at G=0 (hidden by the border), G=25, G=51, G=76, and G=102. But not G=128 which is the end-point. So it seems to me that GradientFill, although requested to draw from black to G=128, is not in fact doing that.

However when "manually" doing it, my figures are:

G=0, G=32, G=64, G=96, G=128.

So just to explain, when calculating the gradient intermediate values, I divided the difference by the number of bars minus one. So, 128 / 4 = 32. So I added 32 to the green value for each change (there are four changes, not five), so my calculations give me the requested range.

The Windows programmers seem to have taken the number of bars as the divisor (128 / 5 = 25.6). Thus the increment of about 25 for each bar. But this is wrong because you don't get the end-point colour.

Now since this calculation is an internal one in the way GradientFill is implemented, I'm not sure I can fix it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,551 posts)  Bio   Global Moderator
Date Reply #7 on Tue 14 Dec 2010 06:11 PM (UTC)
Message
Quote:
The gradient is a bit different on the bottom to the top, but I put that down to rounding errors when generating the colours for each line.
Yeah, this is what I meant. It seems, at least in the cause of the gauge.lua use case, that starting one pixel earlier hid the problem for me. Perhaps not a general solution for drawing all gradients, especially if you don't have a border to hide it behind, but at least for the gauge bars it seemed to work out visually.

https://github.com/fiendish/aardwolfclientpackage
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


20,280 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.