sweetbean.stimulus.Symbol
Symbol
Bases: _BaseStimulus
SweetBean wrapper for window.jsPsychSymbol (string type: "symbol").
Minimal + safe conveniences:
- Pass items (list[dict] or Var) directly, OR provide a top-level shape
to spawn a single-item list.
- Top-level color/texture broadcast to items that haven't set their own
(only when items is a concrete list).
- If items is a Variable (TimelineVariable, FunctionVariable, etc.), it is
forwarded unchanged and no expansion/broadcast is attempted
(to avoid incorrect compile-time assumptions).
Python API (snake_case) -> plugin (camelCase): canvas_width -> canvasWidth canvas_height -> canvasHeight background -> background items -> items duration -> trialDuration response_ends_trial -> responseEndsTrial choices -> choices allow_mouse -> allowMouse
Source code in sweetbean/stimulus/Symbol.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
__init__(*, canvas_width=800, canvas_height=600, background='transparent', items=None, shape=None, color=None, texture=None, duration=None, response_ends_trial=True, choices=None, allow_mouse=False, correct_key=None, side_effects=None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas_width
|
int
|
Canvas width in px. Default 800. |
800
|
canvas_height
|
int
|
Canvas height in px. Default 600. |
600
|
background
|
str
|
Page background CSS color. Default "transparent". |
'transparent'
|
items
|
list[dict] | None
|
List of shape dicts. Each item supports: Required - shape: one of "circle" | "ring" | "rectangle" | "triangle" | "cross" Size (by shape) - circle : radius (int) - ring : innerRadius (int), outerRadius (int) - rectangle : width (int), height (int), cornerRadius (int, opt) - triangle : side (int) - cross : armLen (int), armWidth (int) Common (optional) - x, y : int. Position in px relative to center (default 0,0) - z : int. Draw order; higher draws later (default 0) - rotation : float deg, clockwise from vertical (default 0) - alpha : float 0..1 (default 1) - blend : canvas comp-op string. One of: "source-over","lighter","multiply","screen", "overlay","darken","lighten","difference", "exclusion","hard-light","soft-light" - color : CSS color string; used if no texture (default "#000") - texture : dict (see Texture below) - stroke : CSS color string (outline). Optional. - strokePx : int stroke width (px). Optional. |
None
|
shape
|
str | None
|
Fast path. If set and |
None
|
color
|
str | None
|
Broadcast fill color to any item that lacks "color". Also applied to the fast-path single item. |
None
|
texture
|
dict | None
|
Broadcast texture to any item that lacks "texture". Also applied to the fast-path single item. |
None
|
duration
|
int | None
|
Trial timeout in ms. Mapped to plugin key |
None
|
response_ends_trial
|
bool
|
If True, end on first valid response. |
True
|
choices
|
list[str] | str | None
|
Allowed keys. None/""/"NO_KEYS" → []; "ALL"/"ALL_KEYS" → "ALL_KEYS"; a single string becomes [that string]. |
None
|
allow_mouse
|
bool
|
If True, mouse click counts as a response. |
False
|
correct_key
|
str | None
|
Copied into data; enables simple correctness. |
None
|
side_effects
|
dict | None
|
SweetBean side-effects configuration. |
None
|
Texture
|
A texture is a dict with a "type" and type-specific fields.
|
required |
Source code in sweetbean/stimulus/Symbol.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |