Exemplo n.º 1
0
	def __init__(self,widget,handimage,shadowimage,scale,pivot_x,pivot_y,center_x,center_y,shadowlevel):
		self.imgshadow=karamba.createImage(widget,0,0,shadowimage)
		self.imghand=karamba.createImage(widget,0,0,handimage)
		hw=karamba.getImageWidth(widget,self.imghand)
		hh=karamba.getImageHeight(widget,self.imghand)
		r1=math.sqrt((pivot_x*pivot_x)+(pivot_y*pivot_y))
		r4=r1
		a1=math.pi-math.asin(pivot_y/r1)
		a4=2.0*math.pi-a1
		r2=math.sqrt((pivot_y*pivot_y)+((hw-pivot_x)*(hw-pivot_x)))
		r3=r2
		a2=math.asin(pivot_y/r2)
		a3=-a2
		self.a1=a1
		self.a2=a2
		self.a3=a3
		self.a4=a4
		self.r1=r1*scale
		self.r2=r2*scale
		self.r3=r3*scale
		self.r4=r4*scale
		self.center_x=center_x
		self.center_y=center_y
		self.shadowlevel=shadowlevel
		self.prev=0.0	#prevents rotating etc. if not required
Exemplo n.º 2
0
def widgetUpdated(widget):
    global images, c
    
    b = c%2

    # Create & delete
    if(images[0]):
      karamba.deleteImage(widget, images[0])
      images[0] = 0
    else:
      images[0] = karamba.createImage(widget, 0, 20, "flag.png")
			
    # Hide & Show
    if(b):
      karamba.hideImage(widget, images[1])
    else:
      karamba.showImage(widget, images[1])
    
    # size & resize
    size = karamba.getImageSize(widget, images[1])
    print "getImageSize: " + str(size)
    print "getImageWidth: " + str(karamba.getImageWidth(widget, images[1]))
    print "getImageHeight: " + str(karamba.getImageHeight(widget, images[1]))
    # Auto size
    #size = ((b * 200) + 200, size[1])    
    #karamba.resizeImage(widget, images[1], size[0], size[1])
    
    # pos & move
    pos = karamba.getImagePos(widget, images[2])
    print "getImagePos: " + str(pos)
    pos = (b * 200, pos[1])    
    karamba.moveImage(widget, images[2], pos[0], pos[1])
    
    # Sensor
    sensor = karamba.getImageSensor(widget, images[3])
    print "getSensor: " + str(sensor)
    if(b):
      karamba.setImageSensor(widget, images[3], 'SENSOR=PROGRAM  PROGRAM="/tmp/test1.sh"')
    else:
      karamba.setImageSensor(widget, images[3], 'SENSOR=PROGRAM  PROGRAM="/tmp/test2.sh"')
      
    # Value
    v = karamba.getImagePath(widget, images[4])
    print "getImagePath: ", v
    if(b):
      v = 'flag.png'
    else:
      v = 'flag2.png'
    karamba.setImagePath(widget, images[4], v)
    
    if((c % 10) == 0):
      karamba.removeImageEffects(widget, images[5])
      karamba.removeImageEffects(widget, images[6])
      karamba.removeImageEffects(widget, images[7])
    else:
      karamba.changeImageIntensity(widget, images[5], (float(c%10) / 5 - 1.0))
      karamba.changeImageChannelIntensity(widget, images[6], (float(c%10) / 5 - 1.0), 'blue')
      karamba.changeImageToGray(widget, images[7], 0)

    if((c % 9) == 0):
      karamba.removeImageTransformations(widget, images[8])
      karamba.removeImageTransformations(widget, images[9])
      karamba.removeImageTransformations(widget, images[10])
    else:
      karamba.rotateImage(widget, images[8], (c%9)*20 + 45)
      karamba.resizeImage(widget, images[9], 50 + (c%5)*10, size[1])
      karamba.resizeImageSmooth(widget, images[10], 50 + (c%5)*10, size[1])
      
    if((c % 10) == 0):
      karamba.addImageTooltip(widget, images[11], str(c))
      
    if((c % 20) == 0):
      if(images[12]):
        karamba.deleteImage(widget, images[12])
        images[12] = 0
      else:
        images[12] = karamba.createBackgroundImage(widget, 0, 340, "flag.png")
    
    if(images[13]):
      karamba.deleteImage(widget, images[13])
      images[13] = 0
    else:
      tlist = karamba.getTaskList(widget)
      images[13] = karamba.createTaskIcon(widget, 50, 340, tlist[c % len(tlist)])
      
    c += 1
