[gcompris-devel] GComprisShapegame gimp script
Angel Ivan Moreno
angelivanm at gmail.com
Sun Jan 22 23:27:41 UTC 2012
I managed to make it work adding a new option based on the geography one
created by Miguel de Izarra. The idea is the same. For each selection a new
channel needs to be created:
def gcompris_babyshapes(img, sdrawable, activity_name,
folder, title, bordersize, shapes_color,level,
sublevel):
"""Create file for the babyshapes activity from the current image """
# Default values
if(not activity_name):
activity_name = "babyshapes"
if not gcompris_init(img):
return
if len(img.channels) == 0:
gimp.message("Can't find channels. Please create them.")
return
save_bg = gimp.get_background()
save_fg = gimp.get_foreground()
layer_map = img.layers[0]
if not layer_map.has_alpha:
layer_map.add_alpha()
layerlist = []
for chan in img.channels :
pdb.gimp_selection_load(chan)
pdb.gimp_selection_grow(img, bordersize)
# create new layer from selection
pdb.gimp_edit_copy(layer_map)
pdb.gimp_floating_sel_to_layer(pdb.gimp_edit_paste(layer_map, 1))
layer = img.active_layer
layer.name = chan.name
layerlist.append(layer)
# Fill main image with a color
if shapes_color==1:
gimp.set_background(255,255, 255)
elif shapes_color==2:
gimp.set_background(0, 0, 0)
else:
gimp.set_background(randint(0, 255), randint(0, 255),
randint(0, 255))
pdb.gimp_selection_load(chan)
pdb.gimp_selection_grow(img, bordersize)
pdb.gimp_edit_fill(layer_map,BACKGROUND_FILL)
gimp.set_background(save_bg)
gimp.set_foreground(save_fg)
pdb.gimp_selection_none(img)
shape = dict()
shape["<tooltip>"] = "%n"
title_d = dict(x=600, y=495, justification="GTK_JUSTIFY_CENTER")
title_d["<name>"] = title
layer_map.name = "background"
gcompris_layer_to_board(layerlist, activity_name, folder, title_d,
layer_map, shape,
level, sublevel)
register(
"gcompris_babyshapes",
"Make files for babyshapes activity",
"Make files for babyshapes activity",
"Miguel de Izarra. Adapted by A.I. Moreno",
"Miguel de Izarra. Adapted by A.I. Moreno",
"2012",
"<Image>/Python-Fu/GCompris/Babyshapes",
"RGB*, GRAY*",
[
(PF_STRING, "activity_name", "Name of the activity (default =
babyshapes)", ""),
(PF_STRING, "folder", "Relative output directory (default = image
name)", ""),
(PF_STRING, "title", "GCompris puzzle title", ""),
(PF_SPINNER, "bordersize", "The Size of border ", 0, (0, 20, 1) ),
(PF_OPTION,"shapes_color", "Background color of shapes:", 0,
["Random","White","Black"]),
(PF_SPINNER, "level", "The level in the activity", 1, (1, 100, 1) ),
(PF_SPINNER, "sublevel", "The sub level in the activity", 0, (0,
20, 1) ),
],
[],
gcompris_babyshapes)
On Sun, Jan 22, 2012 at 5:20 PM, Angel Ivan Moreno <angelivanm at gmail.com>wrote:
> The Puzzle activity autogenerates the tiles. What I want is to be able to
> select the shapes I want for the babyshapes activity. I managed to to that
> by cutting and pasting the areas I wanted in new images, besides adding
> them to a channel. At the end, I run the geography script and replace the
> generated images with the ones manually generated. So I only reuse the
> generated xml file (still, removing the sound references). I wondered
> whether more automation was possible or if an updated script existed
> somewhere.
>
>
> On Sun, Jan 22, 2012 at 11:56 AM, Bruno Coudoin <
> bruno.coudoin at gcompris.net> wrote:
>
>> Le dimanche 22 janvier 2012 à 01:08 +0100, Angel Ivan Moreno a écrit :
>> > Is there a trick to use the python script for the babyshapes activity?
>> > The
>> > boards are very similar to the geography activity, but the python
>> > script
>> > does not seem to directly support it, although some of the xml files
>> > in
>> > that activity refer to that python script...
>> >
>> Hi,
>>
>> In Gimp, you should have a script-fu menu for GCompris with 2 entries
>> "Geography" and "Puzzle". I think the Puzzle one is close to what you
>> need, have you tried it ?
>>
>> Bruno.
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Try before you buy = See our experts in action!
>> The most comprehensive online learning library for Microsoft developers
>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>> Metro Style Apps, more. Free future releases when you subscribe now!
>> http://p.sf.net/sfu/learndevnow-dev2
>> _______________________________________________
>> gcompris-devel mailing list
>> gcompris-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gcompris-devel
>>
>
>
More information about the Gcompris-devel
mailing list