BB___RULE

=RULE= toc This page focuses only on the two most common drawing rules; the OVER rule and the XOR rule. The list of Windows constants is included for reference.

Description
> The RULE command affects the way colors display depending on whether they are applied directly over a background color or combined with the background color. > The normal display mode is OVER even if no rule is applied. That is, if you draw a red line over a green background, the red line will indeed show as a red line. The red pixel replaces the green pixel. > If the drawing mode is changed to XOR, the colors are combined in such a way that the red line drawn over a green background will show as blue.

> A benefit of the XOR rule is that if you run the command a second time, the drawing will be erased. See the example below.

Syntax
> //This command is NOT case sensitive//. Using JB rulename OVER (overwrite) or XOR (exclusive-OR): Using Windows constants:
 * 1)  - a graphics window
 * 2)  - a graphicbox

The list of Windows constants: _R2_BLACK _R2_WHITE _R2_NOP _R2_NOT _R2_COPYPEN          <- the default LB drawing rule _R2_NOTCOPYPEN _R2_MERGEPENNOT _R2_MASKPENNOT _R2_MERGENOTPEN _R2_MASKNOTPEN _R2_MERGEPEN _R2_NOTMERGEPEN _R2_MASKPEN _R2_NOTMASKPEN _R2_XORPEN _R2_NOTXORPEN        <- the xor LB drawing rule

Hints
> Place useful hints about this keyword here

The OVER rule
An example of the command in a graphics window. code format="lb" nomainwin UpperLeftX=100:UpperLeftY=100 WindowWidth=400:WindowHeight=400

open "Rule Demo" for graphics_nsb_nf as #g #g "trapclose [quit]"

#g "down; fill yellow" #g "rule over"

#g "place 10 10" #g "color red; backcolor red" #g "boxfilled 140 140"

#g "place 140 140" #g "color blue; backcolor blue" #g "boxfilled 240 240"

#g "place 240 240" #g "color green; backcolor green" #g "boxfilled 340 340"

wait

[quit] close #g end code

The XOR rule
An example of the command in a graphics window. (The example uses a one second timer to demo the effects). code format="lb" nomainwin UpperLeftX=100:UpperLeftY=100 WindowWidth=400:WindowHeight=400

open "Rule Demo" for graphics_nsb_nf as #g #g "trapclose [quit]"

#g "down; fill yellow" #g "rule xor"

#g "place 20 20" #g "color cyan; backcolor pink" #g "boxfilled 140 140" #g "circlefilled 20"

#g "place 140 140" #g "color cyan; backcolor cyan" #g "boxfilled 240 240" #g "circlefilled 20"

#g "place 240 240" #g "color cyan; backcolor darkgreen" #g "boxfilled 340 340" #g "circlefilled 20"

timer 1000, [doit] wait [doit] timer 0 #g "place 140 140" #g "color cyan; backcolor cyan" #g "boxfilled 240 240" #g "circlefilled 20"

timer 1000, [doit2] wait [doit2] timer 0 #g "place 140 140" #g "color cyan; backcolor cyan" #g "boxfilled 240 240" #g "circlefilled 20" wait

[quit] close #g end code

Useful Functions
code format="lb" Place a useful function using this keyword here code