• Is 'partial transparency' possible?

    From Helmut Giese@21:1/5 to All on Tue Sep 7 22:40:44 2021
    Hello out there,
    I had this idea: In a rather complicated configuration environment I
    would like to somehow 'gray out' sections which are currently not
    relevant - as if some sort of fog covers it.
    Is there some picture format which supports this 'partial
    transparency'? or maybe an extension?
    I am on Windows with tcl 8.6.10.

    Any link or hint or idea will be greatly appreciated.
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Gollwitzer@21:1/5 to All on Wed Sep 8 10:10:33 2021
    Am 07.09.21 um 22:40 schrieb Helmut Giese:
    Hello out there,
    I had this idea: In a rather complicated configuration environment I
    would like to somehow 'gray out' sections which are currently not
    relevant - as if some sort of fog covers it.
    Is there some picture format which supports this 'partial
    transparency'?

    This is called an "Alpha channel" and supported by PNG.

    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Uwe Klein@21:1/5 to All on Wed Sep 8 09:57:58 2021
    Am 07.09.21 um 22:40 schrieb Helmut Giese:
    Hello out there,
    I had this idea: In a rather complicated configuration environment I
    would like to somehow 'gray out' sections which are currently not
    relevant - as if some sort of fog covers it.
    Is there some picture format which supports this 'partial
    transparency'? or maybe an extension?
    I am on Windows with tcl 8.6.10.

    Any link or hint or idea will be greatly appreciated.
    Helmut

    there is bitmapped transparency around.

    afair works with gif, png, ?
    ( but I've only ever used it while
    massaging pics via the netpbm package.)

    Uwe

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Wed Sep 8 16:56:55 2021
    Am 08.09.2021 um 16:44 schrieb Helmut Giese:
    Hi Christian,
    Am 07.09.21 um 22:40 schrieb Helmut Giese:
    Hello out there,
    I had this idea: In a rather complicated configuration environment I
    would like to somehow 'gray out' sections which are currently not
    relevant - as if some sort of fog covers it.
    Is there some picture format which supports this 'partial
    transparency'?

    This is called an "Alpha channel" and supported by PNG.

    Christian
    thanks, it is so good that there are knowlegeable people around here. However I can't get it to work: Every image command I tried rejects
    the option '-alpha'. Do you maybe have an example of its use?
    Thank you
    Helmut

    TCL version ?
    It was added somewhere in 8.6.x AFAI remember..

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to All on Wed Sep 8 16:44:40 2021
    Hi Christian,
    Am 07.09.21 um 22:40 schrieb Helmut Giese:
    Hello out there,
    I had this idea: In a rather complicated configuration environment I
    would like to somehow 'gray out' sections which are currently not
    relevant - as if some sort of fog covers it.
    Is there some picture format which supports this 'partial
    transparency'?

    This is called an "Alpha channel" and supported by PNG.

    Christian
    thanks, it is so good that there are knowlegeable people around here.
    However I can't get it to work: Every image command I tried rejects
    the option '-alpha'. Do you maybe have an example of its use?
    Thank you
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Wed Sep 8 17:21:07 2021
    * Helmut Giese <hgiese@ratiosoft.com>
    | However I can't get it to work: Every image command I tried rejects
    | the option '-alpha'. Do you maybe have an example of its use?

    Check the photo(n) manpage:

    https://www.tcl.tk/man/tcl/TkCmd/photo.html

    FORMAT SUBOPTIONS
    Some image formats support sub-options, which are specified at
    the time that the image is loaded using additional words in the
    -format option. At the time of writing, the following are
    supported:

    png -alpha alphaValue
    An additional alpha filtering for the overall image, which
    allows the background on which the image is displayed to
    show through. This usually also has the effect of
    desaturating the image. The alphaValue must be between 0.0
    and 1.0.

    --<snip-snip>--

    The PNG image loader allows the application of an additional
    alpha factor during loading, which is useful for generating
    images suitable for disabled │ buttons: │

    image create photo icon -file "icon.png" │
    image create photo iconDisabled -file "icon.png" \ │
    -format "png -alpha 0.5" │
    button .b -image icon -disabledimage iconDisabled │

    HTH
    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Helmut Giese on Wed Sep 8 17:57:56 2021
    Helmut Giese <hgiese@ratiosoft.com> wrote:
    Arrgh,
    image create photo icon -file "icon.png" ?
    image create photo iconDisabled -file "icon.png" \ ?
    -format "png -alpha 0.5" ?
    I didn't have the idea to /quote/ the option and did
    image create ... -format png -alpha .05
    Thanks a lot Ralf.
    However, I have another problem: Since Tk cannot handle an image by
    itself it needs a "container" - e.g. a label or a button. Now if I
    use a label this label itself has a bottom that is not transparent -
    so it seems impossible to achieve what I intended.
    Hm, another 'tot geborene Idee' (idea born dead) - nothing new to me
    :(

    If you use the plain Tk label widget, and turn off all the
    default configuration options that provide borders/etc., you can get a "container" for the image that is just the image pixels and nothing
    more.

    Experimenting in a REPL with an image in a label and running
    interactive "label configure ..." to change things will reveal which
    ones need to be adjusted.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to All on Wed Sep 8 19:43:08 2021
    Arrgh,
    image create photo icon -file "icon.png" ?
    image create photo iconDisabled -file "icon.png" \ ?
    -format "png -alpha 0.5" ?
    I didn't have the idea to /quote/ the option and did
    image create ... -format png -alpha .05
    Thanks a lot Ralf.
    However, I have another problem: Since Tk cannot handle an image by
    itself it needs a "container" - e.g. a label or a button. Now if I
    use a label this label itself has a bottom that is not transparent -
    so it seems impossible to achieve what I intended.
    Hm, another 'tot geborene Idee' (idea born dead) - nothing new to me
    :(

    Thanks to all of you who responded.
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Schelte@21:1/5 to Rich on Wed Sep 8 21:29:21 2021
    On 08/09/2021 19:57, Rich wrote:
    If you use the plain Tk label widget, and turn off all the
    default configuration options that provide borders/etc., you can get a "container" for the image that is just the image pixels and nothing
    more.

    But it will not be transparent and show the underlying widgets.

    You can however make a (semi-)transparent toplevel:

    toplevel .t -background black
    wm attributes .t -alpha 0.5
    wm overrideredirect .t 1

    But then you'll somehow need to put the toplevel over the desired area,
    and update the position whenever the application window is moved,
    resized, or (partly) obscured:
    wm geometry .t 400x100+10+10

    That's going to be a lot of work.


    Schelte.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Gollwitzer@21:1/5 to All on Thu Sep 9 07:44:20 2021
    Am 08.09.21 um 21:29 schrieb Schelte:
    On 08/09/2021 19:57, Rich wrote:
    If you use the plain Tk label widget, and turn off all the
    default configuration options that provide borders/etc., you can get a
    "container" for the image that is just the image pixels and nothing
    more.

    But it will not be transparent and show the underlying widgets.

    You can however make a (semi-)transparent toplevel:

    toplevel .t -background black
    wm attributes .t -alpha 0.5
    wm overrideredirect .t 1

    But then you'll somehow need to put the toplevel over the desired area,
    and update the position whenever the application window is moved,
    resized, or (partly) obscured:
    wm geometry .t 400x100+10+10

    That's going to be a lot of work.

    Ah, I did'nt realise at first that you want to obscure a window or frame /partially/ with a semitransparent window.

    Schelte's suggestion reminds me of the way "tk busy" works. IMHO it is a
    hack, but when you do "tk busy <window>" then that window is covered
    with a fully transparent overlay so that mouse clicks do not reach it
    anymore. Maybe there is a way to set the "busy window" to an
    intermediate transparency?

    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Donal K. Fellows@21:1/5 to Christian Gollwitzer on Sat Sep 18 01:01:04 2021
    On Thursday, 9 September 2021 at 06:44:28 UTC+1, Christian Gollwitzer wrote:
    Schelte's suggestion reminds me of the way "tk busy" works. IMHO it is a hack, but when you do "tk busy <window>" then that window is covered
    with a fully transparent overlay so that mouse clicks do not reach it anymore. Maybe there is a way to set the "busy window" to an
    intermediate transparency?

    That's an InputOnly window (on X11) and it can't be drawn on at all.

    Donal.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)