Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
temperfugit
@temperfugit
@toomasv Thanks for the block? tip! I didn't even think of putting canvas/draw: canvas/draw in the on-created block. That it works just confuses me more tbh. I had assumed that for some reason View just hadn't detected the change to the draw block so it didn't update, and canvas/draw: canvas/drawtricked it into re-checking it. But if it works to just do it once before even trying to add a circle, then I'm even more clueless than I thought. ;) I'm sure someone will come along who can break it down, the Red community doesn't seem to have any shortage of wizards.
Toomas Vooglaid
@toomasv
@temperfugit See if you'll get some clue if you switch debug? on: system/view/debug?: yes. I guess the problem concerns making deep-change to the draw-block before showing, so that draw has to be processed again, or something. Just a wild guess. :flushed:
nedzadarek
@nedzadarek
@toomasv @temperfugit canvas/draw: canvas/draw and canvas/draw/7: canvas/draw/7 at the end of tempCircle function works. It doesn't work with canvas/draw/7/temp: canvas/draw/7/draw. I guess it uses its own reactivity "engine": ?? on-face-deep-change* so maybe there is a bug?
Vladimir Vasilyev
@9214
@temperfugit does this work for you?
Red [Needs: View]

view [
    base 600x600 white
        draw [fill-pen blue circle 300x300 10] 
        on-down [face/draw/4: event/offset]
]
Vladimir Vasilyev
@9214
The reason why your original code doesn't work as expected is because holding series is not owned by a canvas face, hence it will not react to any changes in it.
Toomas Vooglaid
@toomasv

@temperfugit I think I got it: whenever you add a second-order series to draw, you have to "touch" it with draw: drawkind of thing. Here is your modified code where you don't have to do it - because everything is defined at once and no second order series is added:

tempCircle: func [event] [
    canvas/draw/7/4/4: event/offset - 10
    if canvas/draw/7/4/5 = 0x0 [
        canvas/draw/7/4/5: 20x20
    ]
]

view [
    on-down [tempCircle event]
    on-mid-down [probe canvas/draw]
    canvas: base 600x600 white all-over draw [ 
        transform 300x300 0 1 1 0x0 [
            shape [move 250x400 curve 250x400 200x350 200x250 200x150 250x100 300x100 350x100 400x150 400x250 400x350 350x400 350x400] ; 
            temp: [fill-pen blue ellipse 0x0 0x0]
            fill-pen off pen silver
            circle 250x400 5 circle 200x350 5 circle 200x250 5 circle 200x150 5 circle 250x100 5 circle 300x100 5
            circle 350x100 5 circle 400x150 5 circle 400x250 5 circle 400x350 5 circle 350x400 5 circle 350x400 7
        ]
    ] 
]

I guess it is the same reason @9214 just posted.

Vladimir Vasilyev
@9214
face/draw: face/draw triggers a change of one of the facets, to which face reacts immidiately and updates its data.
temperfugit
@temperfugit
I'm on mobile right now so can't test anything.
(hmm, not sure how to @ ppl on mobile, touching a name doesn't copy their ID to the text box like it does on desktop)
temperfugit
@temperfugit
Vladimir- re: the idea of holding owning the block, I guess I'm not sure what returning a block does, if it copies or links the data into my draw code. I should play with it later and see if a change to the temp block in the draw code would change holding.
Toomas- I was thinking something al lines of a change
Vladimir Vasilyev
@9214
@temperfugit only series enclosed inside deep-reactor!s can propagate a change. Your drawCurve function is redundant, as you can just set word to a block and refer to that block.
And it doesn't work as you probably expect - holding word is global, despite being enclosed in func body.
nedzadarek
@nedzadarek
@temperfugit maybe you can start typing e.g. @t?
temperfugit
@temperfugit
Toomas - darn mobile interface! I'm not sure exactly what you mean by "second order series". Does it have to do with block depth or binding it to temp? Maybe when I get home I can get a better look at your example and it will click for me.
@nedzadarek That works, thanks! I have half a mind to switch to desktop mode in my browser and see if that's any better.
Toomas Vooglaid
@toomasv
@temperfugit I meant series inside series.
temperfugit
@temperfugit
@9214 Thanks for your help, I'm going to have to read up on deep-reactor. drawCurve is redundant here because I stripped out most of its functionality to isolate the odd behavior to post here. In my test program it takes vertex data from other blocks (passed as an argument) and puts them in the draw block, while another function (I've yet to implement) will export the same blocks as svg. It's something I've been doing with Lua and Love2d, but I'm messing around a bit to see if it would be easier in Red.
temperfugit
@temperfugit
@toomasv Thanks for the clarification. Hopefully I'll get a chance this evening to go through
all the code examples and force some of this extra knowledge into my head.
lepinekong
@lepinekong_twitter
@nedzadarek I can't see what's he's pointing at: there's nothing in help about if or while :)
Is it possible to avoid this jaggeg effect for fonts and pictures ? https://i.imgur.com/agzzanj.png testing https://github.com/hako/lines
GiuseppeChillemi
@GiuseppeChillemi
@9214 @toomasv Thanks for you help
Now I have more knowledge about working of RED VID.A special thank to @toomasv as I am building from your code.
Now another request:
GiuseppeChillemi
@GiuseppeChillemi

