Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any way to use transparency in SCREEN 0?
#1
I haven't found a way. What I'm looking for is the same shadow effect we can achieve in graphics. That means both the foreground and the background of the area the shadow occupies are dimmed, but still maintain the same color, just at a lesser intensity.

Now this gets a bit complicated in SCREEN 0.

1) Make hardware buttons mixed with software buttons and place them all on the screen.

2) Reverse the display order so the hardware images go to the bottom.

3) Make a software popup window that can be moved.

So what is needed in SCREEN 0 is for the popup shadow to be of enough transparency to achieve the previously mentioned results.

Usually in SCREEN 0 we just reprint the characters under the shadow in foreground grey and background black, or white on bright white, etc. That doesn't look quite so nice when the shadow appears over bright red on bright white or bright yellow on bright white, etc. A dimmer red and yellow with a grayish background would be ideal in this instance.

Now if we make the shadow a hardware image, the problem becomes the display order. It was reversed, so now the software buttons go over the shadow instead of under it. So dammit Pete, change the display order back.... Well, that would make the hardware buttons go over the popup (it's a software image, remember) so that would be an even bigger problem, which is why the order was reversed in the first place.

If there is a way to copy both the hardware and software images, already on the screen, to a _newimage 32 surface, and then copy that screen to memory, we'd have one big hardware image to use with the software screen 0 popup and its hardware shadow. In theory, that would visually work, but Is this possible?

Honestly I'd just convert the software buttons to all hardware buttons, but remember, there is also a lot of text to consider and that would not dim when shadowed. 

I can see Steve racing for the aspirin bottle now! He needs a really big one, so he can throw it at me after he empties it. (Dammit Pete, just do everything in graphics!)  Big Grin

Pete

Edit: I did think up a tedious method that I believe would work and I know how to do. Make the whole popup a hardware image. The tedious part is it would need to be construct it in stages so when choices like cut, copy, etc. are or are not available, the correct popup gets displayed. So image copy two of every menu item, and "putimage' them together as per circumstances. Highlight the menu with the mouse by putimaging a transparent hardware 'shadow' over each menu choice. Doable, but pretty wonky.
Reply
#2
Instead of dimming, just change the color of what is underneath.
b = b + ...
Reply
#3
Transparency in screen 0?

Won't _PaletteColor 0, 0 work?
Reply
#4
Well, the holes in letters such as O, P, e and numbers like 0, 4, 6 are transparent already...

... sorry, couldn't resist Big Grin Big Grin Big Grin
Reply
#5
(03-28-2025, 03:17 PM)bplus Wrote: Instead of dimming, just change the color of what is underneath.
Yesterday I had the same idea, but realized I couldn't manipulate the intensity of the color underneath in SCREEN 0.

Have a look at this...

Code: (Select All)
Screen 0
a$ = "The O in Rho is transparent you know!"
Palette 7, 63: Cls , 7 ' White background.
Color 4, 7
Print a$
Color _RGB(255, 0, 0), 7 ' Bright red.
Print a$
Color _RGB(86, 0, 0), 7 ' Nice if this was a dull red, but it is the same intensity as above.
Print a$
Color _RGB(85, 0, 0), 7 ' What the hell, it goes black?
Print a$
Color _RGBA(86, 0, 0, 120), 7 ' Alpha has no effect in SCREEN 0 here.
Print a$
Sleep
Screen _NewImage(600, 400, 32)
Cls , _RGB(255, 255, 255) ' White background.
Color _RGB(255, 0, 0), 7 ' Bright red.
Print a$
Color _RGB(86, 0, 0), 7 ' Dull red.
Print a$
Color _RGB(85, 0, 0), 7 ' A hair duller instead of going black.
Print a$
Color _RGBA(86, 0, 0, 120), 7 ' Alpha gives dull and faded red.
Print a$
Sleep

SCREEN 0 treats all reds the same, except when you go below red 86, go figure. Then it just turns black. RGBA doesn't have an effect in SCREEN 0, either.

So I don't see a method I can use. Like I mentioned in the opening post, change the underneath color to 8 (grey) or 7 (white) if a bright white background is present is the best we can do in SCREEN 0, I think. Sure we could use a palette statement to change the red to one of the other reds in the palette, but that would also effect all the red on the screen, not just the red under the shadow. So that method might work in some very specific cases instances but is far from being universally applicable. (Keep in mind those last two words would sound funnier if Sylvester the Puddy Cat said them.)

Oh, also worth mentioning is that a rabbit hole alternative is to make the text in a lighter color off-red like rgb(255, 100, 100) then make the shadow a grey background and use rgb(255, 0, 0) to make those characters under the shadow appear darker. The big job here is to use the SCREEN function to read the text character's color, and then try to figure out an algorithm to determine if it is red, orange, green, yellow, blue, white, or black so we can assign the 'darker' looking color to its shadow overlay.

I love your use of critical thinking though. It's a path towards solutions most folks don't often care to venture.

Pete
Reply
#6
Is this the effect you want?
Code: (Select All)
Randomize Timer
Dim Shared fc, fc2: fc = 8: fc2 = 15
Color fc, 15

Cls
For r = 1 To 25
    For c = 1 To 80
        Locate r, c: Print Chr$(Int(Rnd * 90) + 33);
    Next
Next
For i = 1 To 6
    r1 = 3 * i: r2 = r1 + 3
    c1 = 13 * (i - 1) + 2: c2 = c1 + 8
    shaddowBox r1, c1, r2, c2, i
Next
Sleep

Sub shaddowBox (r1, c1, r2, c2, bc)
    box r1 + 1, c1 + 1, r2 + 1, c2 + 1, 0
    box r1, c1, r2, c2, bc
End Sub
Sub box (r1, c1, r2, c2, bc)
    For r = r1 To r2
        For c = c1 To c2
            If bc = 0 Then
                Color fc - 7, bc
                a = Screen(r, c)
                Locate r, c: Print Chr$(a);
            Else
                Color fc2, bc
                Locate r, c: Print Chr$(Int(Rnd * 90) + 33);
            End If
        Next
    Next
End Sub

   

OK I don't know how to spell shadow Smile
b = b + ...
Reply
#7
You guys are making things too difficult.  See this very simple little demo:

Code: (Select All)
temp = _NewImage(100, 100, 32)
Cls , &HFFFF0000&&, temp 'red screen
hw = _CopyImage(temp, 33)
_DisplayOrder _Hardware , _Software

Do
c = c + 1
Print "Hello World";
Print c;
k = _KeyHit
Select Case k
Case 32:
t = Not t
If t Then _PaletteColor 0, 0 Else _PaletteColor 0, &HFF000000&&
End Select
_PutImage (100, 100), hw
_Limit 30
_Display
Loop


The red box here is UNDER our screen 0 screen. Normally, black is solid and you can't see the box under it. With _PaletteColor, we make black transparent. Can't see any change with the rest of our screen or text or anything else, but now with a transparent black, the box is visible.

Isn't this what you're talking about wanting?
Reply
#8
I'm not sure if it belongs here.

Can one define windows in QB64 that are stacked on top of each other but completely independent of each other? Here's an example from QuickC.

With the following instructions, you could, for example, stack three windows on top of each other, each independent of the other. This meant that different output could be generated in each window, and the color could also be specified. The whole thing looked almost like it did under Windows.

This means: From line 4, 2 lines wide to line 24, column 79
_settextwindow( 4, 2, 24, 79 );

Determine text position: line, column
_settextposition( 2, 15 );

Output text.
_outtext("Text");

And so on, specifying the output for each window.
_settextwindow( 4, 2, 6, 79 );
_settextwindow( 8, 2, 24, 79 );

[Image: Fensterbeispiel-Text.jpg]
Reply
#9
Yes things get interesting when windows or controls, same difference, overlap and you need code to track what you just clicked or which gets the keypress value off keyboard.
b = b + ...
Reply
#10
That's not possible, as QB64(PE) supports only one physical window per program. However, as finally the contents of a window is just an image, and we can create as many images as our memory allows you could simply go a master/slave approach.

You have a master program which creates and manages the images and react to inputs and a slave program which can be run multiple times (one for each window you want) and which get their image data to display send from the master and in return collecting input and send that back to the master program so it can process the inputs and changing image content accordingly.

So in fact the master is the complicated part wich contains the regular program, while the slave program can be very simple just displaying (PutImage) the image it got send from the master and a input loop collecting key/mouse activity and send that back to the master.

That's exactly what I do in my GuiTools Framework (see MultiWinDemo). You just need to figure an efficient communication method between the master and the slave(s) as image data may be lot e.g. a 32bit HD image 1280*720 = ~3.7MB. In GuiTools I use shared memory transfer for it, files might work depending on the speed of your drive but I guess TCP would be much to slow to work close to realtime with this method.
Reply




Users browsing this thread: 1 Guest(s)