How to extend effects?
[1/3] from: atruter::labyrinth::net::au at: 19-Mar-2003 9:28
Given the following:
<code>
REBOL []
img: to-image layout [origin 0 box 100x100 blue]
my-effect: func [face] [
repeat pos (face/size/x * face/size/y) [
poke face pos either odd? pos [255.255.255.0][0.0.0.0]
]
]
view layout [
image my-effect img
]
</code>
is it possible to simply have "view layout [image img effect [my-effect]]",
in essence extending the effects available to VID?
*If* this is possible, is it also possible to make the my-effect func
generic such that "view layout [box blue effect [my-effect]]" works?
If VID is a dialect, what are effects? Built-ins, properties, words? Are
they something that "belongs" to VID or View?
Regards,
Ashley
[2/3] from: antonr:iinet:au at: 19-Mar-2003 14:19
Ashley,
I believe that this is not possible now, but
it has been discussed before, and it may be a future
possibility. It would be very handy.
VID is a dialect, the effect dialect is another, which
is understood at the face (View) level (ie. below VID).
Anton.
[3/3] from: rotenca:telvia:it at: 19-Mar-2003 16:31
Hi,
> is it possible to simply have "view layout [image img effect [my-effect]]",
> in essence extending the effects available to VID?
>
> *If* this is possible, is it also possible to make the my-effect func
> generic such that "view layout [box blue effect [my-effect]]" works?
No, but in this case you could do:
my-effect: func [img] [
repeat pos (img/size/x * img/size/y) [
poke img pos either odd? pos [255.255.255.0][0.0.0.0]
]
img
]
view layout [image effect [draw [image 0x0 my-effect img]]]
> If VID is a dialect, what are effects? Built-ins, properties, words? Are
> they something that "belongs" to VID or View?
Effects are words of a dialect interpreted by View.
The effect word Draw handles a sub-dialect in a block: the advantage of Draw
sub-dialect is that it is reduced before interpreted, so it can contain Rebol
code, like in the example.
---
Ciao
Romano