Randomize images using canvas

Corona shunyata.aishwarya at gmail.com
Sat Sep 22 02:21:15 UTC 2012


Hello everyone, 

I managed to find a way to randomize images using 'random'. I am however 
having trouble finding documentation that allows one to record mouse click 
responses, and corresponding mouse co-ordinates using canvas option. I 
realize the inflexilibility in not using the input mask option, but my code 
is structured as such. A portion of my code is shown below:

'use the Canvas method to create an active display canvas
Set cnvs = Display.Canvas

'use the CreateCanvas to create an off-screen canvas for neg left
Set offScreenCnvsNeg1 = Display.CreateCanvas

''use the CreateCanvas to create an off-screen canvas for pos left
Set offScreenCnvsPos1 = Display.CreateCanvas

'use the CreateCanvas to create an off-screen canvas for neg right
Set offScreenCnvsNeg2 = Display.CreateCanvas

''use the CreateCanvas to create an off-screen canvas for pos right
Set offScreenCnvsPos2 = Display.CreateCanvas


'Define the copy area
Dim LeftNegSrc As Rect
Dim LeftNegDest As Rect
Dim LeftPosSrc As Rect
Dim LeftPosDest As Rect


Dim RightNegSrc As Rect
Dim RightNegDest As Rect
Dim RightPosSrc As Rect
Dim RightPosDest As Rect


Const RECT_WIDTH = 424
Const RECT_HEIGHT = 283

'Prepare the rectangles that would be used to draw the offscreen 
'rectangles and the display destination rectangle for where it will
'be drawn to the screen. 

'Allow the src rectangles Left and Top coordinates to describe/cover the 
'range of Left and Right options that can be chosen. Setting Left and Top 
'to zero means you can choose Left and Right as anything in the dest rect.

'Right, Bottom options are restricted/defined by width -no flexibility 
'in this option.

'In our case, width,height were respectively defined as 424, 283, given
'the image dimensions.

'NEGATIVE IMAGES: LHS:

'define src rect
LeftNegSrc.Left = 0
LeftNegSrc.Top = 0 
LeftNegSrc.Right =  LeftNegSrc.Left + RECT_WIDTH
LeftNegSrc.Bottom = LeftNegSrc.Top + RECT_HEIGHT 

'define dest rect
LeftNegDest.Left = 100
LeftNegDest.Top =   220
LeftNegDest.Right = LeftNegDest.Left + RECT_WIDTH 
LeftNegDest.Bottom = LeftNegDest.Top + RECT_HEIGHT


'POSITIVE IMAGES FOR LHS OF SCREEN

'define src rect
LeftPosSrc.Left = 0
LeftPosSrc.Top = 0 
LeftPosSrc.Right =  LeftPosSrc.Left + RECT_WIDTH
LeftPosSrc.Bottom = LeftPosSrc.Top + RECT_HEIGHT 

'define dest rect
LeftPosDest.Left = 100
LeftPosDest.Top =   220
LeftPosDest.Right = LeftPosDest.Left + RECT_WIDTH 
LeftPosDest.Bottom = LeftPosDest.Top + RECT_HEIGHT




'NEGATIVE IMAGES: RHS:

'define src rect
RightNegSrc.Left = 0
RightNegSrc.Top = 0 
RightNegSrc.Right =  RightNegSrc.Left + RECT_WIDTH
RightNegSrc.Bottom = RightNegSrc.Top + RECT_HEIGHT 

'define dest rect
RightNegDest.Left = 767
RightNegDest.Top =   220
RightNegDest.Right = RightNegDest.Left + RECT_WIDTH 
RightNegDest.Bottom = RightNegDest.Top + RECT_HEIGHT



'POSITIVE IMAGES FOR RHS OF SCREEN

'define src rect
RightPosSrc.Left = 0
RightPosSrc.Top = 0 
RightPosSrc.Right =  RightPosSrc.Left + RECT_WIDTH
RightPosSrc.Bottom = RightPosSrc.Top + RECT_HEIGHT 

'define dest rect
RightPosDest.Left = 767
RightPosDest.Top =   220
RightPosDest.Right = RightPosDest.Left + RECT_WIDTH 
RightPosDest.Bottom = RightPosDest.Top + RECT_HEIGHT

offScreenCnvsNeg1.clear
offScreenCnvsPos1.clear
offScreenCnvsNeg2.clear
offScreenCnvsPos2.clear


select case random(1,2)
   case 1
     offScreenCnvsNeg1.LoadImage c.GetAttrib("NegativeImage")
 cnvs.Copy offScreenCnvsNeg1, LeftNegSrc, LeftNegDest
 offScreenCnvsPos1.LoadImage c.GetAttrib("PositiveImage")
     cnvs.Copy offScreenCnvsPos1, RightPosSrc, RightPosDest
     sleep(4000) 
 offScreenCnvsPos1.LoadImage c.GetAttrib("Prompt")
 cnvs.Copy offScreenCnvsPos1, RightPosSrc, RightPosDest
 sleep(3000)
 
Dim theMouseResponseData As MouseResponseData 

        'Get the mouse response 
        Set theMouseResponseData = 
CMouseResponseData(offScreenCnvsPos1.InputMasks.Responses(1)) 

        'Determine string name of SlideImage or SlideText object at 
        'mouse click coordinates. Assign that value to strHit 
        strHit = theState.HitTest(theMouseResponseData.CursorX, 
theMouseResponseData.CursorY) 
     case 2
    offScreenCnvsNeg2.LoadImage c.GetAttrib("NegativeImage")
    cnvs.Copy offScreenCnvsNeg2, RightNegSrc, RightNegDest
offScreenCnvsPos2.LoadImage c.GetAttrib("PositiveImage")
cnvs.Copy offScreenCnvsPos2, LeftPosSrc, LeftPosDest
    sleep(4000)
end select

Please let me  know what I can do to collect responses, assuming I have a 
prompt image that shows up in wither of the four rect options.

Thanks again,
Corona

On Friday, September 21, 2012 3:03:41 PM UTC-4, Corona wrote:
>
> Thank you for all your help in setting up the canvas images for the dot 
> probe task. I think I was advised to use this option because we will be 
> collecting pixel co-ordinate information, as well integrating other 
> components into the task (eye tracking for example).
>
> My canvas script allows me to load images side by side (say positive and 
> negative). However, I am not sure how to randomize the locations in which 
> the images appear (as in - positive images should randomly show up in 
> either the left side or right, and similarly for the negative) . At any 
> point, the screen has a positive and negative image pair, but the location 
> (i.e. whether right or left) in which either of the two appear is unknown. 
> My guess was to use the nested property to specify location, but I am not 
> sure how to get this attribute (given that it is in a nested list) in the 
> inline script for canvas. I am sorry if this sounds convoluted.Any help 
> would be appreciated.
>
> Thanks,
> Corona
>

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/e-prime/-/YLc9an3HmM0J.
For more options, visit https://groups.google.com/groups/opt_out.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20120921/62d3dc52/attachment.htm>


More information about the Eprime mailing list