new GratingStim(options)
Grating Stimulus.
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Attributes |
Default |
Description |
name |
String
|
|
|
the name used when logging messages from this stimulus |
win |
Window
|
|
|
the associated Window |
tex |
String
|
HTMLImageElement
|
<optional>
|
"sin"
|
the name of the predefined grating texture or image resource or the HTMLImageElement corresponding to the texture |
mask |
String
|
HTMLImageElement
|
<optional>
|
|
the name of the mask resource or HTMLImageElement corresponding to the mask |
units |
String
|
<optional>
|
"norm"
|
the units of the stimulus (e.g. for size, position, vertices) |
sf |
number
|
<optional>
|
1.0
|
spatial frequency of the function used in grating stimulus |
phase |
number
|
<optional>
|
0.0
|
phase of the function used in grating stimulus, multiples of period of that function |
pos |
Array.<number>
|
<optional>
|
[0, 0]
|
the position of the center of the stimulus |
ori |
number
|
<optional>
|
0.0
|
the orientation (in degrees) |
size |
number
|
<optional>
|
|
the size of the rendered image (DEFAULT_STIM_SIZE_PX will be used if size is not specified) |
color |
Color
|
<optional>
|
"white"
|
Foreground color of the stimulus. Can be String like "red" or "#ff0000" or Number like 0xff0000. |
opacity |
number
|
<optional>
|
1.0
|
Set the opacity of the stimulus. Determines how visible the stimulus is relative to background. |
contrast |
number
|
<optional>
|
1.0
|
Set the contrast of the stimulus, i.e. scales how far the stimulus deviates from the middle grey. Ranges [-1, 1]. |
depth |
number
|
<optional>
|
0
|
the depth (i.e. the z order) |
interpolate |
boolean
|
<optional>
|
false
|
Whether to interpolate (linearly) the texture in the stimulus. Currently supports only image based gratings. |
blendmode |
String
|
<optional>
|
"avg"
|
blend mode of the stimulus, determines how the stimulus is blended with the background. Supported values: "avg", "add", "mul", "screen". |
autoDraw |
boolean
|
<optional>
|
false
|
whether or not the stimulus should be automatically drawn on every frame flip |
autoLog |
boolean
|
<optional>
|
false
|
whether or not to log |
|
- Source:
Extends
Members
(static) DEFAULT_STIM_SIZE_PX :Array
Default size of the Grating Stimuli in pixels.
Type:
- Default Value:
- Source:
(static) SHADERS :Object
An object that keeps shaders source code and default uniform values for them.
Shader source code is later used for construction of shader programs to create respective visual stimuli.
Type:
Properties:
Name |
Type |
Description |
imageShader |
Object
|
Renders provided image with applied effects (coloring, phase, frequency).
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for the image based grating stimuli. |
uniforms |
Object
|
default uniforms for the image based shader.
Properties
Name |
Type |
Default |
Description |
uFreq |
float
|
1.0
|
how much times image repeated within grating stimuli. |
uPhase |
float
|
0.0
|
offset of the image along X axis. |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
sin |
Object
|
Creates 2d sine wave image as if 1d sine graph was extended across Z axis and observed from above.
https://en.wikipedia.org/wiki/Sine_wave
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for the sine wave stimuli |
uniforms |
Object
|
default uniforms for sine wave shader
Properties
Name |
Type |
Default |
Description |
uFreq |
float
|
1.0
|
frequency of sine wave. |
uPhase |
float
|
0.0
|
phase of sine wave. |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
sqr |
Object
|
Creates 2d square wave image as if 1d square graph was extended across Z axis and observed from above.
https://en.wikipedia.org/wiki/Square_wave
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for the square wave stimuli |
uniforms |
Object
|
default uniforms for square wave shader
Properties
Name |
Type |
Default |
Description |
uFreq |
float
|
1.0
|
frequency of square wave. |
uPhase |
float
|
0.0
|
phase of square wave. |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
saw |
Object
|
Creates 2d sawtooth wave image as if 1d sawtooth graph was extended across Z axis and observed from above.
https://en.wikipedia.org/wiki/Sawtooth_wave
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for the sawtooth wave stimuli |
uniforms |
Object
|
default uniforms for sawtooth wave shader
Properties
Name |
Type |
Default |
Description |
uFreq |
float
|
1.0
|
frequency of sawtooth wave. |
uPhase |
float
|
0.0
|
phase of sawtooth wave. |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
tri |
Object
|
Creates 2d triangle wave image as if 1d triangle graph was extended across Z axis and observed from above.
https://en.wikipedia.org/wiki/Triangle_wave
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for the triangle wave stimuli |
uniforms |
Object
|
default uniforms for triangle wave shader
Properties
Name |
Type |
Default |
Description |
uFreq |
float
|
1.0
|
frequency of triangle wave. |
uPhase |
float
|
0.0
|
phase of triangle wave. |
uPeriod |
float
|
1.0
|
period of triangle wave. |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
sinXsin |
Object
|
Creates an image of two 2d sine waves multiplied with each other.
https://en.wikipedia.org/wiki/Sine_wave
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for the two multiplied sine waves stimuli |
uniforms |
Object
|
default uniforms for shader
Properties
Name |
Type |
Default |
Description |
uFreq |
float
|
1.0
|
frequency of sine wave (both of them). |
uPhase |
float
|
0.0
|
phase of sine wave (both of them). |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
sqrXsqr |
Object
|
Creates an image of two 2d square waves multiplied with each other.
https://en.wikipedia.org/wiki/Square_wave
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for the two multiplied sine waves stimuli |
uniforms |
Object
|
default uniforms for shader
Properties
Name |
Type |
Default |
Description |
uFreq |
float
|
1.0
|
frequency of sine wave (both of them). |
uPhase |
float
|
0.0
|
phase of sine wave (both of them). |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
circle |
Object
|
Creates a filled circle shape with sharp edges.
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for filled circle. |
uniforms |
Object
|
default uniforms for shader.
Properties
Name |
Type |
Default |
Description |
uRadius |
float
|
1.0
|
Radius of the circle. Ranges [0.0, 1.0], where 0.0 is circle so tiny it results in empty stim
and 1.0 is circle that spans from edge to edge of the stim. |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
gauss |
Object
|
Creates a 2d Gaussian image as if 1d Gaussian graph was rotated arount Y axis and observed from above.
https://en.wikipedia.org/wiki/Gaussian_function
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for Gaussian shader |
uniforms |
Object
|
default uniforms for shader
Properties
Name |
Type |
Default |
Description |
uA |
float
|
1.0
|
A constant for gaussian formula (see link). |
uB |
float
|
0.0
|
B constant for gaussian formula (see link). |
uC |
float
|
0.16
|
C constant for gaussian formula (see link). |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
cross |
Object
|
Creates a filled cross shape with sharp edges.
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for cross shader |
uniforms |
Object
|
default uniforms for shader
Properties
Name |
Type |
Default |
Description |
uThickness |
float
|
0.2
|
Thickness of the cross. Ranges [0.0, 1.0], where 0.0 thickness makes a cross so thin it becomes
invisible and results in an empty stim and 1.0 makes it so thick it fills the entire stim. |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
radRamp |
Object
|
Creates 2d radial ramp image.
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for radial ramp shader |
uniforms |
Object
|
default uniforms for shader
Properties
Name |
Type |
Default |
Description |
uSqueeze |
float
|
1.0
|
coefficient that helps to modify size of the ramp. Ranges [0.0, Infinity], where 0.0 results in ramp being so large
it fills the entire stim and Infinity makes it so tiny it's invisible. |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
raisedCos |
Object
|
Creates 2d raised-cosine image as if 1d raised-cosine graph was rotated around Y axis and observed from above.
https://en.wikipedia.org/wiki/Raised-cosine_filter
Properties
Name |
Type |
Description |
shader |
String
|
shader source code for raised-cosine shader |
uniforms |
Object
|
default uniforms for shader
Properties
Name |
Type |
Default |
Description |
uBeta |
float
|
0.25
|
roll-off factor (see link). |
uPeriod |
float
|
0.625
|
reciprocal of the symbol-rate (see link). |
uAlpha |
float
|
1.0
|
value of the alpha channel. |
|
|
- Source:
setBlendmode
Set blend mode of the grating stimulus.
- Source:
setColor
Set foreground color value for the grating stimulus.
- Source:
setColorSpace
Set color space value for the grating stimulus.
- Source:
setInterpolate
Whether to interpolate (linearly) the texture in the stimulus.
- Source:
setMask
Setter for the mask attribute.
- Source:
setOpacity
Determines how visible the stimulus is relative to background.
- Source:
setPhase
Set phase value for the function.
- Source:
setSF
Set spatial frequency value for the function.
- Source:
setTex
Setter for the tex attribute.
- Source:
Methods
(protected) _estimateBoundingBox()
Estimate the bounding box.
- Source:
(protected) _getPixiMeshFromPredefinedShaders(shaderName, uniforms) → {Pixi.Mesh}
Generate PIXI.Mesh object based on provided shader function name and uniforms.
Parameters:
Name |
Type |
Description |
shaderName |
String
|
name of the shader. Must be one of the SHADERS |
uniforms |
Object
|
a set of uniforms to supply to the shader. Mixed together with default uniform values. |
- Source:
Returns:
Pixi.Mesh object that represents shader and later added to the scene.
-
Type
-
Pixi.Mesh