coloring an arrow with pixel color

hello
so I’m trying to draw arrows that take the colors of the input images.
something like that

test :
intervalx=$1
intervaly=$2
thickness=$3
headend=$4
headthickness=$5
-repeat {w/$intervalx},x
-repeat {w/$intervaly},y
posx={$intervalx/2+($x*$intervalx)}
posy={$intervaly/2+($y*$intervaly)}
-arrow $posx,$posy,{$posx+$intervalx/2},{$posy+$intervaly/2},$thickness,$headend,headthickness,1,{-RGB}
-arrow $posx,$posy,{$posx-$intervalx/2},{$posy-$intervaly/2},$thickness,$headend,headthickness,1,{-RGB}
-done
-done

this way the colors looks randomized and I’m not sure of what ${-RGB} means.
how can I get the colors at posx,posy of my input images and pass them to the -arrow.
this is my first script so I apologize if it’s trivial but I tried a lot of things already …
luc

#@cli RGB
#@cli : Return a random int-valued RGB color.
RGB :
  -v - -u {round(u(255))},{round(u(255))},{round(u(255))} -v +

ok :blush: I understand the randomness now
this is working

colr={i($posx,$posy,0,0)}
colg={i($posx,$posy,0,1)}
colb={i($posx,$posy,0,2)}
mycol={$colr},{$colg},{$colb}
-arrow $posx,$posy,{$posx+$intervalx/2},{$posy+$intervaly/2},$thickness,$headend,$headthickness,1,$mycol
-arrow $posx,$posy,{$posx-$intervalx/2},{$posy-$intervaly/2},$thickness,$headend,$headthickness,1,$mycol

I’m sure that it could be expressed more simply

diving into https://raw.githubusercontent.com/dtschump/gmic/master/src/gmic_stdlib.gmic seems to be the best way to learn about all this.

thanks afre
luc

From what I see in your code, it looks like you could benefit from commands -display_quiver or -quiver that manage the drawing of field of colores arrows.
I wouldn’t recommend doing your own XY loop with two nested -repeat...-done loops, as if the number of loop iterations is high, the script will be really slow. You may actually want to take a look to the code of command -quiver , which uses the G’MIC math parser (and it’s JIT compiler) to speed up the drawing process :
Code of G'MIC -quiver command - Pastebin.com

The code of the -quiver is quite simple to understand, and effective as well :).

thank you David.that’s exactly what I’m doing right now.looking at your code.
my weekend is just … dead

I hope you won’t get headaches, and if so, sorry by advance :wink:

no headaches anymore now.gmic is so exciting.thanks for that.