Skip to content

Commit

Permalink
Demo triangle
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisVincent committed Dec 15, 2022
1 parent a9e05e8 commit 6812abb
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions demo/basic_shapes.ipynb
Expand Up @@ -94,6 +94,65 @@
"# Show\n",
"display(ui, out)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Triangle"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from stimuli.components.shapes import triangle\n",
"help(triangle)\n",
"\n",
"# Define widgets\n",
"w_height = iw.IntSlider(value=4, min=1, max=10, description=\"height [deg]\")\n",
"w_width = iw.IntSlider(value=4, min=1, max=10, description=\"width [deg]\")\n",
"w_ppd = iw.IntSlider(value=32, min=1, max=64, description=\"ppd\")\n",
"\n",
"w_intensities = iw.FloatRangeSlider(value=[0.0, 1.0], min=0.0, max=1.0, step=0.1, description=\"intensities\")\n",
"\n",
"# Layout\n",
"b_im_size = iw.HBox([w_height, w_width, w_ppd])\n",
"b_intensities = iw.HBox([w_intensities])\n",
"ui = iw.VBox([b_im_size, b_intensities])\n",
"\n",
"# Function for showing stim\n",
"def show_triangle(\n",
" height=None,\n",
" width=None,\n",
" ppd=None,\n",
" intensities=(0.0, 1.0)\n",
"):\n",
" stim = triangle(\n",
" visual_size=(height, width),\n",
" ppd=ppd,\n",
" intensity_triangle=intensities[1],\n",
" intensity_background=intensities[0]\n",
" )\n",
" plot_stim(stim, mask=False)\n",
"\n",
"# Set interactivity\n",
"out = iw.interactive_output(\n",
" show_triangle,\n",
" {\n",
" \"height\": w_height,\n",
" \"width\": w_width,\n",
" \"ppd\": w_ppd,\n",
" \"intensities\": w_intensities,\n",
" },\n",
")\n",
"\n",
"# Show\n",
"display(ui, out)"
]
}
],
"metadata": {
Expand Down

0 comments on commit 6812abb

Please sign in to comment.