I think that's lookin' pretty good!
This commit is contained in:
		
							parent
							
								
									bd6c5fe168
								
							
						
					
					
						commit
						3236d85ab6
					
				
					 3 changed files with 13 additions and 13 deletions
				
			
		|  | @ -7,6 +7,7 @@ from hexagram.pattern import HexagonPattern | ||||||
| from hexagram.gauge   import Gauge | from hexagram.gauge   import Gauge | ||||||
| from hexagram.dial    import Dial | from hexagram.dial    import Dial | ||||||
| from hexagram.speedo  import Speedo | from hexagram.speedo  import Speedo | ||||||
|  | from hexagram.tacho   import Tacho | ||||||
| 
 | 
 | ||||||
| class ShiftIndicator(Gauge): | class ShiftIndicator(Gauge): | ||||||
|     LIGHT_WIDTH   = 48 |     LIGHT_WIDTH   = 48 | ||||||
|  | @ -73,12 +74,10 @@ class Cluster(): | ||||||
|                              self.HEIGHT / 2, |                              self.HEIGHT / 2, | ||||||
|                              180.0) |                              180.0) | ||||||
| 
 | 
 | ||||||
|         self.tacho = Dial(self.WIDTH - self.HEIGHT / 2, |         self.tacho = Tacho(self.WIDTH - self.HEIGHT / 2, | ||||||
|                           self.HEIGHT / 2, |                            self.HEIGHT / 2, | ||||||
|                           self.HEIGHT / 2, |                            self.HEIGHT / 2, | ||||||
|                           232.0 * (math.pi / 180.0), |                            8000) | ||||||
|                           488.0 * (math.pi / 180.0), |  | ||||||
|                           8000) |  | ||||||
| 
 | 
 | ||||||
|         self.gauges.append(self.speedo) |         self.gauges.append(self.speedo) | ||||||
|         self.gauges.append(self.tacho) |         self.gauges.append(self.tacho) | ||||||
|  |  | ||||||
|  | @ -3,13 +3,12 @@ import cairo | ||||||
| 
 | 
 | ||||||
| from hexagram.gauge import Gauge | from hexagram.gauge import Gauge | ||||||
| 
 | 
 | ||||||
| ANGLE_OFFSET = math.pi / 2 |  | ||||||
| 
 |  | ||||||
| class Dial(Gauge): | class Dial(Gauge): | ||||||
|     __slots = 'x', 'y', 'radius', 'min_angle', 'max_angle', 'max_value', |     __slots = 'x', 'y', 'radius', 'min_angle', 'max_angle', 'max_value', | ||||||
| 
 | 
 | ||||||
|     BEZEL_WIDTH = 16 |     ANGLE_OFFSET = math.pi / 2 | ||||||
| 
 | 
 | ||||||
|  |     BEZEL_WIDTH = 16 | ||||||
|     BEZEL_GRADIENT_STOPS = ( |     BEZEL_GRADIENT_STOPS = ( | ||||||
|         (0, 1.0, 0.4, 1.0, 1.0), |         (0, 1.0, 0.4, 1.0, 1.0), | ||||||
|         (1, 0.4, 0.0, 0.4, 0.0) |         (1, 0.4, 0.0, 0.4, 0.0) | ||||||
|  | @ -36,13 +35,12 @@ class Dial(Gauge): | ||||||
| 
 | 
 | ||||||
|     def draw_number(self, cr: cairo.Context, radius: float, value: float, text: str): |     def draw_number(self, cr: cairo.Context, radius: float, value: float, text: str): | ||||||
|         scale = value / self.max_value |         scale = value / self.max_value | ||||||
|         angle = self.min_angle + ((self.max_angle - self.min_angle) * scale) - ANGLE_OFFSET |         angle = self.min_angle + ((self.max_angle - self.min_angle) * scale) - self.ANGLE_OFFSET | ||||||
| 
 | 
 | ||||||
|         cr.set_source_rgb(1, 1, 1) |         cr.set_source_rgb(1, 1, 1) | ||||||
|         cr.move_to(self.x + radius * self.radius * math.cos(angle) - 20, |         cr.move_to(self.x + radius * self.radius * math.cos(angle) - 20, | ||||||
|                    self.y + radius * self.radius * math.sin(angle)) |                    self.y + radius * self.radius * math.sin(angle)) | ||||||
| 
 | 
 | ||||||
|         #cr.rotate(angle + ANGLE_OFFSET) |  | ||||||
|         cr.show_text(text) |         cr.show_text(text) | ||||||
|         cr.stroke() |         cr.stroke() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ class Speedo(Dial): | ||||||
|     MIN_ANGLE = 232.0 * (math.pi / 180.0) |     MIN_ANGLE = 232.0 * (math.pi / 180.0) | ||||||
|     MAX_ANGLE = 488.0 * (math.pi / 180.0) |     MAX_ANGLE = 488.0 * (math.pi / 180.0) | ||||||
| 
 | 
 | ||||||
|     FONT_FACE = "Helvetica" |     FONT_FACE = "Muli" | ||||||
| 
 | 
 | ||||||
|     __slots__ = 'units', |     __slots__ = 'units', | ||||||
| 
 | 
 | ||||||
|  | @ -24,7 +24,10 @@ class Speedo(Dial): | ||||||
|     def draw_bg(self, cr: cairo.Context): |     def draw_bg(self, cr: cairo.Context): | ||||||
|         super().draw_bg(cr) |         super().draw_bg(cr) | ||||||
| 
 | 
 | ||||||
|         cr.select_font_face(self.FONT_FACE) |         cr.select_font_face(self.FONT_FACE, | ||||||
|  |                             cairo.FontSlant.ITALIC, | ||||||
|  |                             cairo.FontWeight.BOLD) | ||||||
|  | 
 | ||||||
|         cr.set_font_size(self.radius * 0.1) |         cr.set_font_size(self.radius * 0.1) | ||||||
|         cr.set_source_rgb(1, 1, 1) |         cr.set_source_rgb(1, 1, 1) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue