Switch to full style
Ask all general Gimp related questions here
Post a reply

GTK help needed text in black needed

Fri Nov 01, 2019 6:51 am

GIMP Version:
Operating System: Mac OS
GIMP Experience: Experienced User



In my checker (plugin to be found here) I use
drawable = pdb.gimp_layer_new(image, 10, 10, 1, "dambackground", 100, NORMAL_MODE)
pdb.gimp_image_add_layer(image, drawable, 0)
theText = text_layer = pdb.gimp_text_fontname(image, drawable, 0, 0, 'Dam', 0, True, 32, 0, 'Segoe print')

to change a stone to a "DAM" stone (promoted stone on the base-line)
That works nice on black stones:... a white name on the stone: Dam
BUT on a white stone DAM is written too in white and not really visible.

Would someone be so kind and knows how to make the written DAM in black and tells it to me?

Files to run see: https://github.com/PKHG/guidelab_paint

Re: GTK help needed text in black needed

Fri Nov 01, 2019 3:35 pm

Set the foreground to whatever is needed by

Code:
import gimpcolor
pdb.gimp_context_set_foreground(gimpcolor.RGB(0,0,0))

RGB values are either 0..255 (type "int") or (0. .. 1.) (type float).

It is good form to start your script with pdb.gimp_context_push() and use pdb.gimp_context_pop() just before exiting (after catching all exceptions), so that the user's settings aren't polluted with the settings needed in your script.

Re: GTK help needed text in black needed

Sat Nov 02, 2019 1:12 am

What an easy solution.
Was not aware that the forgroundcolor is used ..
Thanks Ofnuts ;-)

Re: GTK help needed text in black needed

Sat Nov 02, 2019 3:59 am

PKHG wrote:What an easy solution.
Was not aware that the forgroundcolor is used ..
Thanks Ofnuts ;-)


The color has to come from somewhere... Have a look at all the *-context-* functions, that where you set all parameters used to render things.

Re: GTK help needed text in black needed

Sat Nov 02, 2019 6:14 am

Just discovered something, which looks like an error:
pdb.gimp_vectors_bezier_stroke_new_ellipse(new_vectors ,W/2 ,W/2,W/2 ,W/2, 0)
Does not create a real Circle. The Circle from the toolbox CAN do it

Picture above Circle from the Gimp_window tools
picture below result of the pub....ellipse ;-(

Can the toolbox ellipse be run from a python-plugin?
If so, please tell me ;-)

Solved: gimp-image-select-ellipse works perfectly

Re: GTK help needed text in black needed

Sat Nov 02, 2019 10:29 am

PKHG wrote:Just discovered something, which looks like an error:
pdb.gimp_vectors_bezier_stroke_new_ellipse(new_vectors ,W/2 ,W/2,W/2 ,W/2, 0)
Does not create a real Circle. The Circle from the toolbox CAN do it

Picture above Circle from the Gimp_window tools
picture below result of the pub....ellipse ;-(

Can the toolbox ellipse be run from a python-plugin?
If so, please tell me ;-)

Solved: gimp-image-select-ellipse works perfectly


I create the ellipse myself, all you have to know is the "kappa" magic number:

Code:
kappa=4*(math.sqrt(2)-1)/3


Then to create a quarter of circle of radius R, you create tangents of length R*Kappa. For a full circles, 4 anchors and 8 tangents. For an ellipse, use half-axes instead of R.

See http://spencermortensen.com/articles/bezier-circle/
Post a reply