Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] AW: frustrating pairs...

From: Christian:Ensel:GMX at: 8-May-2004 3:12

Dear Alain,
> either d = 'x [bx/pane/offset/x: - tmp * sf/data ] [ ; how to improve that
> bx/pane/offset/y: - tmp * sf/data ]
The function MIX-PAIRS as defined below takes two PAIR!s and a word of value X or Y. Depending on the latter MIX-PAIRS returns a new PAIR! which is composed by A's axis as supplied in the 'D argument and B's opposite axis. This lets you 'simulate' touching only one axis easily. Sounds very confusing, I know, but look at the following code snippet, you will get the idea: ;------------ cut'n'paste -- (beware of line-breaks) ------------------------- REBOL [] mix-pairs: func [a [pair!] b [pair!] 'd [word!] /local way] [ (a * way: pick [1x0 0x1] :d = 'x) + (b * reverse way) ] scroll: func [bx sf 'd] [ bx/pane/offset: mix-pairs bx/size - bx/pane/size * sf/data bx/pane/offset :d ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ;-- bx/pane/offset is modified only for the direction supplied in :d ; by setting the opposite axis back to the value before the modification ; show bx ] d: 'x view layout [ across bx: box 200x100 white with [ pane: make-face/spec 'box [size: 40x40 color: red] ] sf: slider 20x100 [scroll bx sf :d] return tg: btn "toggle" [d: select [x y x] :d sf/data: bx/pane/offset/:d / (bx/size/:d - bx/pane/size/:d) show [tg sf] ] ] ;------------ cut'n'paste -- (beware of line-breaks) ------------------------- regards, Christian