예제 #1
0
def svg_to_png(filename: str) -> Path:
    destination: Path = RESOURCE.img(filename + '.png')
    if not destination.exists():
        log.debug(f'creating transparent .png from {filename}...')
        dest_string = str(destination)
        source = RESOURCE.img(filename + '.svg')
        renderPM.drawToFile(svg2rlg(str(source)),
                            dest_string,
                            fmt="PNG",
                            bg=0x000000)
        make_black_background_transparent(dest_string)
        log.debug(f'done creating transparent .png from {filename}.')
    return destination
예제 #2
0
def make_circle_glyph(size, rel_radius: float, color_rgb: Tuple[int, ...]):
    fp = RESOURCE.img(f'glyph-{"-".join(map(str, [size, *color_rgb]))}.png')
    if not RESOURCE.img(fp).exists():
        half = int(size / 2.)
        color = color_rgb[::-1]
        img = np.zeros((size, size, 3), dtype=np.uint8)
        img = cv2.circle(img,
                         center=(half, half),
                         radius=int((size * rel_radius) / 2),
                         color=color,
                         thickness=-1)
        cv2.imwrite(str(fp), np.dstack((img, make_alpha(img))))
    return fp
예제 #3
0
파일: chart.py 프로젝트: pcreagan/test_old
    def _set_background(self) -> None:
        self.ax.imshow(
            helper.img_from_pickle(RESOURCE.img('colorspace.p')),
            origin='upper', extent=cie_extent, alpha=1, zorder=10
        )
        patches = [
            Circle(
                (x + CIE_X_OFFSET, y + CIE_Y_OFFSET), r, linewidth=0.5
            ) for x, y, r in zip(*[[
                getattr(param_row, k) for param_row in self.params.rows
            ] for k in ['x_nom', 'y_nom', 'color_dist_max']
            ])
        ]

        self.artists['params_collection'] = self.var(self.ax.add_collection(PatchCollection(
            patches, linewidths=0.5, facecolors=IP_FACE_COLOR, alpha=0.4, zorder=11
        )))
예제 #4
0
 def _set_background(self) -> None:
     self.ax.imshow(Image.open(RESOURCE.img(f'mn{self.params.mn}.png')),
                    origin='upper',
                    extent=unit_extent,
                    alpha=0.5,
                    zorder=-1)
예제 #5
0
 def __post_init__(self):
     (self.enable if self._force_enabled else self.disable)()
     self.config(bg=COLORS.dark_grey)
     self.img = self._make_image(RESOURCE.img(self.filepath))
     self._load(tk.Label(self, anchor='center', image=self.img, bg=COLORS.black))
예제 #6
0
def make_ico(img, filename: str, sizes: Tuple[int, ...]):
    img.save(str(RESOURCE.img(filename + '.ico')),
             sizes=[(v, v) for v in sizes])