titan Toxicus
titan Toxicus's Channel
 
 
играю в стандчилов
1
снимаю. стандофф
1
Эдит титан токсикус
1
7 августа 2024 г.
1
вот что пел пел диджей
0
Все катапульты
0
8 июля 2024 г.
0
Выращиваю дерево
0
 
titan Toxicus
Your channel viewers will see links here, including "subscribe" and "add as friend".
Profile
 
Name
titan Toxicus
Description
Subscribers
90
Subscriptions
Recent Activity  
titan Toxicus import pygame # --- Инициализация Pygame --- pygame.init() # --- Настройки экрана (остаются прежними) --- SCREEN_WIDTH = 600 SCREEN_HEIGHT = 800 screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption("Pydroid Paint CLONE с ФУНКЦИЕЙ ФОН") # --- Цвета (остаются прежними) --- BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) MAGENTA = (255, 0, 255) CYAN = (0, 255, 255) ORANGE = (255, 165, 0) DARK_GRAY = (100, 100, 100) GRAY = (150, 150, 150) LIGHT_GRAY = (200, 200, 200) BACKGROUND_COLOR = BLACK # Изначально черный BORDER_COLOR = WHITE # --- Настройки шрифта --- pygame.font.init() try: font_small = pygame.font.SysFont('Arial', 18) font_text_tool = pygame.font.SysFont('Arial', 30) except: font_small = pygame.font.Font(None, 18) font_text_tool = pygame.font.Font(None, 30) # --- Кнопки и их зоны --- BUTTON_HEIGHT = 50 DRAWING_AREA_HEIGHT = SCREEN_HEIGHT - BUTTON_HEIGHT # Структура данных для кнопок: (цвет кнопки, действие, метка, цвет текста) # НОВАЯ КНОПКА: 'FILL_ALL' button_data = [ (RED, 'COLOR', 'Кр', WHITE), (GREEN, 'COLOR', 'Зе', WHITE), (BLUE, 'COLOR', 'Си', WHITE), (YELLOW, 'COLOR', 'Же', BLACK), (MAGENTA, 'COLOR', 'Пу', WHITE), (CYAN, 'COLOR', 'Го', BLACK), (ORANGE, 'COLOR', 'Ор', BLACK), (DARK_GRAY, 'COLOR', 'Се', WHITE), (WHITE, 'COLOR', 'Бе', BLACK), (GRAY, 'ERASER', 'ЛАС', WHITE), (LIGHT_GRAY, 'FILL_ALL', 'ФОН', BLACK), # ЗАЛИВКА ВСЕГО ФОНА (GRAY, 'FILL_MODE', 'ЗАЛ', WHITE), # Заливка области (Flood Fill) (LIGHT_GRAY, 'TEXT_MODE', 'ТК', BLACK), # Режим Текста (GRAY, 'SIZE_DOWN', '—', WHITE), (LIGHT_GRAY, 'SIZE_UP', '+', BLACK) ] button_rects = [] num_buttons = len(button_data) # Теперь 15 кнопок button_width = SCREEN_WIDTH // num_buttons for i, data in enumerate(button_data): rect = pygame.Rect(i * button_width, DRAWING_AREA_HEIGHT, button_width, BUTTON_HEIGHT) button_rects.append({'rect': rect, 'action': data[1], 'color': data[0], 'label': data[2], 'text_color': data[3]}) # --- Текущие параметры рисования и режимы --- drawing_color = WHITE line_thickness = 5 MIN_THICKNESS = 1 MAX_THICKNESS = 30 current_mode = 'DRAW' is_eraser = False # Заливаем область рисования screen.fill(BACKGROUND_COLOR) drawing = False last_pos = None # --- ФУНКЦИЯ FLOOD FILL (остается для точной заливки) --- def flood_fill(start_pos): """Реализует алгоритм Flood Fill (заливка) для заданной области.""" try: target_color = screen.get_at(start_pos) except IndexError: return fill_color = drawing_color if target_color == fill_color: return stack = [start_pos] min_x, max_x = 0, SCREEN_WIDTH - 1 min_y, max_y = 0, DRAWING_AREA_HEIGHT - 1 # Временно блокируем поверхность для ускорения screen.lock() while stack: x, y = stack.pop() if not (min_x <= x <= max_x and min_y <= y <= max_y): continue # Проверяем цвет пикселя, используя сравнение по RGB (без учета альфа-канала) pixel_color = screen.get_at((x, y)) if pixel_color[:3] != target_color[:3]: continue screen.set_at((x, y), fill_color) stack.append((x + 1, y)) stack.append((x - 1, y)) stack.append((x, y + 1)) stack.append((x, y - 1)) screen.unlock() print(f"Заливка области завершена цветом {fill_color}") # --- ФУНКЦИЯ ЗАЛИВКИ ФОНА (НОВАЯ) --- def fill_all_background(): """Заливает весь холст текущим выбранным цветом.""" global BACKGROUND_COLOR BACKGROUND_COLOR = drawing_color fill_rect = pygame.Rect(0, 0, SCREEN_WIDTH, DRAWING_AREA_HEIGHT) screen.fill(BACKGROUND_COLOR, fill_rect) print(f"Фон залит цветом: {BACKGROUND_COLOR}") # --- Остальные вспомогательные функции (обновлены для новой кнопки) --- # ... (функции draw_buttons, display_thickness, display_mode, draw_text остаются прежними по логике) def draw_buttons(): # ... (код отрисовки кнопок, не изменен) for btn in button_rects: pygame.draw.rect(screen, btn['color'], btn['rect']) pygame.draw.rect(screen, BORDER_COLOR, btn['rect'], 1) text_surface = font_small.render(btn['label'], True, btn['text_color']) text_rect = text_surface.get_rect(center=btn['rect'].center) screen.blit(text_surface, text_rect) display_thickness() display_mode() def display_thickness(): # ... (код отображения размера, не изменен) clear_rect = pygame.Rect(SCREEN_WIDTH - 155, 5, 150, 40) pygame.draw.rect(screen, BACKGROUND_COLOR, clear_rect) rect_width = 150 rect_height = 30 rect_x = SCREEN_WIDTH - rect_width - 10 rect_y = 10 pygame.draw.rect(screen, GRAY, (rect_x, rect_y, rect_width, rect_height)) text_label = "Размер: " text_value = str(line_thickness) label_surface = font_small.render(text_label, True, BLACK) screen.blit(label_surface, (rect_x + 5, rect_y + 3)) value_surface = font_small.render(text_value, True, RED) screen.blit(value_surface, (rect_x + 95, rect_y + 3)) def display_mode(): # ... (код отображения режима, не изменен) mode_text = f"Режим: {current_mode}" mode_color = YELLOW if current_mode == 'TEXT' else WHITE if current_mode == 'DRAW' else RED clear_rect = pygame.Rect(5, 5, 150, 40) pygame.draw.rect(screen, BACKGROUND_COLOR, clear_rect) rect_width = 150 rect_height = 30 rect_x = 10 rect_y = 10 pygame.draw.rect(screen, GRAY, (rect_x, rect_y, rect_width, rect_height)) mode_surface = font_small.render(mode_text, True, mode_color) screen.blit(mode_surface, (rect_x + 5, rect_y + 3)) def draw_text(pos): # ... (код печати текста, не изменен) global current_mode, drawing_color text_to_print = "PYTHON CLONE" text_surface = font_text_tool.render(text_to_print, True, drawing_color) screen.blit(text_surface, pos) current_mode = 'DRAW' def handle_button_click(pos): """Обрабатывает касание кнопки.""" global drawing_color, is_eraser, line_thickness, current_mode for btn in button_rects: if btn['rect'].collidepoint(pos): action = btn['action'] # --- Смена режима и Цвета --- if action == 'COLOR': current_mode = 'DRAW' is_eraser = False drawing_color = btn['color'] elif action == 'ERASER': current_mode = 'DRAW' is_eraser = True elif action == 'FILL_ALL': # НОВАЯ ФУНКЦИЯ: Заливка всего фона fill_all_background() current_mode = 'DRAW' elif action == 'FILL_MODE': current_mode = 'FILL' elif action == 'TEXT_MODE': current_mode = 'TEXT' # --- Смена размера --- elif action == 'SIZE_UP': if line_thickness < MAX_THICKNESS: line_thickness += 1 elif action == 'SIZE_DOWN': if line_thickness > MIN_THICKNESS: line_thickness -= 1 return True return False # --- Основной цикл программы --- running = True while running: # 1. Обработка событий for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: # Касание/левая кнопка pos = event.pos # 1. Проверяем, нажата ли кнопка if handle_button_click(pos): continue # Если нажали на холст (не на кнопку) if pos[1] < DRAWING_AREA_HEIGHT: if current_mode == 'FILL': # Запускаем Flood Fill flood_fill(pos) current_mode = 'DRAW' elif current_mode == 'TEXT': # Печатаем текст draw_text(pos) elif current_mode == 'DRAW': # Начинаем рисовать drawing = True last_pos = pos elif event.type == pygame.MOUSEBUTTONUP: if event.button == 1: drawing = False last_pos = None elif event.type == pygame.MOUSEMOTION: if drawing and current_mode == 'DRAW': current_pos = event.pos if current_pos[1] >= DRAWING_AREA_HEIGHT: drawing = False continue color_to_draw = BACKGROUND_COLOR if is_eraser else drawing_color if last_pos: pygame.draw.line(screen, color_to_draw, last_pos, current_pos, line_thickness) last_pos = current_pos # 2. Отрисовка интерфейса и обновление экрана draw_buttons() pygame.display.flip() # --- Выход из Pygame --- pygame.quit() (11 months ago)
 
 
titan Toxicus Этот человек прав, мы должны изгаернуть ложь этот человек будет возглавлять нас я давно знал что это канал ложь который там показан ну в посте фотография. Пост который это написал будет возглавлять нас то есть пост чего скриншота я сделал (1 year ago)
 
 
titan Toxicus Мне возвращаться во фьюжен мод концепты? (1 year ago)
Vote on a poll:
Да
Click to vote
Нет
Click to vote
Да иди ты нахуй
Click to vote
 
 
titan Toxicus В 10 февраля (1 year ago)
 
 
Friends
Channel Comments
There are no comments for this user.