# How do I define a custom Action in Javis.jl?

**URL:** <https://discourse.julialang.org/t/how-do-i-define-a-custom-action-in-javis-jl/79791>\
**Category:** General Usage\
**Created:** [April 21, 2022, 2:36pm UTC](https://discourse.julialang.org/t/how-do-i-define-a-custom-action-in-javis-jl/79791 "2022-04-21T14:36:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cocoa1231](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cocoa1231/32/22215_2.png) [@cocoa1231](https://discourse.julialang.org/u/cocoa1231)\
**Post date:** [April 21, 2022, 2:36pm UTC](https://discourse.julialang.org/t/how-do-i-define-a-custom-action-in-javis-jl/79791/1 "2022-04-21T14:36:23Z")

</div>

Hello

So I’m trying to define a custom animation in Javis. My code is -

```julia
using Javis
using Animations
using Colors

function ground(args...)
    background("black")
    sethue("white")
end

rotate_anim = Animation(
    [0, 1],
    [0, 2π],
    [sineio()]
)

nframes = 30

video = Video(500, 500)
Background(1:nframes, ground)

function change_arrow_head(vid, obj, actn, frame)
    new_x = cos(actn.anim(frame / nframes)) * 141.4213562373095
    new_y = sin(actn.anim(frame / nframes)) * 141.4213562373095
    return Object(obj.frames.frames, (args...) -> arrow(O, Point(new_x, new_y)))
end

ar = Object(1:nframes, (args...; x = 100, y = 100) -> arrow(O, Point(x, y)))
Object(1:nframes, (args...) -> circle(O, 10, :fill))

act!(ar, Action(1:nframes, rotate_anim, change_arrow_head))

render(video; pathname = "test.gif")

```

Now I have a few questions -

1. How do I get the length of the arrow rather than manually inputting it where I define `new_x, new_y`.
2. Why aren’t the old arrows being removed? Am I not doing this properly? Is there a way to modify the old arrow rather than defining this new arrow? I’ve only ever animated using Matplotlib and Plots.jl

![test](https://global.discourse-cdn.com/julialang/original/3X/c/b/cb71158500189cde252948c17889f4f92cf9848a.gif)

Here is the resulting GIF
