修改後的程式碼,與測試的結果圖
width = 256
height = 256
seed = 32
detail = 4
landheight = 60
seadepth = 4
xscale = 4
yscale = 4
gradient = "Land 1"
img = pdb.gimp_image_new(width, height, RGB)
layer_one = pdb.gimp_layer_new(img, width, height, RGB_IMAGE, "Bottom", 100, NORMAL_MODE)
layer_two = 0
pdb.gimp_context_set_gradient(gradient)
pdb.gimp_image_undo_disable(img)
pdb.gimp_image_add_layer(img, layer_one, 0)
pdb.plug_in_solid_noise(img, layer_one, TRUE, FALSE, seed, detail, xscale, yscale)
pdb.plug_in_c_astretch(img, layer_one)
layer_two = pdb.gimp_layer_copy(layer_one, TRUE)
pdb.gimp_image_add_layer(img, layer_two, -1)
pdb.gimp_image_set_active_layer(img, layer_two)
pdb.plug_in_gradmap(img, layer_two)
pdb.gimp_by_color_select(layer_one, (190, 190, 190), 55, CHANNEL_OP_REPLACE, FALSE, FALSE, 0, FALSE)
pdb.plug_in_bump_map(img, layer_two, layer_one, 135.0, 35, landheight, 0, 0, 0, 0, TRUE, FALSE, 0)
#pdb.plug_in_c_astretch(img, layer_two)
pdb.gimp_selection_invert(img)
pdb.plug_in_bump_map(img, layer_two, layer_one, 135.0, 35, seadepth, 0, 0, 0, 0, TRUE, FALSE, 0)
#pdb.plug_in_c_astretch(img, layer_two)
# uncomment the next line if you want to keep a selection of the "land"
pdb.gimp_selection_none(img)
pdb.gimp_display_new(img)
pdb.gimp_image_undo_enable(img)