Visual display is largely handled by the methods defined in Images
. However, this objects must be prepared by Weber using visual
and then a call to display
is made to show the visual. The call to visual
is normally handled automatically for you when you call moment
.
Base.Multimedia.display
— Function.display(r::SDLRendered;kwds...)
Displays anything rendered by visual
onto the current experiment window.
Any keyword arguments, available from visual
are also available here. They overload the arguments as specified during visual (but do not change them).
display(x;kwds...)
Short-hand for display(visual(x);kwds...)
. This is the most common way to use display. For example:
moment(0.5s,display,"Hello, World!")
This code will show the text "Hello, World!" on the screen 0.5 seconds after the start of the previous moment.
Assuming your hardware and video drivers permit it, display
sycnrhonizes to the screen refresh rate so long as the experiment window uses accelerated graphics (true by default). The display of a visual can be no more accurate than that permitted by this refresh rate. In particular, display can block for up to the length of an entire refresh cycle. If you want accurate timing in your experiment, make sure that there is nothing you want to occur immediately after calling display. If you want to display multiple visuals at once remember that you can compose visuals using the +
operator, do not call display multiple times and expect these visual to all display at the same time (also note that the default behavior of visuals is to disappear when the next visual is shown).
display(fn::Function;kwds...)
Display the visual returned by calling fn
.
Weber.visual
— Function.visual(obj,[duration=0s],[priority=0],keys...)
Render an object, allowing display
to show the object in current experiment's window.
Arguments
duration: A positive duration means the object is displayed for the given duration, otherwise the object displays until a new object is displayed.
priority: Higher priority objects are always visible above lower priority ones. Newer objects display over same-priority older objects.
If coordinates are used they are in units of half screen widths (for x) and heights (for y), with (0,0) at the center of the screen.
By using using the +
operator, multiple visual objects can be composed into one object, so that they are displayed together
visual(color,[duration=0s],[priority=0])
Render a color, across the entire screen.
visual(str::String, [font=nothing], [font_name="arial"], [size=32],
[color=colorant"white"],
[wrap_width=0.8],[clean_whitespace=true],[x=0],[y=0],[duration=0s],
[priority=0])
Render the given string as an image that can be displayed. An optional second argument can specify a font, loaded using the font
function.
If the string passed refers to an image file–becasue the string ends in a file type, like .bmp or .png–-it will be treated as an image to be loaded and displayed, rather than as a string to be printed to the screen. Refer to the documentation of visual
for image objects.
Arguments
wrap_width: the proporition of the screen that the text can utilize before wrapping.
clean_whitespace: if true, replace all consecutive white space with a single space.
visual(img, [x=0],[y=0],[duration=0s],[priority=0])
Prepare the color or gray scale image to be displayed to the screen.
For a string or file reference, this loads and prepares for display the given image file. For an array this utilizes all the conventions in the Images
package for representing images. Internally, real-number 2d arrays are interpreted as gray scale images, and real-number 3d arrays as an RGB image or RGBA image, depending on whether size(img,1) is of size 3 or 4. A 3d array with a size(img,1) ∉ [3,4] results in an error.
Weber.instruct
— Function.instruct(str;keys...)
Presents some instructions to the participant.
This adds "(Hit spacebar to continue...)" to the end of the text, and waits for the participant to press spacebar to move on. It records an "instructions" event to the data file.
Any keyword arguments are passed onto to visual
, which can be used to adjust how the instructions are displayed.
Weber.font
— Function.font(name,size,[dirs=os_default],[color=colorant"white"])
Creates an SDLFont
object to be used for for rendering text as an image.
By default this function looks in the current directory and then an os specific default font directory for a font with the given name (case insensitive). You can specify a different list of directories using the dirs
parameter.
Weber.window
— Function.window([width=1024],[height=768];[fullscreen=true],[title="Experiment"],
[accel=true])
Create a window to which various objects can be rendered. See the visual
method.
Base.close
— Function.close(win::SDLWindow)
Closes a visible SDLWindow window.