01-14-2024, 10:02 PM
I've got a barebones bit of python code - it sets the brush size and works out the centre coords.
I'v highlighted in red where I'm stuck.
Aspect ratio: not sure what the maths is here
Drawing/stroking: not sure what are valid parameters, correct syntax etc.
Menu location: similarly, not sure of correct menu placement code.
from gimpfu import *
def add_scaled_brush(img, layer):
# Set up an undo group, so the operation will be undone in one step.
pdb.gimp_undo_push_group_start(img)
# Do stuff here.
xCentre = img.width/2
yCentre = img.height/2
brushSize = float(img.width)
pdb.gimp_context_set_brush_size(brushSize)
aspectRatio = 0.0 #TO DO - calculate based on image height
pdb.gimp_context_set_brush_aspect_ratio(aspectRatio)
newLayer = pdb.gimp_layer_new(img, img.width, img.height, RGBA_IMAGE, "Scaled Brush", 100.0, LAYER_MODE_NORMAL)
pdb.gimp_image_insert_layer(img, newLayer, None, 0)
#draw with the current brush
#something to do with pdb.gimp_paintbrush
# Close the undo group.
pdb.gimp_undo_push_group_end(img)
register(
"add_scaled_brush", #Name
"Add Scaled Brush to Image", #Blurb
"Scale current brush to image, paint once to new layer.", #help
"R Soul", #Author
"CC Licence", #Copyright
"2024", #Date
"<Image>/Image/Add Scaled Brush", #Menu path, needs to go somewhere else
"", # image types
[ # No Gui Params
],
[], # Results
add_scaled_brush) #function
main()
I'v highlighted in red where I'm stuck.
Aspect ratio: not sure what the maths is here
Drawing/stroking: not sure what are valid parameters, correct syntax etc.
Menu location: similarly, not sure of correct menu placement code.
from gimpfu import *
def add_scaled_brush(img, layer):
# Set up an undo group, so the operation will be undone in one step.
pdb.gimp_undo_push_group_start(img)
# Do stuff here.
xCentre = img.width/2
yCentre = img.height/2
brushSize = float(img.width)
pdb.gimp_context_set_brush_size(brushSize)
aspectRatio = 0.0 #TO DO - calculate based on image height
pdb.gimp_context_set_brush_aspect_ratio(aspectRatio)
newLayer = pdb.gimp_layer_new(img, img.width, img.height, RGBA_IMAGE, "Scaled Brush", 100.0, LAYER_MODE_NORMAL)
pdb.gimp_image_insert_layer(img, newLayer, None, 0)
#draw with the current brush
#something to do with pdb.gimp_paintbrush
# Close the undo group.
pdb.gimp_undo_push_group_end(img)
register(
"add_scaled_brush", #Name
"Add Scaled Brush to Image", #Blurb
"Scale current brush to image, paint once to new layer.", #help
"R Soul", #Author
"CC Licence", #Copyright
"2024", #Date
"<Image>/Image/Add Scaled Brush", #Menu path, needs to go somewhere else
"", # image types
[ # No Gui Params
],
[], # Results
add_scaled_brush) #function
main()