LB Booster
« #handle "rule " »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:02am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: #handle "rule "  (Read 585 times)
Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx #handle "rule "
« Thread started on: Jul 20th, 2015, 8:41pm »

I can't seem to find a sequence of rules that do what I want to do.

Imagine a box with black characters on a white background.

I want to draw a filled box on top so the background changes to another colour but the text remains black.

(This I have achieved simply by using MASKPEN with the new background colour)

I also want to be able to reverse this action; i.e. draw a filled box on top so the background changes back to white but the characters remain black, but I just can't seem to find a solution.
« Last Edit: Jul 20th, 2015, 8:41pm by Monkfish » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: #handle "rule "
« Reply #1 on: Jul 20th, 2015, 9:03pm »

on Jul 20th, 2015, 8:41pm, Monkfish wrote:
the background changes back to white but the characters remain black, but I just can't seem to find a solution.

It's impossible with a simple logical operation. If you want to change any background colour to white then - since black is itself a colour - that will inevitably change to white too!

If you literally want to 'reverse' the previous operation, then use flush to save the original state and redraw to restore it:

Code:
    button #w, "change background color", [change], LL, 50, 30
    button #w, "restore background color", [restore], LL, 46, 0
    open "Test" for graphics_nsb as #w
    #w "font Arial 18 bold"
    #w "\\\\\     Some text in black"
    wait

[change]
    #w "flush; backcolor yellow; down; rule "; _R2_MASKPEN
    #w "place 0 0; boxfilled ";WindowWidth;" ";WindowHeight
    wait

[restore]
    #w "redraw"
    wait 

Richard.
« Last Edit: Jul 20th, 2015, 9:04pm by Richard Russell » User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: #handle "rule "
« Reply #2 on: Jul 20th, 2015, 9:25pm »

If users are changing the colour of different boxes and want to change them back out of order, can I achieve this by assigning each a segment name?
« Last Edit: Jul 20th, 2015, 9:28pm by Monkfish » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: #handle "rule "
« Reply #3 on: Jul 20th, 2015, 9:57pm »

on Jul 20th, 2015, 9:25pm, Monkfish wrote:
If users are changing the colour of different boxes and want to change them back out of order, can I achieve this by assigning each a segment name?

LBB doesn't support segments, so that's not relevant. But graphicboxes are independent so the flush/redraw method can be used to restore the background colour to the previously saved state for that box in any order.

If you need to save more than one state for a given graphicbox (which you shouldn't if you simply want to restore the previous condition), then use getbmp and drawbmp instead of flush and redraw.

Richard.
User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: #handle "rule "
« Reply #4 on: Jul 20th, 2015, 10:04pm »

Thanks Richard, I will look into it. btw I made a donation the other day, but still seeing the ads. not sure how that works.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: #handle "rule "
« Reply #5 on: Jul 20th, 2015, 10:21pm »

on Jul 20th, 2015, 10:04pm, Monkfish wrote:
I made a donation the other day, but still seeing the ads. not sure how that works.

Conforums works by calendar months, so it's wasteful to use a donation only for the last twelve days or so of July. Yours will result in the forum being ad-free in August.

Can I encourage others to donate too, if they are so inclined.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls