Exemplo n.º 1
0
 def drawFlash(self, rowcol):
     #text enlargement mode
     if(isEnlargeTextMode):
         if(rowcol-1 < 6 and isDrawVertFlash):
             tmp = rowcol
             for i in range (len(self.words)):
                 if(i == tmp):
                     self.words[i].font_size = keyboardEnlargeFontSize
                     self.words[i].color = (keyboardEnlargeFontColour[0],keyboardEnlargeFontColour[1],keyboardEnlargeFontColour[2],keyboardEnlargeFontColour[3])
                     tmp = tmp +6
                 else:
                     self.words[i].font_size = keyboardFontSize
                     self.words[i].color = (keyboardFontColour[0],keyboardFontColour[1],keyboardFontColour[2],keyboardFontColour[3])
         elif(rowcol < 12 and isDrawHorizFlash):
             tmp = (rowcol-11)*-6
             for i in range (len(self.words)):
                 if(i == tmp and i < (rowcol-11)*-6 + 6):
                     self.words[i].font_size = keyboardEnlargeFontSize
                     self.words[i].color = (keyboardEnlargeFontColour[0],keyboardEnlargeFontColour[1],keyboardEnlargeFontColour[2],keyboardEnlargeFontColour[3])
                     tmp = tmp + 1
                 else:
                     self.words[i].font_size = keyboardFontSize                        
                     self.words[i].color = (keyboardFontColour[0],keyboardFontColour[1],keyboardFontColour[2],keyboardFontColour[3])
     
     if(isHighlightTextMode):    
         if (rowcol < 6 and isDrawVertFlash):
             primitives.drawRect(rowcol*width/6, 0, vertFlashSize[0], vertFlashSize[1], vertFlashColour[0],vertFlashColour[1],vertFlashColour[2],vertFlashColour[3])
         elif (rowcol < 12 and isDrawHorizFlash):
             primitives.drawRect(0, rowcol%6*height/12, horizFlashSize[0], horizFlashSize[1], horizFlashColour[0], horizFlashColour[1], horizFlashColour[2], horizFlashColour[3])
     return         
Exemplo n.º 2
0
 def drawHighlightText(self, rowcol):
     if isCrazyHighlightTextMode:
         self.generateRandomColour()
         vertFlashColour = self.colourCrazyNormalized
         self.generateRandomColour()
         horizFlashColour = self.colourCrazyNormalized
     else:
         vertFlashColour = vertFlashColourDefault
         horizFlashColour = horizFlashColourDefault
     if isHighlightTextMode:
         if rowcol <= 5 and isDrawVertFlash:
             primitives.drawRect(
                 rowcol * width / 6,
                 0,
                 vertFlashSize[0],
                 vertFlashSize[1],
                 vertFlashColour[0],
                 vertFlashColour[1],
                 vertFlashColour[2],
                 vertFlashColour[3],
             )
         elif rowcol <= 11 and isDrawHorizFlash:
             if isHighlightTextMode:
                 primitives.drawRect(
                     0,
                     rowcol % 6 * keyboardPositionTop / 5,
                     horizFlashSize[0],
                     horizFlashSize[1],
                     horizFlashColour[0],
                     horizFlashColour[1],
                     horizFlashColour[2],
                     horizFlashColour[3],
                 )
     return
Exemplo n.º 3
0
 def drawTarget(self, rowStim, colStim):
     if (isDrawTarget):
         rowNum = rowStim - OVTK_StimulationId_Label_01
         colNum = colStim - OVTK_StimulationId_Label_07
         x = colNum * width / 6
         y = (5-rowNum) * (keyboardPositionTop/6)
     primitives.drawRect(x, y, targetSize[0], targetSize[1], targetColour[0],targetColour[1],targetColour[2],targetColour[3])
     return
