World: r3wp
[View] discuss view related issues
older newer | first last |
Pekr 4-Nov-2008 [8266] | IIRC, there was first a source version from Chris, then it was added as a native ... |
Chris 4-Nov-2008 [8267x3] | http://www.ross-gill.com/r/hsv-lab.r |
It's not exactly equivalent, rgb-hsv returns a block. It's also a little slower... [hue [integer!] saturation [decimal!] brightness [decimal!] alpha [decimal!]] | |
Hmm, also in the library: http://www.rebol.org/view-script.r?script=hsv-lab.r | |
amacleod 4-Nov-2008 [8270x4] | Is there a way to get an index # from a text list selection? |
text-list | |
face/text gives the string but can I get its position i the list? | |
actually its face/picked gives teh string.. | |
Chris 5-Nov-2008 [8274] | index? find face/data face/picked |
DideC 5-Nov-2008 [8275] | text-list in R2 has this problem cause it works on text value, not index. So it can't handle the same text value several times. VID 3.4 actually return the index AFAIK. |
amacleod 5-Nov-2008 [8276] | Thaks Chris, I thought there might be an internal method but as DIdC suggests there is not/ |
Geomol 5-Nov-2008 [8277] | Henrik, the hsv2rgb function, I made for Canvas RPaint. It takes H S V values as decimals in the area 0.0 - 1.0 as input: hsv2rgb: func [ H S V /local RGB var_h var_i var_1 var_2 var_3 var_r var_g var_b ][ RGB: 0.0.0 either S = 0 ;HSV values: 0 Ö 1 [ RGB/1: to-integer V * 255 RGB/2: to-integer V * 255 RGB/3: to-integer V * 255 ][ var_h: H * 6 if var_h >= 6 [var_h: 0] ;H must be < 1 var_i: to-integer var_h var_1: V * (1 - S) var_2: V * (1 - (S * (var_h - var_i))) var_3: V * (1 - (S * (1 - (var_h - var_i)))) switch var_i [ 0 [var_r: V var_g: var_3 var_b: var_1] 1 [var_r: var_2 var_g: V var_b: var_1] 2 [var_r: var_1 var_g: V var_b: var_3] 3 [var_r: var_1 var_g: var_2 var_b: V ] 4 [var_r: var_3 var_g: var_1 var_b: V ] 5 [var_r: V var_g: var_1 var_b: var_2] ] RGB/1: to-integer var_r * 255 ;RGB results: 0 Ö 255 RGB/2: to-integer var_g * 255 RGB/3: to-integer var_b * 255 ] RGB ] |
Henrik 5-Nov-2008 [8278] | Geomol, thanks |
Geomol 5-Nov-2008 [8279] | Let me know, if you need the rgb2hsv as well. |
Henrik 5-Nov-2008 [8280x2] | I'll be ok, I think. Right now I'm trying to find a bug in an hsl-to-rgb function. |
and now fixed :-) | |
amacleod 10-Nov-2008 [8282x3] | Is there a way to have an area style that auto adjusts the height given a specific width so an entire paragraph will fit in the area. I know text style does this but I need to retain formatting. |
I played with the sizing- 100x-1 etc. but it does not seem to work like 'btn style does. | |
Never Mind. I found the as-is statement added to style. Retains the formatting. | |
Henrik 11-Nov-2008 [8285] | amacleod, you may want to study BTN's INIT block, to see how it uses the -1 size. |
amacleod 11-Nov-2008 [8286] | Henrik, I was looking at that too, Thanks. But 'as-is does what I need. Funny, I never saw it used before.. |
james_nak 17-Nov-2008 [8287] | I'm trying to create a function that builds radio buttons and checkboxes on the fly. Sunanda gave me some ideas about how to do that. This morning it dawned on me that I was going about it the wrong way. I was trying to build an entire string that represented the rebol code for the gadget instead of building a block of code.. What was happening was my contexts were all in error. I'm wondering now how to append my code into an existing layout block. The only working method I have found so far is to append into a non-layout block then "view layout blk." I'm still curious if there is a way to append/insert into a layout block though. E.g., a: layout [ btn "Quit" [unview halt] ] b: [t1: check [ ] ] <- this is my generated block append a b I get a "Script Error: append expected series argument of type: series port" |
Henrik 17-Nov-2008 [8288x2] | remove the first layout and then create the layout afterwards. |
all LAYOUT does is create a big object tree, and of course you can't just append blocks to that | |
james_nak 17-Nov-2008 [8290] | Thanks Henrik. That's what I needed to hear (how layout works). |
Nicolas 17-Nov-2008 [8291x3] | insert-event-func [ if event/type = 'key [ print face/text ] event ] view layout [area "hello"] ;Can a/text update before it prints? |
;There's a one keystroke delay | |
that should be view layout [a: area "hello"] | |
Anton 17-Nov-2008 [8294] | Nicolas, you could modify the area's engage function, as in this patch. append blk: select select second get in a/feel 'engage [switch act][key] bind [print face/text] blk/2 |
Nicolas 17-Nov-2008 [8295] | Thanks Anton. That was really helpful. |
Anton 17-Nov-2008 [8296] | You're welcome. |
Nicolas 21-Nov-2008 [8297x4] | REBOL [] index: func [dir list /local files] [ files: sort load dir foreach file files [append list join dir file] foreach file files [attempt [if find file "/" [index dir/:file list]]] ] index %/c/ files: [] l: layout [ f: field 600 [call t/picked] t: text-list 600x400 data copy files] search: func [f-string] [ t/data: copy files foreach s parse f-string none [remove-each f t/data [not find f s]] show t] append blk: select select second get in f/feel 'engage [switch act][key] bind [search f/text] blk/2 focus f view l if I type something into the field, then I click the slider, it calls t/picked. Why? i can't figure it out. |
Sorry. That should be this. | |
index: func [dir list /local files] [ files: sort load dir foreach file files [append list join dir file] foreach file files [attempt [if find file "/" [index dir/:file list]]] ] index %/c/ files: [] l: layout [ f: field 600 [call t/picked] t: text-list 600x400 data copy files] search: func [f-string] [ t/data: copy files foreach s parse f-string none [remove-each f t/data [not find f s]] append clear t/picked t/data/1 show t] append blk: select select second get in f/feel 'engage [switch act][key] bind [search f/text] blk/2 append clear t/picked t/data/1 focus f view l if I type something into the field, then I click the slider, it calls t/picked. | |
Why? | |
Anton 21-Nov-2008 [8301x4] | This is just the same as: view layout [ field [call t/picked] t: text-list ] |
It calls t/picked because [call t/picked] is the action block specified after FIELD. Are you confused about action blocks in VID ? | |
Ah sorry, it's when you click the slider that the field action is done (unexpectedly by you). | |
It's ON-UNFOCUS in face flags. Compare: view layout [f: field [print "action"] text-list] print mold f/flags view layout [f: field [print "action"] with [deflag-face self on-unfocus] text-list] print mold f/flags | |
james_nak 22-Nov-2008 [8305] | As I have mentioned before here I have been working on turning strings into code. I've used this: set in get to-set-word "myobj" 'text "change a value" where myobj: make object! [text: "default"] and this works! I just don't know why get to-set-word "myobj" behaves that way. I'm hoping it's not a fluke because it's my Mr. Helper. Anyone able to explain that? |
Anton 22-Nov-2008 [8306x2] | You can get from a word! as well as the corresponding set-word! and get-word!. They are all the same word, after all. |
So, in your example, you could replace TO-SET-WORD with TO-WORD. | |
james_nak 22-Nov-2008 [8308] | I see. But what am I "getting"? |
Anton 22-Nov-2008 [8309] | GET gets the value of the word, which you previously set to an object. So, GET returns that object. |
james_nak 22-Nov-2008 [8310x3] | Then the to-word just know by context that myobj was an object, eh? The reason I ask that is that if it was just a word and not an object I don't seem to have to use get.: >> a: "test" == "test" >> set to-word "a" "hello" == "hello" >> a == "hello" >> set in to-word "myobj" 'text "hello" ** Script Error: in expected object argument of type: object port ** Where: halt-view ** Near: set in to-word "myobj" 'text >> myobj/text == "eeee" |
>> set in get to-word "myobj" 'text "hello" == "hello" | |
It's all good. I just was curious. Thanks Anton. | |
Nicolas 22-Nov-2008 [8313] | Thanks Anton! |
Anton 22-Nov-2008 [8314x2] | Nicolas, you're welcome. |
James, TO-WORD does not interact with the value of the word it is creating. | |
older newer | first last |