#!/usr/bin/env python
# -*- coding: utf-8 -*-
# add-pixels-to-tiles v1.0: Python-fu plugin for GIMP 2.8
# Copyright Ivan Enzhaev (8Observer8) [http://ivan.enzhaev.name], 2015
# Licence GPL-2
# Installation: put the file into /GIMP 2/lib/gimp/2.0/plug-ins
from gimpfu import *
import os
def python_fu_add_pixels_to_tiles(tile_size = 16):
# Get image
image = gimp.image_list()[0]
# Get drawable
drawable = pdb.gimp_image_get_active_drawable(image)
# Get width and height
width = pdb.gimp_image_width(image)
height = pdb.gimp_image_height(image)
# Right
x = 17
y = 2
spacing = 5
y_counter = 0
while y < height:
while x < width:
# Get color
color = pdb.gimp_color_picker(image, drawable, x, y, FALSE, FALSE, 0)
# Set end point
ctrlPoints = [x+1,y,x+2,y]
if color.a == 1:
# Set color
pdb.gimp_context_set_foreground(color)
# Draw points
pdb.gimp_pencil(drawable, 4, ctrlPoints)
x = x + spacing + tile_size
x = 17
if y_counter < tile_size:
y = y + 1
else:
y = y + spacing
y_counter = 0
# Top
x = 2
y = 2
spacing = 5
x_counter = 0
while x < width:
while y < height:
# Get color
color = pdb.gimp_color_picker(image, drawable, x, y, FALSE, FALSE, 0)
# Set end point
ctrlPoints = [x,y-1,x,y-2]
if color.a == 1:
# Set color
pdb.gimp_context_set_foreground(color)
# Draw points
pdb.gimp_pencil(drawable, 4, ctrlPoints)
y = y + spacing + tile_size
y = 2
if x_counter < tile_size:
x = x + 1
else:
x = x + spacing
x_counter = 0
# Left
x = 2
y = 2
spacing = 5
y_counter = 0
while y < height:
while x < width:
# Get color
color = pdb.gimp_color_picker(image, drawable, x, y, FALSE, FALSE, 0)
# Set end point
ctrlPoints = [x-1,y,x-2,y]
if color.a == 1:
# Set color
pdb.gimp_context_set_foreground(color)
# Draw points
pdb.gimp_pencil(drawable, 4, ctrlPoints)
x = x + spacing + tile_size
x = 2
if y_counter < tile_size:
y = y + 1
else:
y = y + spacing
y_counter = 0
# Down
x = 2
y = 17
spacing = 5
x_counter = 0
while x < width:
while y < height:
# Get color
color = pdb.gimp_color_picker(image, drawable, x, y, FALSE, FALSE, 0)
# Set end point
ctrlPoints = [x,y+1,x,y+2]
if color.a == 1:
# Set color
pdb.gimp_context_set_foreground(color)
# Draw points
pdb.gimp_pencil(drawable, 4, ctrlPoints)
y = y + spacing + tile_size
y = 17
if x_counter < tile_size:
x = x + 1
else:
x = x + spacing
x_counter = 0
register(
"python_fu_add_pixels_to_tiles",
"Add a few pixels to tiles",
"Add a few pixels to tiles",
"Ivan Enzhaev (nickname: 8Observer8; email: 8observer8@gmail.com)",
"Ivan Enzhaev (nickname: 8Observer8; email: 8observer8@gmail.com)",
"8/18/2015",
"AddPxToTiles",
"*",
[
(PF_INT, "tile_size", "Tile Size", 16)
],
[],
python_fu_add_pixels_to_tiles,
menu="<Image>/Filters/Map",
)
main()