Exemplo n.º 4
0
 def drawFlash(self, rowcol):
     if isCrazyKeyboardEnlargeColour:
         self.generateRandomColour()
         keyboardEnlargeFontColour = self.colourCrazy
     else:
         keyboardEnlargeFontColour = keyboardEnlargeFontColourDefault
     #text enlargement mode
     if(isEnlargeTextMode):
         if(rowcol < 6 and isDrawVertFlash):
             tmp = rowcol
             for i in range (len(self.words)):
                 if(i == tmp):
                     self.words[i].font_size = keyboardEnlargeFontSize
                     self.words[i].color = keyboardEnlargeFontColour
                     self.words[i].bold = True
                     tmp = tmp +6
                 else:
                     self.words[i].font_size = keyboardFontSize
                     self.words[i].color = keyboardFontColour
                     self.words[i].bold = False
         elif(rowcol < 12 and isDrawHorizFlash):
             tmp = (rowcol-11)*-6
             for i in range (len(self.words)):
                 if(i == tmp and i < (rowcol-11)*-6 + 6):
                     self.words[i].font_size = keyboardEnlargeFontSize
                     self.words[i].color = keyboardEnlargeFontColour
                     self.words[i].bold = True
                     tmp = tmp + 1
                 else:
                     self.words[i].font_size = keyboardFontSize                        
                     self.words[i].color = keyboardFontColour
                     self.words[i].bold = False
     
     if(isHighlightTextMode):
         if(isCrazyHighlightTextMode):
             self.generateRandomColour()
             vertFlashColour = self.colourCrazyNormalized
             self.generateRandomColour()
             horizFlashColour = self.colourCrazyNormalized
         else:
             vertFlashColour = vertFlashColourDefault
             horizFlashColour = horizFlashColourDefault
         if (rowcol < 6 and isDrawVertFlash):
             primitives.drawRect(rowcol*width/6, 0, vertFlashSize[0], vertFlashSize[1], vertFlashColour[0],vertFlashColour[1],vertFlashColour[2],vertFlashColour[3])
         elif (rowcol < 12 and isDrawHorizFlash):
             primitives.drawRect(0, rowcol%6*keyboardPositionTop/5, horizFlashSize[0], horizFlashSize[1], horizFlashColour[0], horizFlashColour[1], horizFlashColour[2], horizFlashColour[3])
     if(isDrawCircleMode):
         self.drawCircle(rowcol)
     if(isDrawImageMode):
         self.drawImage(rowcol)
     return         
Exemplo n.º 5
0
 def startFlash(self, rowcol):
     # If column
     if rowcol <= 5 and isDrawVertFlash:
         if isEnlargeTextMode:
             c = rowcol
             for r in range(0, len(self.matrix)):
                 self.matrix[r][c].font_size = keyboardEnlargeFontSize
                 self.matrix[r][c].color = (
                     keyboardEnlargeFontColour[0],
                     keyboardEnlargeFontColour[1],
                     keyboardEnlargeFontColour[2],
                     keyboardEnlargeFontColour[3],
                 )
         if isHighlightTextMode:
             primitives.drawRect(
                 rowcol * width / 6,
                 0,
                 vertFlashSize[0],
                 vertFlashSize[1],
                 vertFlashColour[0],
                 vertFlashColour[1],
                 vertFlashColour[2],
                 vertFlashColour[3],
             )
     # If row
     elif rowcol <= 11 and isDrawHorizFlash:
         if isEnlargeTextMode:
             r = rowcol % 6
             for c in range(0, len(self.matrix[r])):
                 self.matrix[r][c].font_size = keyboardEnlargeFontSize
                 self.matrix[r][c].color = (
                     keyboardEnlargeFontColour[0],
                     keyboardEnlargeFontColour[1],
                     keyboardEnlargeFontColour[2],
                     keyboardEnlargeFontColour[3],
                 )
         if isHighlightTextMode:
             primitives.drawRect(
                 0,
                 rowcol % 6 * height / 12,
                 horizFlashSize[0],
                 horizFlashSize[1],
                 horizFlashColour[0],
                 horizFlashColour[1],
                 horizFlashColour[2],
                 horizFlashColour[3],
             )
     return
