def draw_points(renderer): global current_alpha, current_color, cycle_direction viewport = sdl2.SDL_Rect() sdl2.SDL_RenderGetViewport(renderer, ctypes.byref(viewport)) for i in range(0, 10 * NUM_OBJECTS): current_color = current_color + cycle_direction if current_color < 0: current_color = 0 cycle_direction = -cycle_direction if current_color > 255: current_color = 255 cycle_direction = -cycle_direction sdl2.SDL_SetRenderDrawColor(renderer, 255, current_color, current_color, current_alpha) x = int(random.random() * 65535) % viewport.w y = int(random.random() * 65535) % viewport.h sdl2.SDL_RenderDrawPoint(renderer, x, y)
def _draw_point(self, x, y): sdl2.SDL_RenderDrawPoint(self._sdl_renderer, x, y)
def render_pixel(self, x, y, colour): # can't use the below as too slow big_x = 5 * x big_y = 5 * y sdl2.SDL_SetRenderDrawColor(self.renderer, *colour, sdl2.SDL_ALPHA_OPAQUE) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 1, big_y) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 2, big_y) sdl2.SDL_RenderDrawPoint(self.renderer, big_x, big_y + 1) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 1, big_y + 1) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 2, big_y + 1) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 3, big_y + 1) sdl2.SDL_RenderDrawPoint(self.renderer, big_x, big_y + 2) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 1, big_y + 2) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 2, big_y + 2) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 3, big_y + 2) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 1, big_y + 3) sdl2.SDL_RenderDrawPoint(self.renderer, big_x + 2, big_y + 3)
def render_pixel(self, x, y, colour): sdl2.SDL_SetRenderDrawColor(self.renderer, *colour, sdl2.SDL_ALPHA_OPAQUE) sdl2.SDL_RenderDrawPoint(self.renderer, x, y)
def render(self, render_context): sdl2.SDL_RenderDrawPoint(render_context.sdl_renderer, int(self.x), int(self.y))
def _draw_point(self, x, y, point_index): if self._is_point_visible((x, y)): sdl2.SDL_RenderDrawPoint(self._sdl_renderer, x, y) else: if self._is_draw_dash_point(point_index): sdl2.SDL_RenderDrawPoint(self._sdl_renderer, x, y)
def setpixel(renderer, x, y): sdl2.SDL_RenderDrawPoint(renderer, x, y)