Exemplo n.º 3
0
def widgetUpdated(widget):
    global images, c

    b = c % 2

    # Create & delete
    if (images[0]):
        karamba.deleteImage(widget, images[0])
        images[0] = 0
    else:
        images[0] = karamba.createImage(widget, 0, 20, "flag.png")

    # Hide & Show
    if (b):
        karamba.hideImage(widget, images[1])
    else:
        karamba.showImage(widget, images[1])

    # size & resize
    size = karamba.getImageSize(widget, images[1])
    print "getImageSize: " + str(size)
    print "getImageWidth: " + str(karamba.getImageWidth(widget, images[1]))
    print "getImageHeight: " + str(karamba.getImageHeight(widget, images[1]))
    # Auto size
    #size = ((b * 200) + 200, size[1])
    #karamba.resizeImage(widget, images[1], size[0], size[1])

    # pos & move
    pos = karamba.getImagePos(widget, images[2])
    print "getImagePos: " + str(pos)
    pos = (b * 200, pos[1])
    karamba.moveImage(widget, images[2], pos[0], pos[1])

    # Sensor
    sensor = karamba.getImageSensor(widget, images[3])
    print "getSensor: " + str(sensor)
    if (b):
        karamba.setImageSensor(widget, images[3],
                               'SENSOR=PROGRAM  PROGRAM="/tmp/test1.sh"')
    else:
        karamba.setImageSensor(widget, images[3],
                               'SENSOR=PROGRAM  PROGRAM="/tmp/test2.sh"')

    # Value
    v = karamba.getImagePath(widget, images[4])
    print "getImagePath: ", v
    if (b):
        v = 'flag.png'
    else:
        v = 'flag2.png'
    karamba.setImagePath(widget, images[4], v)

    if ((c % 10) == 0):
        karamba.removeImageEffects(widget, images[5])
        karamba.removeImageEffects(widget, images[6])
        karamba.removeImageEffects(widget, images[7])
    else:
        karamba.changeImageIntensity(widget, images[5],
                                     (float(c % 10) / 5 - 1.0))
        karamba.changeImageChannelIntensity(widget, images[6],
                                            (float(c % 10) / 5 - 1.0), 'blue')
        karamba.changeImageToGray(widget, images[7], 0)

    if ((c % 9) == 0):
        karamba.removeImageTransformations(widget, images[8])
        karamba.removeImageTransformations(widget, images[9])
        karamba.removeImageTransformations(widget, images[10])
    else:
        karamba.rotateImage(widget, images[8], (c % 9) * 20 + 45)
        karamba.resizeImage(widget, images[9], 50 + (c % 5) * 10, size[1])
        karamba.resizeImageSmooth(widget, images[10], 50 + (c % 5) * 10,
                                  size[1])

    if ((c % 10) == 0):
        karamba.addImageTooltip(widget, images[11], str(c))

    if ((c % 20) == 0):
        if (images[12]):
            karamba.deleteImage(widget, images[12])
            images[12] = 0
        else:
            images[12] = karamba.createBackgroundImage(widget, 0, 340,
                                                       "flag.png")

    if (images[13]):
        karamba.deleteImage(widget, images[13])
        images[13] = 0
    else:
        tlist = karamba.getTaskList(widget)
        images[13] = karamba.createTaskIcon(widget, 50, 340,
                                            tlist[c % len(tlist)])

    c += 1