Exemplo n.º 6
0
    def drawSelection(self, rowStim, colStim, selectedStr):
        if (isDrawTarget):
            rowNum = rowStim - OVTK_StimulationId_Label_01
            colNum = colStim - OVTK_StimulationId_Label_07
            x = colNum * width / 6
            y = (5-rowNum) * (keyboardPositionTop/5)
        primitives.drawRect(x, y, targetSize[0], targetSize[1], targetColour[0],targetColour[1],targetColour[2],targetColour[3])

        # Make whole screen flash suddenly 
        glClearColor(1,1,1,1)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Set up background
        selectText = pyglet.text.Label(selectedStr, 
                font_name='Courier New',
                font_size=selectTextFontSize,
                color=(selectTextFontColour[0],selectTextFontColour[1],selectTextFontColour[2],selectTextFontColour[3]),
                x=width/2, y=height/2,
                anchor_x='center', anchor_y='center')
        selectText.draw()
        glClearColor(backgroundColour[0], backgroundColour[1], backgroundColour[2], backgroundColour[3])
        return 
Exemplo n.º 7
0
    def process(self): # Called on each box clock tick (this can be configured by right-clicking the box)
        self.count += 1
        self.count = self.count % 20
        if (self.count == 0):
            # Listen for rows/columns
            #rc_stim = self.getChunk(0)
            #if rc_stim:
            #    self.displayUpdate(rc_stim.identifier)
            self.label = random.randint(0,11) + 33024
            if (random.randint(0,9) == 9):
                # Listen for target
                #target_stim = self.getChunk(1)
                #if target_stim:
                #    print target_stim.identifier
                self.target[0] = random.randint(0,5)
                self.target[1] = random.randint(0,5)

        if self.win.has_exit:
            self.win.close()
            sys.exit()

        else:
            self.label2 = random.randint(0,12)
            self.target0 = random.randint(0,5)
            self.target1 = random.randint(0,6)
            
            if(self.num < self.constant):
                self.num = self.num+1
            
            if(self.keys[key.A] and self.num == self.constant):
                self.text = " A"    
                self.num = 0
                self.write = True
            
            if(self.num == (self.constant-1) and self.write):    
                self.widget.caret.on_text(self.text)

            self.win.dispatch_events()
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
            #draw text
            self.batch.draw() 
            #highlight vertical
            if self.label2 < 6:
                primitives.drawRect(self.label2*self.width/6,0,self.width/6,7*self.height/12,1,1,0,1)
            #highlight horizontal
            elif self.label2 < 13:
                primitives.drawRect(0,self.label2%7*self.height/12,self.width,self.height/12,1,1,0,1)
            #highlight target    
            primitives.drawRect(self.target0*self.width/6,self.target1*self.height/12,self.width/6,self.height/12,0,1,0,1)
            #draw keyboard
            self.words6.draw()
            self.words5.draw()
            self.words4.draw()
            self.words3.draw()
            self.words2.draw()
            self.words.draw()
            self.win.flip()
            # Send outputs
            self.sendOutput(1, self.label)
        return
Exemplo n.º 8
0
 def drawTarget(self, targetRow, targetCol):
     if(isDrawTarget):
         primitives.drawRect(targetCol*width/6, (5-targetRow)*height/12, targetSize[0], targetSize[1], targetColour[0],targetColour[1],targetColour[2],targetColour[3])
     return
Exemplo n.º 9
0
import word_display 
import random

if __name__=="__main__":
	#set window
    win = window.Window()
    win.set_fullscreen(True)
    
    #color background
    glClearColor(0.05882, 0.05882, 0.05882, 1.0)
    
    #set openGL stuff
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    
    #key event handlers
    keys = key.KeyStateHandler()
    win.push_handlers(keys)
  
  	#get window parameters
    user32 = ctypes.windll.user32
    width = user32.GetSystemMetrics(0) 
    height = user32.GetSystemMetrics(1) 

    while not win.has_exit:
        win.dispatch_events()
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        primitives.drawRect(0,height/2,width,height/2,20,20,20,1)
        primitives.drawRect(0,0,width,4,255,255,255,1)
        primitives.drawRect(0,0+height/12,width,4,255,255,255,1)
        win.flip()
Exemplo n.º 10
0
 def drawTarget(self, targetRow, targetCol):
     if(isDrawTarget):
         primitives.drawRect(targetCol*width/6, (5-targetRow)*(keyboardPositionTop/5), targetSize[0], targetSize[1], targetColour[0],targetColour[1],targetColour[2],targetColour[3])
     return