Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 04011ffe15 | |||
| 50c62c7ad8 | |||
| b4721575aa | |||
| 7b45803a2c | |||
| 01f0ce97c7 | |||
| 0082a7e8cc |
@@ -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. Запрогроммировать свои инструкции для бота:
|
||||||
|
|||||||
@@ -3,12 +3,21 @@ from time import sleep
|
|||||||
|
|
||||||
def draw(cords):
|
def draw(cords):
|
||||||
for i in range(len(cords)):
|
for i in range(len(cords)):
|
||||||
sleep(0.6)
|
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': "blue" }
|
||||||
|
|
||||||
payload = {'x': cords[i][1], 'y': cords[i][0], 'color': 'b'}
|
|
||||||
response = requests.post('http://pb.dmcraft.online', data=payload)
|
response = requests.post('http://pb.dmcraft.online', data=payload)
|
||||||
print(response)
|
print(response)
|
||||||
|
|
||||||
|
while str(response) != "<Response [200]>":
|
||||||
|
response = requests.post('http://pb.dmcraft.online', data=payload)
|
||||||
|
print("Retrying...")
|
||||||
|
print(response)
|
||||||
|
print("DONE!")
|
||||||
|
|
||||||
def linex(y, x1, x2):
|
def linex(y, x1, x2):
|
||||||
res = []
|
res = []
|
||||||
for i in range(x1, x2+1):
|
for i in range(x1, x2+1):
|
||||||
@@ -22,8 +31,13 @@ def liney(x, y1, y2):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
l = [[65, 86, 'red'], [66, 87, 'red'], [66, 86, 'red'], [66, 85, 'red'], [67, 86, 'red'], [89, 97, 'red'], [90, 98, 'red'], [90, 97, 'red'], [90, 96, 'red'], [91, 97, 'red'], [95, 77, 'black'], [96, 78, 'black'], [96, 77, 'black'], [96, 76, 'black'], [97, 77, 'black'], [107, 108, 'blue'], [108, 109, 'blue'], [108, 108, 'blue'], [108, 107, 'blue'], [109, 108, 'blue']]
|
||||||
|
|
||||||
|
draw(l)
|
||||||
|
|
||||||
|
|
||||||
#draw( liney(300, 300, 500) )
|
#draw( liney(300, 300, 500) )
|
||||||
draw(linex(500, 300, 500))
|
#draw(linex(500, 300, 500))
|
||||||
|
|
||||||
'''
|
'''
|
||||||
xs = 180
|
xs = 180
|
||||||
|
|||||||
+65
-5
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user