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 ➜ Miniwindows ➜ Transparency issues.

Transparency issues.

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


Posted by Alca   (20 posts)  Bio
Date Fri 05 Feb 2010 03:14 PM (UTC)

Amended on Fri 05 Feb 2010 03:15 PM (UTC) by Alca

Message
Since I updated from v4.40 to v4.30, some of my plugins don't function as they should anymore.
More specifically, the WindowDrawImage() function is what keeps them from showing what I want them to show.

I use mode 3 (transparent copy) to make 'overlays'. I could -probably- do this with WindowDrawImageAlpha(), but my question is: why doesn't mode 3 work like it used to?

In case I coded something wrong, here's one of the plugins:


winid = world.GetPluginID
path = world.GetPluginInfo(winid, 20)

background_colour =  world.ColourNameToRGB("black")
start_colour =  world.ColourNameToRGB("darkslateblue")
end_colour = world.ColourNameToRGB("turquoise")

# Window size

win_height = 586
win_width = 37

# Initial Gauge Height (when XP = 0)

gauge_height = 535

# Gauge Length = 535 - 50 = 485

def OnPluginBroadcast(msg, id, name, text):

    if id == "65b2f9550e9da2d141111e74":
        if msg == 300:
            ComputeGaugeHeight(text)

    return 0

def ComputeGaugeHeight(text):

    global gauge_height

    text_list = text.split('!')

    XP_current = float(text_list[6])
    XP_needed = float(text_list[7])
    XP_ratio = XP_current/XP_needed

    gauge_height = int(535 - (485*XP_ratio))

    DrawGauge()


def OnPluginInstall():

    world.WindowCreate(winid, 0, 0, win_width, win_height, 6, 4, background_colour)

    world.WindowLoadImage(winid, "xp_bar", path+"xp_bar.png")

    DrawGauge()

    world.WindowShow(winid, True)

def DrawGauge():

    world.WindowRectOp(winid, 2, 0, 0, win_width, win_height, background_colour, background_colour)

    world.WindowGradient(winid, 13, gauge_height, 18, win_height, start_colour, end_colour, 1)
    world.WindowGradient(winid, 18, gauge_height, 24, win_height, end_colour, start_colour, 1)

    world.WindowDrawImage(winid, "xp_bar", 0, 0, win_width, win_height, 3, 0, 0, 0, 0)

    world.WindowShow(winid, True)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 05 Feb 2010 07:03 PM (UTC)
Message
I think I would need to see your image file (xp_bar.png) - the spec says that the pixel at 0, 0 is the transparent pixel. Are you sure that that pixel is the one which is, elsewhere, the one you should be seeing through?

Meanwhile, using transparency (alpha channel) in the image lets you have more control, and you could fade the transparency out rather than having it on or off.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 05 Feb 2010 09:30 PM (UTC)
Message
Alca said:

Since I updated from v4.40 to v4.30, some of my plugins don't function as they should anymore.


Is this a typo? Sounds like a downgrade, if you moved from 4.40 to 4.30.

Try 4.47 available from:

http://www.gammon.com.au/forum/?id=10044

- Nick Gammon

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

Posted by Alca   (20 posts)  Bio
Date Reply #3 on Mon 08 Feb 2010 09:07 AM (UTC)
Message
Link to the png: http://i254.photobucket.com/albums/hh92/Ferusian/xp_bar.png

It is indeed a typo. I'm currently at version 4.43

The plugin worked before, so I always thought my offset and such was right. I've tried and fooled around with it, but it didn't work. Using a bigger black area (as to be sure I got the pixel I need) doesn't work, nor does changing the offset by one pixel. I tried simple pngs to test if it was just a wrong sort of 'black', but that didn't fix it either.

Using the alpha channel is easier and better, and I'll use it from now on, but I'm still wondering why my previous solution doesn't work anymore.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #4 on Mon 08 Feb 2010 07:38 PM (UTC)
Message
After extensive investigation it seems that the problem is the choice of black as the transparency colour. Basically the transparency works by turning your original image into a mask, where black is transparent and white not (or vice-versa). However by using black as the transparent colour it throws all that out.

I'll amend the documentation to recommend not using black or white as the transparent colour.

- Nick Gammon

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

Posted by Alca   (20 posts)  Bio
Date Reply #5 on Tue 09 Feb 2010 06:46 AM (UTC)
Message
Thanks for clearing that up for me!


Also, I'm really, really, really relieved I didn't make an incredibly obvious mistake again.
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.


17,484 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.