Python pygame.SRCALPHA Examples
The following are 30
code examples of pygame.SRCALPHA().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygame
, or try the search function
.
Example #1
Source File: no_rendering_mode.py From scenario_runner with MIT License | 7 votes |
def __init__(self): def make_surface(tl): w = 40 surface = pygame.Surface((w, 3 * w), pygame.SRCALPHA) surface.fill(COLOR_ALUMINIUM_5 if tl != 'h' else COLOR_ORANGE_2) if tl != 'h': hw = int(w / 2) off = COLOR_ALUMINIUM_4 red = COLOR_SCARLET_RED_0 yellow = COLOR_BUTTER_0 green = COLOR_CHAMELEON_0 pygame.draw.circle(surface, red if tl == tls.Red else off, (hw, hw), int(0.4 * w)) pygame.draw.circle(surface, yellow if tl == tls.Yellow else off, (hw, w + hw), int(0.4 * w)) pygame.draw.circle(surface, green if tl == tls.Green else off, (hw, 2 * w + hw), int(0.4 * w)) return pygame.transform.smoothscale(surface, (15, 45) if tl != 'h' else (19, 49)) self._original_surfaces = { 'h': make_surface('h'), tls.Red: make_surface(tls.Red), tls.Yellow: make_surface(tls.Yellow), tls.Green: make_surface(tls.Green), tls.Off: make_surface(tls.Off), tls.Unknown: make_surface(tls.Unknown) } self.surfaces = dict(self._original_surfaces)
Example #2
Source File: keyboard.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 6 votes |
def render_text(self, p_sText, p_bShadow = True): C_SHADOW = pygame.Color( 19, 14, 56) C_TEXT = pygame.Color(202,199,219) p_sText = str(p_sText) img = self.m_oFontText.render(p_sText, False, C_TEXT) rect = img.get_rect() sf = pygame.Surface((rect.width, rect.height), pygame.SRCALPHA) if p_bShadow: shadow = self.m_oFontText.render(p_sText, False, C_SHADOW) shadow_rect = img.get_rect() shadow_rect.x += 1 shadow_rect.y += 1 sf.blit(shadow, shadow_rect) sf.blit(img, rect) return sf
Example #3
Source File: tunnel_entrance.py From SwervinMervin with GNU General Public License v2.0 | 6 votes |
def render(self, window, segment): coords = segment.bottom["screen"] s_width = s.DIMENSIONS[0] s_height = int(s.TUNNEL_HEIGHT * coords["s"] * s.ROAD_WIDTH * self.quantifier) x = 0 y = s.DIMENSIONS[1] - coords["y"] - s_height top_clip = s.DIMENSIONS[1] - segment.clip[1] - y # Player can see the tunnel approaching. if top_clip > 0: e_height = int(s_height * 0.7) surf = pygame.Surface([s_width, s_height], pygame.SRCALPHA, 32) surf = surf.convert_alpha() points = [(s_width, s_height), (coords["x"] + coords["w"], s_height), (coords["x"] + coords["w"], s_height - e_height), (coords["x"] - coords["w"], s_height - e_height), (coords["x"] - coords["w"], s_height), (0, s_height), (0, 0), (s_width, 0)] pygame.draw.polygon(surf, self.colour, points) window.blit(surf, (x, y), (0, 0, s_width, top_clip))
Example #4
Source File: renderer.py From L2RPN with GNU Lesser General Public License v3.0 | 6 votes |
def draw_surface_loads_curves(self, n_hours_to_display_top_loadplot, n_hours_to_display_bottom_loadplot): # Loads curve surface: retrieve images surfaces, stack them into a common surface, plot horizontal lines # at top and bottom of latter surface # compute the string number of days n_days_horizon = n_hours_to_display_top_loadplot // 24 img_loads_curve_week = self.create_plot_loads_curve( n_timesteps=int(n_hours_to_display_top_loadplot * 3600 // self.timestep_duration_seconds), left_xlabel=' {} day{} ago '.format(n_days_horizon, 's' if n_days_horizon > 1 else '')) n_hours_horizon = n_hours_to_display_bottom_loadplot img_loads_curve_day = self.create_plot_loads_curve( n_timesteps=int(n_hours_to_display_bottom_loadplot * 3600 // self.timestep_duration_seconds), left_xlabel='{} hours ago'.format(n_hours_horizon)) loads_curve_surface = pygame.Surface( (img_loads_curve_week.get_width(), 2 * img_loads_curve_week.get_height() + 30), pygame.SRCALPHA, 32).convert_alpha() loads_curve_surface.fill(self.left_menu_tile_color) loads_curve_surface.blit(self.bold_white_render('Historical total consumption'), (30, 10)) loads_curve_surface.blit(img_loads_curve_week, (0, 30)) loads_curve_surface.blit(img_loads_curve_day, (0, 30 + img_loads_curve_week.get_height())) gfxdraw.hline(loads_curve_surface, 0, loads_curve_surface.get_width(), 0, (64, 64, 64)) gfxdraw.hline(loads_curve_surface, 0, loads_curve_surface.get_width(), loads_curve_surface.get_height() - 1, (64, 64, 64)) return loads_curve_surface
Example #5
Source File: ptext.py From ct-Raspi-Radiowecker with GNU General Public License v3.0 | 6 votes |
def _gradsurf(h, y0, y1, color0, color1): key = h, y0, y1, color0, color1 if key in _grad_cache: return _grad_cache[key] surf = pygame.Surface((1, h),flags=pygame.SRCALPHA).convert_alpha() r0, g0, b0 = color0[:3] r1, g1, b1 = color1[:3] for y in range(h): f = min(max((y - y0) / (y1 - y0), 0), 1) g = 1 - f surf.set_at((0, y), ( int(round(g * r0 + f * r1)), int(round(g * g0 + f * g1)), int(round(g * b0 + f * b1)), 0 )) _grad_cache[key] = surf return surf # Tracks everything that can be updated by tags.
Example #6
Source File: player.py From SwervinMervin with GNU General Public License v2.0 | 6 votes |
def __level_over_overlay(self, window): lo_font = pygame.font.Font(s.FONTS["fipps"], 38) s_font = pygame.font.Font(s.FONTS["retro_computer"], 30) txt_lo = lo_font.render("Level Complete!", 1, s.COLOURS["dark_text"]) txt_lap = s_font.render("Best Lap", 1, s.COLOURS["dark_text"]) txt_lap_v = s_font.render("%.1fs" % round(self.fastest_lap, 1), 1, s.COLOURS["dark_text"]) txt_bonus = s_font.render("Time bonus", 1, s.COLOURS["dark_text"]) txt_bonus_v = s_font.render(str(math.trunc(self.time_bonus)), 1, s.COLOURS["dark_text"]) txt_points = s_font.render("Points", 1, s.COLOURS["dark_text"]) txt_points_v = s_font.render(str(math.trunc(self.points)), 1, s.COLOURS["dark_text"]) overlay = pygame.Surface(s.DIMENSIONS, pygame.SRCALPHA) overlay.fill((255, 255, 255, 150)) overlay.blit(txt_lo, (s.DIMENSIONS[0] / 2 - txt_lo.get_size()[0] / 2, 20)) overlay.blit(txt_lap, (20, 180)) overlay.blit(txt_lap_v, (s.DIMENSIONS[0] - txt_lap_v.get_size()[0] - 10, 190)) overlay.blit(txt_bonus, (20, 260)) overlay.blit(txt_bonus_v, (s.DIMENSIONS[0] - txt_bonus_v.get_size()[0] - 10, 270)) overlay.blit(txt_points, (20, 340)) overlay.blit(txt_points_v, (s.DIMENSIONS[0] - txt_points_v.get_size()[0] - 10, 350)) window.blit(overlay, (0,0))
Example #7
Source File: graphics.py From highway-env with MIT License | 6 votes |
def display(cls, object_: 'RoadObject', surface: WorldSurface, transparent: bool = False, offscreen: bool = False): """ Display a road objects on a pygame surface. The objects is represented as a colored rotated rectangle :param object_: the vehicle to be drawn :param surface: the surface to draw the object on :param transparent: whether the object should be drawn slightly transparent :param offscreen: whether the rendering should be done offscreen or not """ o = object_ s = pygame.Surface((surface.pix(o.LENGTH), surface.pix(o.LENGTH)), pygame.SRCALPHA) # per-pixel alpha rect = (0, surface.pix(o.WIDTH) / 2 - surface.pix(o.WIDTH) / 2, surface.pix(o.LENGTH), surface.pix(o.WIDTH)) pygame.draw.rect(s, cls.get_color(o, transparent), rect, 0) pygame.draw.rect(s, cls.BLACK, rect, 1) if not offscreen: # convert_alpha throws errors in offscreen mode TODO() Explain why s = pygame.Surface.convert_alpha(s) h = o.heading if abs(o.heading) > 2 * np.pi / 180 else 0 # Centered rotation position = (surface.pos2pix(o.position[0], o.position[1])) cls.blit_rotate(surface, s, position, np.rad2deg(-h))
Example #8
Source File: config_core.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 6 votes |
def _render_layer30(self): # layer30 pointer line = self._get_onscreen_menu_line() Y_POS = self.m_iMenu_pos + (line * self.m_iText_spc) self.m_oLayer30 = pygame.Surface(self.m_lRES, pygame.SRCALPHA) if not self.m_lPointer['pointer_render']: if type(self.dCFG['pointer']) is list: for item in self.dCFG['pointer']: ptr = self._img_render(item) self.m_lPointer['pointer_render'].append(ptr) else: ptr = self._img_render(self.dCFG['pointer']) self.m_lPointer['pointer_render'].append(ptr) ptr = self.m_lPointer['pointer_render'][self.m_lPointer['frame']] rect = ptr.get_rect() rect.midright = (self.m_iText_lft - 2, Y_POS) self.m_oLayer30.blit(ptr, rect) # Rotate if vertical mode if self.m_iSide == 1: self.m_oLayer30 = pygame.transform.rotate(self.m_oLayer30, -90) elif self.m_iSide == 3: self.m_oLayer30 = pygame.transform.rotate(self.m_oLayer30, 90)
Example #9
Source File: config_core.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 6 votes |
def _render_layer21(self): # selected line self.m_oLayer21 = pygame.Surface(self.m_lRES, pygame.SRCALPHA) line = self._get_onscreen_menu_line() Y_POS = self.m_iMenu_pos + (line * self.m_iText_spc) oLine = self._render_line_menu(self.m_lLines[self.m_iLine]) # append line surface to layer21 surface rect = oLine.get_rect() rect.midleft = (self.m_iText_lft, Y_POS) self.m_oLayer21.blit(oLine, rect) # Rotate if vertical mode if self.m_iSide == 1: self.m_oLayer21 = pygame.transform.rotate(self.m_oLayer21, -90) elif self.m_iSide == 3: self.m_oLayer21 = pygame.transform.rotate(self.m_oLayer21, 90)
Example #10
Source File: loginscreen.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def __init__(self, ls, w, h, l, t, value): pygame.sprite.Sprite.__init__(self) self.ls = ls self.w = w self.h = h self.left = l self.top = t self.focus_order = -1 if self.ls.lang.ltr_text: self.right_align = False else: self.right_align = True self.font_color = self.ls.colors.font_color self.value = value self.visible = True self.select_item = False self.update_me = True self.hover = False self.image = pygame.Surface((w, h), flags=pygame.SRCALPHA) self.rect = self.image.get_rect() self.rect.topleft = [l, t] self.font_v = self.ls.font_2
Example #11
Source File: config_core.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 6 votes |
def _render_layer10(self, p_bReload = False): # layer10 surface, selector line = self._get_onscreen_menu_line() Y_POS = self.m_iMenu_pos + (line * self.m_iText_spc) self.m_oLayer10 = pygame.Surface(self.m_lRES, pygame.SRCALPHA) # append selector to layer10 if not self.dCFG['selector_render'] or p_bReload: img = "selector" if self.m_iSide != 0: img = "vselector" self.dCFG['selector_render'] = self._img_render(self.dCFG[img]) rect = self.dCFG['selector_render'].get_rect() rect.midleft = (0, Y_POS) self.m_oLayer10.blit(self.dCFG['selector_render'], rect) # Rotate if vertical mode if self.m_iSide == 1: self.m_oLayer10 = pygame.transform.rotate(self.m_oLayer10, -90) elif self.m_iSide == 3: self.m_oLayer10 = pygame.transform.rotate(self.m_oLayer10, 90)
Example #12
Source File: thermometer.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def __init__(self, game_board, width, height, scale, color, border_color, rng, number, lbl_dist=5): self.size = [width * scale, height * scale] self.center = [self.size[0] // 2, self.size[1] // 2] self.game_board = game_board self.color = color self.border_color = border_color self.number = number self.lbl_dist = lbl_dist self.rng = rng self.v_margin = int(80 * self.size[0] / 500.0) self.marker_len10 = int(20 * self.size[0] / 150.0) self.marker_len5 = int(15 * self.size[0] / 150.0) self.marker_len = int(10 * self.size[0] / 150.0) self.bar_width = int(25 * self.size[0] / 150.0) self.bottom_r = int(30 * self.size[0] / 150.0) self.v_gauge_margin_t = int(120 * self.size[0] / 500.0) self.v_gauge_margin_b = int(120 * self.size[0] / 500.0) + self.bottom_r self.canvas = pygame.Surface((self.size[0], self.size[1] - 1), flags=pygame.SRCALPHA) self.canvas.fill((0, 0, 0, 0)) self.draw_thermometer()
Example #13
Source File: config_render.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 6 votes |
def _render_info_text(self, p_sText, p_sIcon = None): ltoffset = 0 if p_sIcon: icon = self._img_render(self.dCFG[p_sIcon]) ltoffset += icon.get_width() + 3 text = self._text_render(p_sText, C_WHITE, 'type_color_3') size = ltoffset + text.get_width() oSectSf = pygame.Surface((size, self.dCFG['font_line'] + 4), pygame.SRCALPHA) if size > text.get_width(): alignY = 0 if icon.get_height() > self.dCFG['font_size']: alignY -= math.ceil((icon.get_height() - self.dCFG['font_size']) / 2.0) rect = icon.get_rect() rect.midleft = (0, (oSectSf.get_height() / 2) + alignY) oSectSf.blit(icon, rect) rect = text.get_rect() rect.midleft = (ltoffset, oSectSf.get_height() / 2) oSectSf.blit(text, rect) return oSectSf
Example #14
Source File: ratio_hq.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def __init__(self, unit_size, scale, color1, color2, color3, border_color1, border_color2, border_color3, numbers): self.size = unit_size * scale self.center = [self.size // 2, self.size // 2] self.color1 = color1 self.color2 = color2 self.color3 = color3 self.border_color1 = border_color1 self.border_color2 = border_color2 self.border_color3 = border_color3 self.numbers = numbers self.type = type self.canvas = pygame.Surface((self.size, self.size - 1), flags=pygame.SRCALPHA) self.canvas.fill((0, 0, 0, 0)) self.draw_minicircles()
Example #15
Source File: fraction_hq.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def __init__(self, unit_size, scale, color1, color2, border_color1, border_color2, numbers, border_width): self.size = unit_size * scale self.center = [self.size // 2, self.size // 2] self.color1 = color1 self.color2 = color2 self.border_color1 = border_color1 self.border_color2 = border_color2 self.numbers = numbers self.border_width = border_width self.canvas = pygame.Surface((self.size, self.size - 1), flags=pygame.SRCALPHA) self.offset_selected = self.size // 30 self.offset_unselected = self.size // 60 self.set_offset(30, 60)
Example #16
Source File: keyboard.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 6 votes |
def _render_keyboard(self): if not self.m_oRndLayout: self.m_oRndLayout = self.render_image(self.m_sLayout) if not self.m_oRndCursor: self.m_oRndCursor = self.render_image(self.m_sCursor) self.m_oRndText = self._line_text() self.m_oSfKBD = pygame.Surface((self.m_oRndLayout.get_width(), self.m_oRndLayout.get_height()), pygame.SRCALPHA) rect = self.m_oRndLayout.get_rect() rect.topleft = (0, 0) self.m_oSfKBD.blit(self.m_oRndLayout, rect) rect = self.m_oRndCursor.get_rect() pos = self._get_coord() rect.midtop = (pos[0], pos[1]) self.m_oSfKBD.blit(self.m_oRndCursor, rect) rect = self.m_oRndText.get_rect() rect.midleft = (self.m_iTextLft, self.m_iTextLine) self.m_oSfKBD.blit(self.m_oRndText, rect)
Example #17
Source File: keyboard.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 6 votes |
def _line_text(self): max_width = self.m_iTextRgt - self.m_iTextLft text = self.render_text(self.m_sText) sf = pygame.Surface((max_width, text.get_height()), pygame.SRCALPHA) LnWidth = text.get_width() + self.m_oRndCursor.get_width() textSf = pygame.Surface((LnWidth, text.get_height()), pygame.SRCALPHA) rect = text.get_rect() rect.bottomleft = (0, textSf.get_height()) textSf.blit(text, rect) rect = self.m_oRndCursor.get_rect() rect.bottomright = (LnWidth, textSf.get_height()) textSf.blit(self.m_oRndCursor, rect) if LnWidth < max_width: rect = textSf.get_rect() rect.midbottom = (max_width / 2, sf.get_height()) sf.blit(textSf, rect) else: rect = textSf.get_rect() rect.bottomright = (max_width, sf.get_height()) sf.blit(textSf, rect) return sf
Example #18
Source File: dialogwnd.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def __init__(self, wnd, l, t, w, h, caption, img_src1, fsubmit, fargs): pygame.sprite.Sprite.__init__(self) self.wnd = wnd self.w = w self.h = h self.l = l self.t = t self.fsubmit = fsubmit self.fargs = fargs self.caption = ex.unival(caption) self.hover = False self.color = (255, 255, 255, 0) self.image = pygame.Surface((self.w, self.h), flags=pygame.SRCALPHA) self.rect = self.image.get_rect() self.rect.topleft = [self.l, self.t] self.img_src1 = img_src1 self.active_img = None self.load_images()
Example #19
Source File: menu_items.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def resize_unit(self, new_grid_w, new_grid_h): self.grid_w = new_grid_w self.grid_h = new_grid_h self.image = pygame.Surface((self.grid_w * self.board.scale - 1, self.grid_h * self.board.scale - 1), flags=pygame.SRCALPHA) self.image.fill(self.color)
Example #20
Source File: config_render.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 5 votes |
def push_info_image(self, p_oImg): self.m_oLayer40 = pygame.Surface(self.m_lRES, pygame.SRCALPHA) rect = p_oImg.get_rect() rect.center = (self.m_lScreenCenter[0], self.m_lScreenCenter[1]) self.m_oLayer40.blit(p_oImg, rect) # Rotate if vertical mode if self.m_iSide == 1: self.m_oLayer40 = pygame.transform.rotate(self.m_oLayer40, -90) elif self.m_iSide == 3: self.m_oLayer40 = pygame.transform.rotate(self.m_oLayer40, 90) return
Example #21
Source File: percentage_multi_hq.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def __init__(self, unit_size, scale, colors, b_colors, numbers): self.size = unit_size * scale self.center = [self.size // 2, self.size // 2] self.numbers = numbers self.type = type self.canvas = pygame.Surface((self.size, self.size - 1), flags=pygame.SRCALPHA) self.set_colors(colors, b_colors) self.redraw()
Example #22
Source File: splash.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def __init__(self, unit_size, scale, preset_color, custom_color=(-1, -1, -1, -1)): size = unit_size * scale self.scaled_lines = [[int(size * each[0] / 200.0), int(size * each[1] / 200.0)] for each in Splash.lines] self.canvas = pygame.Surface((size, size - 1), flags=pygame.SRCALPHA) self.canvas.fill((0, 0, 0, 0)) if custom_color[0] > -1: col = ex.hsva_to_rgba(custom_color[0], custom_color[1], custom_color[2], custom_color[3]) else: col = Splash.hue_choice[preset_color] self.draw_splash(self.canvas, col)
Example #23
Source File: clock.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def draw_all(self, time=None): if time is not None: self.time = time self.canvas = pygame.Surface((self.size, self.size - 1), flags=pygame.SRCALPHA) self.canvas.fill((0, 0, 0, 0)) self.hands_vars() self.draw_hands() self.clock_wrapper.painting = self.canvas.copy()
Example #24
Source File: percentage_hq.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def __init__(self, unit_size, scale, color1, color2, border_color1, border_color2, number): self.size = unit_size * scale self.center = [self.size // 2, self.size // 2] self.color1 = color1 self.color2 = color2 self.border_color1 = border_color1 self.border_color2 = border_color2 self.number = number self.type = type self.canvas = pygame.Surface((self.size, self.size - 1), flags=pygame.SRCALPHA) self.canvas.fill((0, 0, 0, 0)) self.draw_circles()
Example #25
Source File: gui9.py From pgu with GNU Lesser General Public License v2.1 | 5 votes |
def init(self,v): self.surface = pygame.Surface((int(v['width']),int(v['height']))) color = v['color'] if v['color'] == 'custom': color = v['custom'] else: color = pygame.Color(color) self.surface.fill(color) self.overlay = pygame.Surface((int(v['width']),int(v['height'])),pygame.SRCALPHA,32) self.repaint()
Example #26
Source File: mopidy.py From ct-Raspi-Radiowecker with GNU General Public License v3.0 | 5 votes |
def imageurl(self, url): if url != self._imageurl: self._imageurl = url self._downloader() self._t = threading.Thread( target=self._downloader) self._t.daemon = True self._t.start() self.image = pygame.Surface((1, 1), flags=pygame.SRCALPHA) if self._imageurl != None: self.image = pygame.image.load( self.image_cache[self._imageurl]) self.trackdata_changed = True
Example #27
Source File: road.py From Reinforcement-Learning-for-Self-Driving-Cars with Apache License 2.0 | 5 votes |
def draw_cars(self, subject_car): view = pygame.Surface((1010, ROAD_HEIGHT), pygame.SRCALPHA, 32) view = view.convert_alpha() camera_lane = subject_car.lane cars = subject_car.get_subjective_vision() for car in cars: lane = car[0] y = car[1] relative_y = y - 42 if relative_y < 0: continue image = self.object_car_middle_image ratio = 231.0 / 328.0 if lane != camera_lane: if lane > camera_lane: image = self.object_car_right_image else: image = self.object_car_left_image pt_top_left = (lane - 1) * 100.0 / 7 + 455 pt_top_right = lane * 100.0 / 7 + 455 pt_bottom_left = -337.0 * camera_lane + 673.33 + (lane - 1) * 337.0 pt_bottom_right = -337.0 * camera_lane + 673.33 + lane * 337.0 target_y = ROAD_HEIGHT * relative_y / 28.0 target_bottom_left_x = pt_top_left + target_y / ROAD_HEIGHT * (pt_bottom_left - pt_top_left) target_bottom_right_x = pt_top_right + target_y / ROAD_HEIGHT * (pt_bottom_right - pt_top_right) image_width = int(target_bottom_right_x - target_bottom_left_x - 10) image_width = image_width if image_width > 0 else 0 image_height = int(image_width * ratio) target_top_left_x = int(target_bottom_left_x + 5) target_top_left_y = int(target_y - image_height) a = pygame.transform.scale(image, (image_width, image_height)) view.blit(a, (target_top_left_x, target_top_left_y)) self.surface.blit(view, ((self.origin_x, self.origin_y), (self.width, self.height)))
Example #28
Source File: core_choices_dynamic.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 5 votes |
def text_render(self, p_sText, p_lTextColor, p_lShadowColor = None, p_iShadowDrop = 1, p_bUseBiggerFont = True): img = self.m_oFontText.render(p_sText, False, p_lTextColor) rect = img.get_rect() sf = pygame.Surface((rect.width, rect.height), pygame.SRCALPHA) if p_lShadowColor: shadow = self.m_oFontText.render(p_sText, False, p_lShadowColor) shadow_rect = img.get_rect() shadow_rect.x += p_iShadowDrop shadow_rect.y += p_iShadowDrop sf.blit(shadow, shadow_rect) sf.blit(img, rect) return sf
Example #29
Source File: config_render.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 5 votes |
def _text_render(self, p_sText, p_lTextColor, p_lShadowColor = None, p_bCropText = False, p_iShadowDrop = 1): p_sText = str(p_sText) if p_bCropText == True: # max length 16 chars for values if len(p_sText) > 16 and self.m_iSide != 0: p_sText = (p_sText[:15] + "~") elif len(p_sText) > 21 and self.m_iSide == 0: p_sText = (p_sText[:20] + "~") p_oTextColor = C_WHITE if p_lTextColor and "type" in p_lTextColor: try: p_oTextColor = self.dCFG[p_lTextColor] except: p_oTextColor = C_WHITE elif p_lTextColor: p_oTextColor = p_lTextColor if p_lShadowColor and "type" in p_lShadowColor: try: p_oShadowColor = self.dCFG[p_lShadowColor] except: p_oShadowColor = C_WHITE else: p_oShadowColor = p_lShadowColor if self.dCFG['cap']: p_sText = p_sText.upper() img = self.m_oFontText.render(p_sText, False, p_oTextColor) rect = img.get_rect() sf = pygame.Surface((rect.width, rect.height), pygame.SRCALPHA) if p_oShadowColor: shadow = self.m_oFontText.render(p_sText, False, p_oShadowColor) shadow_rect = img.get_rect() shadow_rect.x += p_iShadowDrop shadow_rect.y += p_iShadowDrop sf.blit(shadow, shadow_rect) sf.blit(img, rect) return sf
Example #30
Source File: config_utils.py From Retropie-CRT-Edition with GNU General Public License v3.0 | 5 votes |
def render_image(p_sImg): if not os.path.exists(p_sImg): logging.info("INFO: image not found") return None try: img = pygame.image.load(p_sImg).convert_alpha() rect = img.get_rect() rect.bottomleft = (0, rect.height) sf = pygame.Surface((rect.width, rect.height), pygame.SRCALPHA) sf.blit(img, rect) return sf except: raise #return None