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 ➜ General ➜ Drew a sun, can't figure out how to remove outer black shadow

Drew a sun, can't figure out how to remove outer black shadow

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


Posted by Wuggly   USA  (112 posts)  Bio
Date Sat 07 May 2016 02:49 PM (UTC)
Message
Hello again,

Recently, I've tried drawing a Sun using this thread as a reference.
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=9303

However, I can't seem to figure out how to get rid of the black shadow around the outer edge of it.

I want to be able to keep the inner shadow part of it.

Reason I need it like this is because I have it transparent and it looks a bit funky with that shadow on the outer part.

I've tried quite a few things to fix this, but can't seem to figure it out. Or maybe I've been at this for too long and my brain is scrambled stuck thinking down one direction.


-- main result window
win5 = GetPluginID () .. ".5" 
WindowCreate (win5, 0, 0, 20, 20, 7, 4, 0x000000)  -- create window
 

-- gradient window
win6 = GetPluginID ()  .. ".6"
WindowCreate (win6, 0, 0, 20, 20, 7, 4, ColourNameToRGB("white"))  -- create window

WindowGradient (win6, 0, 0, 0, 0, 
                ColourNameToRGB ("yellow"), 
                ColourNameToRGB ("red"), 
                2)  -- top to bottom
				
-- mask window
win7 = GetPluginID ()  .. ".7"
WindowCreate (win7, 0, 0, 20, 20, 7, 4, ColourNameToRGB("black"))  -- create window


-- chord
WindowCircleOp (win7, 4, 0, 0, 20, 20, 
                ColourNameToRGB("black"), 5, 0,  -- no pen
                ColourNameToRGB("white"), 0,  -- brush
                0, 0)

-- convert to images
WindowImageFromWindow (win5, "gradient", win6)
WindowImageFromWindow (win5, "mask", win7)

-- do the merge
WindowMergeImageAlpha (win5, "gradient", "mask", 0, 1, 20, 20, 0, 1, 0, 0, 0, 0)

WindowFilter (win5, 0, 0, 0, 0, 3, 0) -- blur both directions
WindowShow (win5,  true)  -- show it
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 07 May 2016 09:02 PM (UTC)

Amended on Sat 07 May 2016 10:20 PM (UTC) by Nick Gammon

Message
I can't see what you mean. When I tried that code (my background is normally black) the sun looks fine.


- Nick Gammon

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

Posted by Wuggly   USA  (112 posts)  Bio
Date Reply #2 on Sat 07 May 2016 10:21 PM (UTC)

Amended on Sat 07 May 2016 10:33 PM (UTC) by Wuggly

Message
Yes, it looks fine on a black background, but I have an image for my background that is not a solid black. Here's a screenshot so you can see what I mean.

http://i.imgur.com/5ZdKcqx.png

It's a little squished in that as I was trying to cut off the outer shadow parts.

I'm thinking maybe make another mini-window with a circleop, inside being transparent, and just putting it over top of it, but I feel like there is a better way.

EDIT: Oh by the way, that isn't a star next to it, it's a compass rose I'm also working on building. I still have yet to add 4 more small diagonal arrows and a couple skinny circles. That's going to be what shows my room exits. So say there is a north and east exit, the north and east arrows will change colour to show those directions are open. It's functional, but my end game goal on it is to make it glow instead of changing colours.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 08 May 2016 06:07 AM (UTC)

Amended on Sun 08 May 2016 06:08 AM (UTC) by Nick Gammon

Message
I got a better result using this:



-- main result window
win5 = GetPluginID () .. ".5" 
WindowCreate (win5, 0, 0, 40, 40, miniwin.pos_center_right, miniwin.create_transparent, ColourNameToRGB("darkgray"))  -- create window
 

-- gradient window
win6 = GetPluginID ()  .. ".6"
WindowCreate (win6, 0, 0, 40, 40, miniwin.pos_center_right, miniwin.create_transparent, 0)  -- create window

WindowGradient (win6, 0, 0, 0, 0, 
                ColourNameToRGB ("yellow"), 
                ColourNameToRGB ("red"), 
                miniwin.gradient_vertical)  -- top to bottom
				
-- mask window
win7 = GetPluginID ()  .. ".7"
WindowCreate (win7, 0, 0, 40, 40, miniwin.pos_center_right, miniwin.create_transparent, 0)  -- create window


-- ellipse
WindowCircleOp (win7, miniwin.circle_ellipse, 5, 5, 25, 25, 
                ColourNameToRGB("black"), miniwin.pen_null, 0,  -- no pen
                ColourNameToRGB("white"), miniwin.brush_solid)  -- brush

-- blur ellipse
WindowFilter (win7, 0, 0, 0, 0, miniwin.filter_blur, 0) -- blur both directions

-- convert to images
WindowImageFromWindow (win5, "gradient", win6)
WindowImageFromWindow (win5, "mask", win7)

-- do the merge
WindowMergeImageAlpha (win5, "gradient", "mask", miniwin.merge_straight, 1, 40, 40, 0, 1)

WindowFilter (win5, 0, 0, 0, 0, miniwin.filter_blur, 0) -- blur both directions
WindowShow (win5,  true)  -- show it


The important part was making the background not black, but matching the output window (in my case, darkgray). You seem to be using an image, but if you get something that is close to the underlying colour it should look better.

Also I would use the symbolic constants (as I have above) rather than sprinking lots of "magic numbers" in the code, which you will always have to look up to see what they mean.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 08 May 2016 08:43 AM (UTC)
Message
Just to explain a bit more...

When you make a miniwindow with transparent mode, all that does is allow it to be merged with the main output window with an on/off test: Does a pixel in the miniwindow equal the background colour? Yes/No.

This lets you have odd-shaped windows, but you can't blend (smoothly) from a miniwindow to the main window because it isn't an alpha channel with 256 levels of blending. It's on/off.

So even if you make a nice smooth alpha transition in the miniwindow from the sun to the background, when that is copied to the main window (they way you did it) then pure black becomes transparent, and anything else (even slightly less black) becomes opaque. Thus you got the hard edges.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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,290 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.