Compare commits

..

4 Commits

Author SHA1 Message Date
justuser 04011ffe15 Update 'README.md' 2023-04-20 16:59:28 +03:00
justuser 50c62c7ad8 Update 'README.md' 2023-04-20 16:56:18 +03:00
justuser31 b4721575aa Fix color code in example list 2023-04-20 15:59:43 +03:00
justuser31 7b45803a2c Update: add uploader, add cleaner, add black color and update color code 2023-04-20 15:59:04 +03:00
3 changed files with 75 additions and 7 deletions
+8
View File
@@ -8,6 +8,14 @@ Super simple, super stupid.
## -------------------------------- ## --------------------------------
## >>>Рисование<<<: ## >>>Рисование<<<:
## Уровень: ламер
1. Скачать im_creator.py
2. Запустить через `python3 im_creator.py`
3. Нарисовать что-то.
4. Нажать кнопку "Upload" для загрузки рисунка на сервер.
5. Ждать надписи в консоли "DONE"
## Уровень: овнокодер
Вы можете написать свой скрипт на основе post.py или... Вы можете написать свой скрипт на основе post.py или...
1. Скачать bot.py 1. Скачать bot.py
2. Запрогроммировать свои инструкции для бота: 2. Запрогроммировать свои инструкции для бота:
+2 -2
View File
File diff suppressed because one or more lines are too long
+65 -5
View File
@@ -1,5 +1,29 @@
from tkinter import * from tkinter import *
####DRAW BLOCK
import requests
from time import sleep
def draw(cords):
for i in range(len(cords)):
sleep(0.2)
try:
payload = {'x': cords[i][1], 'y': cords[i][0], 'color': cords[i][2]}
except:
payload = {'x': cords[i][1], 'y': cords[i][0], 'color': "b" }
response = requests.post('http://pb.dmcraft.online', data=payload)
print(response)
while str(response) != "<Response [200]>":
response = requests.post('http://pb.dmcraft.online', data=payload)
print("Retrying...")
print(response)
print("!!!DONE!!!")
class PixelArt: class PixelArt:
def __init__(self, master): def __init__(self, master):
@@ -7,12 +31,22 @@ class PixelArt:
self.master.title("Pixel Art") self.master.title("Pixel Art")
self.canvas = Canvas(self.master, width=128*12, height=128*12, bg="white") self.canvas = Canvas(self.master, width=128*12, height=128*12, bg="white")
self.canvas.pack(side=LEFT, padx=5, pady=5) self.canvas.pack(side=LEFT, padx=5, pady=5)
self.colors = ["red", "green", "blue", "white"] self.colors = ["red", "green", "blue", "white","black"]
self.current_color = "red" self.current_color = "red"
self.button_frame = Frame(self.master) self.button_frame = Frame(self.master)
self.button_frame.pack(side=LEFT, padx=5, pady=5) self.button_frame.pack(side=LEFT, padx=5, pady=5)
self.export_button = Button(self.button_frame, text="Export", command=self.export_image) self.export_button = Button(self.button_frame, text="Export", command=self.export_image)
self.export_button.pack(side=TOP, padx=5, pady=5) self.export_button.pack(side=TOP, padx=5, pady=5)
self.button_frame.pack(side=LEFT, padx=5, pady=5)
self.export_button = Button(self.button_frame, text="Clean", command=self.clean_image)
self.export_button.pack(side=TOP, padx=5, pady=5)
self.button_frame.pack(side=LEFT, padx=5, pady=5)
self.export_button = Button(self.button_frame, text="Upload", command=self.upload_image)
self.export_button.pack(side=TOP, padx=5, pady=5)
self.color_buttons = [] self.color_buttons = []
for color in self.colors: for color in self.colors:
button = Button(self.button_frame, bg=color, width=3, height=1, command=lambda c=color: self.set_color(c)) button = Button(self.button_frame, bg=color, width=3, height=1, command=lambda c=color: self.set_color(c))
@@ -31,6 +65,30 @@ class PixelArt:
def set_color(self, color): def set_color(self, color):
self.current_color = color self.current_color = color
def clean_image(self):
items = self.canvas.find_all()
for item in items:
self.canvas.delete(item)
def upload_image(self):
pixel_data = []
for i in range(128):
for j in range(128):
color = self.canvas.itemcget(self.canvas.find_closest(i*12+6, j*12+6), "fill")
if color != "white":
match self.colors.index(color):
case 0:
color = "red"
case 1:
color = "green"
case 2:
color = "blue"
case 3:
color = "black"
pixel_data.append([i, 127-j, color])
print("!!!START UPLOAD!!!")
draw(pixel_data)
def export_image(self): def export_image(self):
pixel_data = [] pixel_data = []
for i in range(128): for i in range(128):
@@ -39,12 +97,14 @@ class PixelArt:
if color != "white": if color != "white":
match self.colors.index(color): match self.colors.index(color):
case 0: case 0:
color = "r" color = "red"
case 1: case 1:
color = "g" color = "green"
case 2: case 2:
color = "b" color = "blue"
pixel_data.append([i, j, color]) case 3:
color = "black"
pixel_data.append([i, 127-j, color])
f = open('out.txt', 'w') f = open('out.txt', 'w')
f.write(str(pixel_data)) f.write(str(pixel_data))
f.close() f.close()