Skip to content

Commit

Permalink
Make holes in PCB transparent
Browse files Browse the repository at this point in the history
  • Loading branch information
yaqwsx committed Sep 22, 2022
1 parent 38f2d45 commit d717719
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pcbdraw/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,18 @@ def f(plan: RenderAction, substrate: Image.Image, board: Image.Image) \

if makeTransparent:
board = board.convert("RGBA")
pixel = board.getpixel((1, 1))
pixel = np.array(board.getpixel((1, 1)))

ImageDraw.floodfill(board, (1, 1), (0, 0, 0, 0), thresh=30)
npBoard = np.array(board) # type: ignore
yVec, xVec = np.where(np.all(npBoard == pixel, axis=2))
for pos in zip(xVec, yVec):
ImageDraw.floodfill(board, pos, (0, 0, 0, 0), thresh=30)
# This isn't the fastest way, but given the cost of raytracing it is
# good enough for now.
for rId, row in enumerate(npBoard):
for cId, elem in enumerate(row):
fPix = np.array([int(x) for x in elem])
distance = np.linalg.norm(fPix - pixel)
if distance < 20:
ImageDraw.floodfill(board, (cId, rId), (0, 0, 0, 0), thresh=30)



btlx -= pxHPadding
Expand Down

0 comments on commit d717719

Please sign in to comment.