def update(self, mouseclick, scrolldown, scrollup, keypressed):
		if self.wheel.is_clicked(self.x+self.wheel.x, self.y+self.wheel.y):
			r,g,b,a = self.wheel.get_color()
			
		else:
			for btn in range(len(self.custom_colors.grid)):
				if self.custom_colors.grid[btn].is_clicked(self.x+self.custom_colors.x+self.custom_colors.grid[btn].x,
				self.y+self.custom_colors.y+self.custom_colors.grid[btn].y, mouseclick):
					self.custom_selected = btn
					if self.custom_colors.grid[btn].color != (212,212,212):
						r,g,b = self.custom_colors.grid[btn].color
		
		for slider in self.sliders:
			slider.update(self.x+slider.x, self.y+slider.y)
			try:
				if slider.title == 'red':
					slider.set_value(r)	
				if slider.title == 'green':
					slider.set_value(g)
				if slider.title == 'blue':
					slider.set_value(b)
			except: # catch 'em all.
				if slider.title == 'red':
					r = slider.get_value()
				if slider.title == 'green':
					g = slider.get_value()
				if slider.title == 'blue':
					b = slider.get_value()
					
		self.current_color = (r,g,b)
		self.current_color_box.fill(self.current_color)
		self.custom_colors.grid[self.custom_selected].color = self.current_color
		self.custom_colors.grid[self.custom_selected].surface.fill(self.current_color)
						
		Window.update(self, mouseclick, scrolldown, scrollup)
    def draw(self):
        for button in self.buttons:
            button.draw(self.surface)
        self.mytextbox.draw(self.mypane.content_surface)

        self.mypane.draw(self.surface)

        self.inputbox.draw(self.surface)

        # Inherited draw method from base class, draws onto parent
        Window.draw(self)
 def __init__(self, x, y, w, h, p):
     Window.__init__(self, x, y, w, h, p, "Tool Bar")
     self.buttons = []
     self.buttons.append(Button(10, 30, "Select", self.surface, c=(50, 50, 50)))
     self.mytextbox = TextBox(
         00,
         0,
         150,
         "Lorem ipsum dolor sit amet, \n \n \n consectetur adipiscing elit. Proin at porta mauris. Aliquam ultricies venenatis nisi, non feugiat elit consequat at. Suspendisse sollicitudin condimentum mauris, vel consequat lorem ornare sed. Vestibulum eu eros libero. Quisque sed purus non orci tincidunt volutpat et in nisi. Fusce quis cursus urna. Aliquam ipsum urna, dictum a convallis sed, tristique eu lectus. In hac habitasse platea dictumst. Praesent vestibulum, diam sit amet sagittis consequat, lacus velit commodo risus, ac congue erat dui nec diam. ?",
     )
     self.mypane = ScrollPane(10, 120, 170, 200, 400)
     self.inputbox = Input(160, 50, 100)
    def update(self, mouseclick, scrolldown, scrollup, keypressed):
        for button in self.buttons:
            if button.is_clicked(self.x + button.x, self.y + button.y, mouseclick):
                if self.mytextbox.text.split(" ")[0] == "Cool":
                    self.mytextbox.text += " And again."
                else:
                    self.mytextbox.text = "Cool you clicked a button"
                self.mypane.render()
                self.mytextbox.render()
        self.mypane.scrolldown = scrolldown
        self.mypane.scrollup = scrollup
        self.mypane.update(self.x + self.mypane.x, self.y + self.mypane.y)
        self.inputbox.update(self.x + self.inputbox.x, self.y + self.inputbox.y, mouseclick, keypressed)

        Window.update(self, mouseclick, scrolldown, scrollup)
	def __init__(self, x, y, w, h, p):
		Window.__init__(self,x,y,w,h,p,"Color Picker")	
		self.wheel = ColorWheel(120, 30)
		self.sliders = []
		self.sliders.append(Slider(10,50,100,(0,255), 'red'))
		self.sliders.append(Slider(10,90,100,(0,255), 'green'))
		self.sliders.append(Slider(10,130,100,(0,255), 'blue'))
		self.labels = [] # I call them labels but they're really just buttons without actions!
		self.labels.append(Button(0,30,"Red:", self.surface, (255,255,255)))
		self.labels.append(Button(0,70,"Green:", self.surface, (255,255,255)))
		self.labels.append(Button(0,110,"Blue:", self.surface, (255,255,255)))
		self.buttons = []
		self.buttons.append(Button(10, 160, "Choose", self.surface, (50,50,50)))
		self.current_color_box = pygame.Surface((50,50))
		self.custom_colors = CustomColors(70, 200, 200)
		self.custom_selected = 0
	def __init__(self,x,y,w,h,p):
		Window.__init__(self,x,y,w,h,p)
		self.windows = []
		
		self.windows.append(ColorWheelWindow(100,300,280,260,self.parent))
		self.current_color = (255,100,0)
	
		# blank canvas window
		newdoc = pygame.Surface((640,480))
		newdoc.fill((255,255,255))
		self.windows.append(CanvasWindow(300,300,self.parent,newdoc))
		
		# create toolbar
		self.toolbar = Toolbar(self.parent)
		self.toolbar.items.append(ToolbarButton(0,0,'File', self.parent, ['New', 'Open']))
		self.toolbar.items.append(ToolbarButton(0,0,'View', self.parent, ['Tools', 'Colours', 'Answer this']))
		self.toolbar.render() # item appended, needs to be re-rendered

		self.draw()
	def draw(self):
		for label in self.labels:
			label.draw(self.surface)
		for slider in self.sliders:
			slider.draw(self.surface)
		for button in self.buttons:
			button.draw(self.surface)
		self.wheel.draw(self.surface)
		pygame.draw.line(self.surface, (200,200,200), (10,190), (self.width-10, 190))
		self.surface.blit(self.current_color_box, (10, 200))
		self.custom_colors.draw(self.surface)
		btn = self.custom_colors.grid[self.custom_selected]
		zerox = self.custom_colors.x+btn.x # just using vars to
		zeroy = self.custom_colors.y+btn.y # keep the lines nice and short
		# manually drawing lines because a for loop is achieves the same thing
		# in only a couple of lines less but with more resources used
		pygame.draw.line(self.surface, (0,0,0), (zerox,zeroy), (zerox+23, zeroy),2)
		pygame.draw.line(self.surface, (0,0,0), (zerox,zeroy), (zerox, zeroy+23),2)
		pygame.draw.line(self.surface, (0,0,0), (zerox+23,zeroy), (zerox+23, zeroy+24),2)
		pygame.draw.line(self.surface, (0,0,0), (zerox,zeroy+23), (zerox+23, zeroy+23),2)
		Window.draw(self)
	def draw(self):
		self.bar.draw()
		Window.draw(self)
Beispiel #9
0

Luces = Reflejos = Paredes = []
lucesEfectivas = [[0]*500]*500
Img = None

def threadPathTrace():
    PT.pathTrace(Luces, Reflejos, Paredes, Img, lucesEfectivas)


t = threading.Thread(target = threadPathTrace) # f being the function that tells how the ball should move
t.setDaemon(True) # Alternatively, you can use "t.daemon = True"


if __name__ == '__main__':
    display = None
    Thread = threading.Thread(target=MAINLOOP)
    Thread.setDaemon(True)
    boolean = True
    display = Window(500, 500, "Path Tracing")
    Thread.start()
    display.run()