download: hello-world.py
#!/usr/bin/env python
# -*- coding: latin-1 -*-
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# Copyright 2006 - Juan José Conti <jjconti@gnu.org>
# Copyleft :-)
from gimpfu import *
def hello_world(bg_colour, fg_colour, circle_colour, text):
img = pdb.gimp_image_new(200, 120, RGB)
layer = pdb.gimp_layer_new(img, 200, 120, RGB_IMAGE, "Greet", 100, NORMAL_MODE)
pdb.gimp_image_add_layer(img,layer,0)
pdb.gimp_context_set_background(bg_colour)
pdb.gimp_drawable_fill(layer,BACKGROUND_FILL)
pdb.gimp_context_set_foreground(circle_colour)
draw_circle(img, layer, 70, 60, 40)
pdb.gimp_context_set_foreground(fg_colour)
float_text = set_text(img, layer, 50, 50, text)
pdb.gimp_floating_sel_anchor(float_text)
pdb.gimp_selection_none(img)
pdb.gimp_display_new(img)
def set_text(img, layer, x, y, text):
# last parameter, font name, must be installed in the system
return pdb.gimp_text_fontname(img, layer, x, y, text, 1, False, 16, PIXELS,"URW Gothic L")
def draw_circle(img, layer, x_center, y_center, rad):
x_top_left = x_center - rad
y_top_left = y_center - rad
pdb.gimp_ellipse_select(img, x_top_left, y_top_left, 2*rad, 2*rad, CHANNEL_OP_ADD, False, 0, 0)
pdb.gimp_edit_bucket_fill(layer, FG_BUCKET_FILL, NORMAL_MODE,100, 0, 0, 0, 0)
pdb.gimp_selection_none(img)
register(
"hello_world",
"Un saludo",
"Un saludo",
"Juanjo Conti",
"Juanjo Conti",
"2006",
"<Toolbox>/Xtns/Python-Fu/Hello/World",
"",
[
(PF_COLOR, "bg_colour", "Color de fondo:", (255,255,255)),
(PF_COLOR, "fg_colour", "Color del texto:", (0,0,0)),
(PF_COLOR, "circle_colour", "Color del circulo:", (216,255,255)),
(PF_STRING, "text", "Texto de saludo", "Hello World!")
],
[],
hello_world)
main()