# Moving Bar question

**URL:** <https://mworks.discourse.group/t/moving-bar-question/406>\
**Category:** Support\
**Created:** [July 24, 2017, 2:24pm UTC](https://mworks.discourse.group/t/moving-bar-question/406 "2017-07-24T14:24:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 24, 2017, 2:24pm UTC](https://mworks.discourse.group/t/moving-bar-question/406/1 "2017-07-24T14:24:13Z")

</div>

Hello,  
I am trying to implement a method for receptive field mapping in Mworks. Basically, I am presenting a bar that moves across the screen at different orientations. My question is: is there is a built-in method in mworks to present a moving stimulus (bar)? What I am doing right now is change the x position in the bar stimulus (the one built-in in mworks) parameters within a loop to produce the motion. However, it’s a bit jittery at the moment.  
Thanks in advance,  
Beshoy

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 24, 2017, 7:13pm UTC](https://mworks.discourse.group/t/moving-bar-question/406/2 "2017-07-24T19:13:07Z")

</div>

Hi Beshoy,

I’ve attached an example experiment that shows how to do this. Here are the key points:

1. The x position of the rectangle stimulus is an expression that depends on the output time of the frame currently being prepared (`nextFrameTime()`) and the deg\_per\_sec variable.

2. The rectangle stimulus is “wrapped” in a [frame list stimulus](http://mworks-project.org/documentation/0.7/components/frame_list_stimulus.html). The rectangle is the frame list’s only frame, and the frame list is configured to loop indefinitely. The net effect is that the rectangle is redrawn on every display refresh, instead of just being drawn when needed or requested.

3. The frame list (and thereby the rectangle) is [live queued](http://mworks-project.org/documentation/0.7/components/live_queue_stimulus.html), so the rectangle stimulus will re-evaluate the position expression each time it draws itself (i.e. every frame).

This is a very useful technique for animating stimuli that are normally static.

Cheers,  
Chris Stawarz

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 24, 2017, 7:13pm UTC](https://mworks.discourse.group/t/moving-bar-question/406/3 "2017-07-24T19:13:07Z")

</div>

Attachment: [moving\_bar.xml](https://mworks.discourse.group/uploads/short-url/g7RPCLHrLEwAIQz4sXUFwMvyIla.xml) (2 KB)

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 25, 2017, 3:19pm UTC](https://mworks.discourse.group/t/moving-bar-question/406/4 "2017-07-25T15:19:26Z")

</div>

Hello Chris,  
Thank you for the quick reply. Indeed, this works great and it’s much smoother than my code. I will start fiddling with it.  
Cheers,  
Beshoy Agayby

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 19, 2022, 9:56pm UTC](https://mworks.discourse.group/t/moving-bar-question/406/5 "2022-07-19T21:56:30Z")

</div>

Closed on July 19, 2022, 9:56pm UTC


