The easiest way to learn the drawing commands is to use them for a practical task: here I will draw two response buttons on the screen for a subject to click in.
Using the built-in drawing commands, we can accomplish this in just a few lines:
tell application
"PsyScript"
reset all
activate
begin experiment
set
word size
to 28
set
word color
to {32000,
32000, 32000}
draw rectangle
in {50,
50, 150,
100} corner
rounding {5,
5} using
{pen color:green}
with filling
draw rectangle
in {160,
50, 260,
100} corner
rounding {5,
5} using
{pen color:red}
with filling
do trial
"'YES'(?1) 'NO'(?2) "
given {{100,
85}, {210,
85}}
end experiment
end tell
Running this script shows this image on screen:
You can learn about the other drawing commands for ovals and lines and beier curves by looking in the PsyScript dictionary and in the "example scripts folder": they are pretty self explanatory.
To create an image as a permanent stimulus (i.e., loaded into memory for display later), you simply wrap your drawing commands inside line to create a new permanent stimulus with the dimensions you want(like a blank canvas in memory), set the drawing target to point to this stimulus, then after doing any drawing you need, setting the drawing target back to the screen ("null"). Now the permanent stimulus contains your drawing and is available just like any other permanent stimulus.
tell
application
"PsyScript"
set
stim1
to
(make
new
permanent stimulus
with properties
¬
{type:picture
stimulus, name:"yes_no",
dimensions:{500,
400},
pixel depth:(get
screen depth)})
set
drawing target
to
stim1
-- insert
your drawing commands here
activate
begin
experiment
do
trial "•yes_no"
--call your stimulus by its "name"
property
end
experiment
end
tell
To save the drawing as a file object, just save the object to file, as shown below.
tell
application
"PsyScript"
set
newStimulus
to
(make
new
permanent stimulus
with properties
¬
{type:picture
stimulus, name:"yes_no",
dimensions:{500,
400},
pixel depth:(get
screen depth)})
set
drawing target
to
stim1
--insert
your drawing commands here
save
newStimulus
output to
file
"Smiley Face"
if exists
overwrite
end
tell
The drawing system uses a pen to draw one of a set of objects
The pen has a color and size, which you can set on a default basis using
set default drawing settings to {pen size:{4, 4}, pen color:yellow}
Colors can be set using predefined names {blue,red, yellow etc.}, or as RGB lists
RGB stands for building colors by mixing RED, GREEN, and BLUE. Each component color has an intensity which you set between 0 (not at all) and 65535 (100%). 65535 looks funny until you realise it is 2^16.
So saying pen color:{0, 65535, 0} is the same as saying pen color:green
You can override the default pen settings for each drawing action by adding a using {pen properties statement} to a particular drawing command (see examples below).
You can draw rectangles, ovals, arcs, and lines: Simple examples of drawing are
draw
rectangle in
{0,
0,
300,
300}
with
filling
draw
rectangle in
{0,
0,
300,
300}
using
{pen color:{0,
0,
65535}}
without filling
draw
line from
{50,
40}
to
{100,
40}
draw
oval in
{50,
50,
100,
100}
without
filling
draw
line from
{200,
40}
to
{250,
40}
draw
oval in
{200,
50,
250,
100}
using
{pen color:white}
with
filling
draw
oval in
{200,
50,
250,
100}
without
filling
draw
rectangle in
{125,
62,
175,
212}
corner rounding
{8,
16}
with
filling
draw
arc in
{50,
170,
250,
270}
starting angle
90
arc angle
180
using
{pen color:red,
pen size:{8,
32}}
without
filling
Check out the examples in "showing stimuli:image creation"
| MACCS | |
Documentation | Downloads | FAQ | Mailing List | Last change: echo date( "F d Y.", getlastmod() ); ?> |
| Advanced Search |