else
added xy spinbox
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 568 KiB After Width: | Height: | Size: 419 KiB |
BIN
.GitImages/texturetile04.png
Normal file
After Width: | Height: | Size: 40 KiB |
6
Decorner/README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Decorner
|
||||||
|
========
|
||||||
|
|
||||||
|
I made this so I can trim the corners off of screenshots of Windows 7 window frames, because they're rounded and I want the background to be transparent.
|
||||||
|
|
||||||
|
It only works if the image is a perfect screenshot of the window.
|
32
Decorner/decorner.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
from PIL import Image
|
||||||
|
import sys
|
||||||
|
|
||||||
|
imagename = sys.argv[1]
|
||||||
|
image = Image.open(imagename)
|
||||||
|
w = image.size[0] - 1
|
||||||
|
h = image.size[1] - 1
|
||||||
|
for i in range(5):
|
||||||
|
image.putpixel( (0, i), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (0, h-i), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w, i), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w, h-i), (0, 0, 0, 0))
|
||||||
|
for i in range(3):
|
||||||
|
image.putpixel( (1, i), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (1, h-i), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w-1, i), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w-1, h-i), (0, 0, 0, 0))
|
||||||
|
for i in range(2):
|
||||||
|
image.putpixel( (2, i), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (2, h-i), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w-2, i), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w-2, h-i), (0, 0, 0, 0))
|
||||||
|
|
||||||
|
image.putpixel( (3, 0), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (3, h), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w-3, 0), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w-3, h), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (4, 0), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (4, h), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w-4, 0), (0, 0, 0, 0))
|
||||||
|
image.putpixel( (w-4, h), (0, 0, 0, 0))
|
||||||
|
image.save(imagename)
|
BIN
Decorner/test_after.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
Decorner/test_before.png
Normal file
After Width: | Height: | Size: 26 KiB |
|
@ -18,4 +18,8 @@ Make it small!
|
||||||
Make it any size at all!
|
Make it any size at all!
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://github.com/voussoir/else/blob/master/.GitImages/texturetile03.png?raw=true" alt="texture tile"/>
|
<img src="https://github.com/voussoir/else/blob/master/.GitImages/texturetile03.png?raw=true" alt="texture tile"/>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="https://github.com/voussoir/else/blob/master/.GitImages/texturetile04.png?raw=true" alt="texture tile"/>
|
||||||
</p>
|
</p>
|
|
@ -9,8 +9,8 @@ class TextureTile:
|
||||||
|
|
||||||
self.t = tkinter.Tk()
|
self.t = tkinter.Tk()
|
||||||
self.t.title(self.windowtitle)
|
self.t.title(self.windowtitle)
|
||||||
self.w = 450
|
self.w = 500
|
||||||
self.h = 475
|
self.h = 525
|
||||||
self.screenwidth = self.t.winfo_screenwidth()
|
self.screenwidth = self.t.winfo_screenwidth()
|
||||||
self.screenheight = self.t.winfo_screenheight()
|
self.screenheight = self.t.winfo_screenheight()
|
||||||
self.windowwidth = self.w
|
self.windowwidth = self.w
|
||||||
|
@ -21,15 +21,19 @@ class TextureTile:
|
||||||
self.t.geometry(self.geometrystring)
|
self.t.geometry(self.geometrystring)
|
||||||
|
|
||||||
self.entry_filename = tkinter.Entry(self.t, font=('Consolas', 12))
|
self.entry_filename = tkinter.Entry(self.t, font=('Consolas', 12))
|
||||||
|
self.spinbox_x = tkinter.Spinbox(self.t, width=2, from_=1, to=2 ** 13)
|
||||||
|
self.spinbox_y = tkinter.Spinbox(self.t, width=2, from_=1, to=2 ** 13)
|
||||||
self.button_load = tkinter.Button(self.t, text='Load', command=self.file_load_display)
|
self.button_load = tkinter.Button(self.t, text='Load', command=self.file_load_display)
|
||||||
self.frame_filearea = tkinter.Frame(self.t)
|
self.frame_filearea = tkinter.Frame(self.t)
|
||||||
self.label_image = tkinter.Label(self.frame_filearea, bg='#222')
|
self.label_image = tkinter.Label(self.frame_filearea, bg='#222')
|
||||||
|
|
||||||
self.t.columnconfigure(0, weight=1)
|
self.t.columnconfigure(0, weight=1)
|
||||||
self.t.rowconfigure(1, weight=1)
|
self.t.rowconfigure(1, weight=1)
|
||||||
self.entry_filename.grid(row=0, column=0, sticky='ew')
|
self.entry_filename.grid(row=0, column=0, sticky='ew')
|
||||||
self.button_load.grid(row=0, column=1, sticky='ne')
|
self.spinbox_x.grid(row=0, column=1)
|
||||||
self.frame_filearea.grid(row=1, column=0, columnspan=2, sticky='nsew')
|
self.spinbox_y.grid(row=0, column=2)
|
||||||
|
self.button_load.grid(row=0, column=3, sticky='ne')
|
||||||
|
self.frame_filearea.grid(row=1, column=0, columnspan=4, sticky='nsew')
|
||||||
self.label_image.pack(expand=True, fill='both')
|
self.label_image.pack(expand=True, fill='both')
|
||||||
#self.entry_filename.pack(fill='x')
|
#self.entry_filename.pack(fill='x')
|
||||||
#self.button_load.pack()
|
#self.button_load.pack()
|
||||||
|
@ -39,10 +43,20 @@ class TextureTile:
|
||||||
self.entry_filename.bind('<Return>', self.file_load_display)
|
self.entry_filename.bind('<Return>', self.file_load_display)
|
||||||
self.entry_filename.focus_set()
|
self.entry_filename.focus_set()
|
||||||
|
|
||||||
|
self.spinbox_x.delete(0, 'end')
|
||||||
|
self.spinbox_x.insert(0, 3)
|
||||||
|
self.spinbox_y.delete(0, 'end')
|
||||||
|
self.spinbox_y.insert(0, 3)
|
||||||
|
|
||||||
self.t.mainloop()
|
self.t.mainloop()
|
||||||
|
|
||||||
def file_load_display(self, *event):
|
def file_load_display(self, *event):
|
||||||
filename = self.entry_filename.get()
|
filename = self.entry_filename.get()
|
||||||
|
# I want to check the spinbox values up
|
||||||
|
# here so they can crash before wasting
|
||||||
|
# a file read.
|
||||||
|
xcount = int(self.spinbox_x.get())
|
||||||
|
ycount = int(self.spinbox_y.get())
|
||||||
# Open file or turn red
|
# Open file or turn red
|
||||||
try:
|
try:
|
||||||
image = Image.open(filename)
|
image = Image.open(filename)
|
||||||
|
@ -55,9 +69,9 @@ class TextureTile:
|
||||||
w = image.size[0]
|
w = image.size[0]
|
||||||
h = image.size[1]
|
h = image.size[1]
|
||||||
expanded = image.copy()
|
expanded = image.copy()
|
||||||
expanded = expanded.resize((w * 3, h * 3))
|
expanded = expanded.resize((w * xcount, h * ycount))
|
||||||
for x in range(3):
|
for x in range(xcount):
|
||||||
for y in range(3):
|
for y in range(ycount):
|
||||||
expanded.paste(image, (w*x, h*y))
|
expanded.paste(image, (w*x, h*y))
|
||||||
|
|
||||||
# Resize 9x'ed image into frame
|
# Resize 9x'ed image into frame
|
||||||
|
|