Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some of the issues to get it working #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions image_pixels_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def load_as_binary_image(image_path):
converting it to a binary one (== black&white),
if it is not yet one.
'''
with Image.open(image_path) as img:
if img.mode != "1":
img = img.convert("L")
img = img.convert("1")
return img
img = Image.open(image_path)
if img.mode != "1":
img = img.convert("L")
img = img.convert("1")
return img

class ImagePixelsSource(PixelsSource):
'''
Expand Down
4 changes: 2 additions & 2 deletions placeholder2image.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ def _drawPixel(self, footprint: pcbnew.FOOTPRINT, index: int, pos: (int, int)):

def drawPixels(self):
footprint = pcbnew.FOOTPRINT(self.pcb)
footprint.SetDescription(f"Replaced template - {self.pixels}")
footprint.SetLibDescription(f"Replaced template - {self.pixels}")
footprint.SetLayer(self.placeholder.getLayer())

footprint.SetPosition(pcbnew.wxPoint(self.first_pixel_pos[0], self.first_pixel_pos[1]))
footprint.SetPosition(pcbnew.VECTOR2I(self.first_pixel_pos[0], self.first_pixel_pos[1]))
pos = (0, 0)
pixel_i = 0
x_i = 0
Expand Down
6 changes: 3 additions & 3 deletions string_pixels_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class StringPixelsSource(PixelsSource):
'''
def __init__(self, text: str):
self.text = text
text_size = _FONT.getsize(text)
image_size = (text_size[0] + 2, text_size[1] + 2)
text_size = _FONT.getbbox(text)
image_size = (text_size[2] + 2, text_size[3] + 2)
self.image = Image.new("RGBA", image_size, (0, 0, 0, 0))
draw = ImageDraw.Draw(self.image)
draw.rectangle(((0, 0), image_size), fill="white")
draw.rectangle(((1, 1), text_size), fill="black")
draw.rectangle(((1, 1), (text_size[2], text_size[3])), fill="black")
draw.text((1, -1), text, font=_FONT, spaceing=1)
self.image = self.image.convert("L")
self.image = self.image.convert("1")
Expand Down