Is I have a list like:

button-list: [field1 "aaa" field2 "bbb" field3 "ccc" ]

How could I dynamically create a GUI with those 3 fields ?

Somethig like:

Red []

view/no-wait [
    field1: field 70 hint "aaa" [probe face/text]]
    field2: field 70 hint "bbb" [probe face/text]]
    field2: field 70 hint "ccc" [probe face/text]]
]
Vladimir Vasilyev
@9214
@GiuseppeChillemi
list: [field1 "aaa" field2 "bbb" field3 "ccc"]

view collect [
    foreach [tag text] list [
        keep compose [
            (to set-word! tag) field 70 hint (text) [probe face/text]
        ]
    ]
]
GiuseppeChillemi
@GiuseppeChillemi
@9214 another lesson to study !
Keep and Compose are the target
I don't understand the reason for to set-word! Tag instead of Tag
Vladimir Vasilyev
@9214
@GiuseppeChillemi well, remove to set-word! and check how the output of collect changed with probe.
GiuseppeChillemi
@GiuseppeChillemi
We are inside a dialect so I expect the code to be text
Vladimir Vasilyev
@9214
We are not inside a dialect.
GiuseppeChillemi
@GiuseppeChillemi
No ? Isn't the generated text passed to vid with view ... ?
(could try Tomorrow)
Vladimir Vasilyev
@9214
Then I don't get what you mean by "I expect the code to be text".
GiuseppeChillemi
@GiuseppeChillemi
I expected the "view" argument to be text. Then the dialect code interprets It.
Vladimir Vasilyev
@9214
It's not a text, it's a VID block which collect returns.
GiuseppeChillemi
@GiuseppeChillemi
Like "sell 10 shares at 50"
Ok, so we are parsing a block instead of text
nedzadarek
@nedzadarek
@lepinekong_twitter as fair I remember, he said to check help for while and if. You can see that if takes cond [any-type!] and while, cond [block!].
If you are new (or used different languages) you may be confused about usage of () and []. An expression inside() is evaluated (e.g. a: ( 1 + 2) a; 3) and an expression inside [] is not evaluated (not sure if this is proper term). So you should use () for grouping code to run it immediately. You should use [] to pass some code/data.
ps. helps for both functions are wrong about true. It should be "true-thy value" or something like this.
ps2. I was very succinct about this description - I could miss something. I just didn't want to confuse you with unnecessary things.
Toomas Vooglaid
@toomasv
@GiuseppeChillemi You are welcome! :smile:
GiuseppeChillemi
@GiuseppeChillemi
This message was deleted
I have a VIEW button which uses as DATA an "area" name, referencing the whole object ( @toomasv , yes, it is based on your code). If I define the area BEFORE the button in the VID BLOCK, everything works fine. If I define it AFTER the word is undefinied at runtime. Is it correct ?
Vladimir Vasilyev
@9214
@GiuseppeChillemi you can't directly reference something that doesn't yet exist.
view [
    b: button extra 'a [probe get in get face/extra 'text]
    a: area "this is an area text"
]
GiuseppeChillemi
@GiuseppeChillemi
@9214 Being a dialect it is different than the main program code loading...
Vladimir Vasilyev
@9214
@GiuseppeChillemi not really.
GiuseppeChillemi
@GiuseppeChillemi
I am used to define object at the botton of the code and being able to access it since the very first lines...
@9214 I could understand this but changes the coding schemas you have in mind.
Vladimir Vasilyev
@9214
@GiuseppeChillemi you can't do that directly, without storing referring words in a block or using lit-word!s instead.