Skip to content

Commit

Permalink
added animation article, minor fixs to other articles
Browse files Browse the repository at this point in the history
  • Loading branch information
banchan86 committed May 13, 2024
1 parent f11513d commit d16c601
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 4 deletions.
42 changes: 41 additions & 1 deletion docs/articles/stimuli-animating.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
# Animating Stimuli
## Under Construction

## Manipulating Parameters of Drawing Stimuli Nodes.
Basic animation in `BonVision` involves manipulating one or more properties in a `DrawX` node. For instance, to make a circle
move across the screen, you would vary the `LocationX` parameter in a `DrawCircle` node.

To get started:
1) Right click on any `DrawX` node and externalize the property you want to manipulate.
2) `BonVision` provides a `RangeAnimation` operator to generate a linear range of values for a specified duration of time. Connect a `RangeAnimation` operator to the parameter you externalized and change the `RangeBegin`, `RangeEnd` and `Duration`.
3) Add a `Repeat` operator if you want the animation to repeat between the `RangeAnimation` and `DrawX` node.

The workflow will look something like this (which shows a circle moving across the screen repeatedly)

:::workflow
![Create Window](../workflows/animating-stimuli-circle-locationx.bonsai)
:::

> [!Note]
> The `RangeBegin` and `RangeEnd` parameter depends on the [drawing region](drawing-region.md). For a `NormalizedView` -1 to 1 represents the edges of the screen.
> [!Note]
> To vary more than 1 parameter at a time if they share the same `RangeAnimation` parameters, you can externalize more than 1 property at a time and they will be grouped together.
> To prevent parameters from being grouped together, connect a `RangeAnimation` operator to the first externalized property before externalizing a second property.
<div style="max-width: 500px">
<iframe width=100% height=282 src="https://www.youtube.com/embed/YUNJNsJj6co" title="BonVision quick tips: Making a animated feature" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div>

For an additional example of this, see the `Looming/Sweeping` demo in the [Demo](/demos/VR-demo.md) page.


## Animating stimuli with moving viewing window/perspective view
- this sounds like it should be possible but I need to look at an example.









2 changes: 1 addition & 1 deletion docs/articles/stimuli-multiple.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ For a video walkthrough of this process, see this youtube video.


### Presenting multiple stimuli sequentially
To present multiple stimuli sequentially, we can use the same `PublishSubject` and `SubscribeSubject` operators but add timers to them. Timing will be covered in the [Timing Stimuli](stimuli-timing.bonsai)
To present multiple stimuli sequentially, we can use the same `PublishSubject` and `SubscribeSubject` operators but add timers to them. Timing will be covered in the [Timing Stimuli](stimuli-timing.md) article,
2 changes: 1 addition & 1 deletion docs/articles/stimuli-timing.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ subject movement (for instance when an animal crosses into an arena).
## Video Walkthrough
For a video walkthrough of many of the steps covered in this article, check out this youtube video.
<div style="max-width: 500px">
<iframe width=100% height="720" src="https://www.youtube.com/embed/yHQFbI69UHw" title="BonVision quick tips: Timing a stimulus" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
<iframe width=100% height="282" src="https://www.youtube.com/embed/yHQFbI69UHw" title="BonVision quick tips: Timing a stimulus" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div>


Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BonVision’s key features include:
<iframe width=100% height = 282 src="https://www.youtube.com/embed/e_5W503W1AI?si=QuYZu-T7V7G7mwXA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div>

[!Video https://www.youtube.com/embed/e_5W503W1AI?si=QuYZu-T7V7G7mwXA]{width=500}
> [!Video https://www.youtube.com/embed/e_5W503W1AI?si=QuYZu-T7V7G7mwXA]{width=500}

More Bonvision videos on specific topics can be found on our [youtube channel](https://www.youtube.com/channel/UCEg-3mfbvjIwbzDVvqYudAA).
Expand Down
89 changes: 89 additions & 0 deletions docs/workflows/animating-stimuli-circle-locationx.bonsai
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gl="clr-namespace:Bonsai.Shaders;assembly=Bonsai.Shaders"
xmlns:res="clr-namespace:Bonsai.Resources;assembly=Bonsai.System"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
<Expression xsi:type="Combinator">
<Combinator xsi:type="gl:CreateWindow">
<gl:Width>640</gl:Width>
<gl:Height>480</gl:Height>
<gl:VSync>On</gl:VSync>
<gl:SwapSync>false</gl:SwapSync>
<gl:ClearColor>Gray</gl:ClearColor>
<gl:ClearMask>DepthBufferBit ColorBufferBit</gl:ClearMask>
<gl:CursorVisible>true</gl:CursorVisible>
<gl:Location xsi:nil="true" />
<gl:WindowBorder>Resizable</gl:WindowBorder>
<gl:WindowState>Normal</gl:WindowState>
<gl:DisplayDevice>Primary</gl:DisplayDevice>
<gl:TargetRenderFrequency>60</gl:TargetRenderFrequency>
<gl:TargetUpdateFrequency xsi:nil="true" />
<gl:RenderState />
<gl:GraphicsMode>
<gl:ColorFormat>
<gl:Red>8</gl:Red>
<gl:Green>8</gl:Green>
<gl:Blue>8</gl:Blue>
<gl:Alpha>8</gl:Alpha>
</gl:ColorFormat>
<gl:Depth>16</gl:Depth>
<gl:Stencil>0</gl:Stencil>
<gl:Samples>0</gl:Samples>
<gl:AccumulatorFormat>
<gl:Red>0</gl:Red>
<gl:Green>0</gl:Green>
<gl:Blue>0</gl:Blue>
<gl:Alpha>0</gl:Alpha>
</gl:AccumulatorFormat>
<gl:Buffers>2</gl:Buffers>
<gl:Stereo>false</gl:Stereo>
</gl:GraphicsMode>
</Combinator>
</Expression>
<Expression xsi:type="IncludeWorkflow" Path="BonVision:Primitives.BonVisionResources.bonsai" />
<Expression xsi:type="Combinator">
<Combinator xsi:type="res:LoadResources" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="gl:RenderFrame" />
</Expression>
<Expression xsi:type="IncludeWorkflow" Path="BonVision:Environment.NormalizedView.bonsai" />
<Expression xsi:type="IncludeWorkflow" Path="BonVision:Primitives.RangeAnimation.bonsai">
<Duration>4</Duration>
<RangeBegin>-1</RangeBegin>
<RangeEnd>1</RangeEnd>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Repeat" />
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="LocationX" />
</PropertyMappings>
</Expression>
<Expression xsi:type="IncludeWorkflow" Path="BonVision:Primitives.DrawCircle.bonsai">
<Diameter>0.5</Diameter>
<LocationX>-0.7916667</LocationX>
<LocationY>0</LocationY>
<Layer>0</Layer>
<ColorR>0</ColorR>
<ColorG>0</ColorG>
<ColorB>0</ColorB>
<ColorA>1</ColorA>
</Expression>
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="3" To="4" Label="Source1" />
<Edge From="4" To="8" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="6" To="7" Label="Source1" />
<Edge From="7" To="8" Label="Source2" />
</Edges>
</Workflow>
</WorkflowBuilder>

0 comments on commit d16c601

Please sign in to comment.