PIKApp/devel-docs/PIKA3-plug-in-porting-guide/classes.md

101 lines
1.9 KiB
Markdown
Raw Normal View History

2023-09-26 00:35:21 +02:00
# Useful Modules/Classes in PIKA 3.0+
Here's a guide to the modules you're likely to need.
It's a work in progress: feel free to add to it.
Eventually we'll have online documentation for these classes.
In the meantime, you can generate your own:
```
HTMLDOCDIR=/path/to/doc/dir
g-ir-doc-tool -I /path/to/share/gir-1.0/ --language=Python -o $HTMLDOCDIR Gimp-3.0.gir
```
Then browse $HTMLDOCDIR with yelp, or generate HTML from it:
```
cd $HTMLDOCDIR
yelp-build cache *.page
yelp-build html .
```
You can also get some information in PIKA's Python console with
*help(module)* or *help(object)*, and you can get a list of functions
with *dir(object)*.
## Gimp
The base module: almost everything is under Pika.
## Pika.Image
The image object.
Some operations that used to be PDB calls, like
```
pdb.pika_selection_layer_alpha(layer)
```
are now in the Image object, e.g.
```
img.select_item(Pika.ChannelOps.REPLACE, layer)
```
## Pika.Layer
The layer object.
```
fog = Pika.Layer.new(image, name,
drawable.width(), drawable.height(), type, opacity,
Pika.LayerMode.NORMAL)
```
## Pika.Selection
Selection operations that used to be in the PDB, e.g.
```
pdb.pika_selection_none(img)
```
are now in the Pika.Selection module, e.g.
```
Pika.Selection.none(img)
```
## Pika.ImageType
A home for image types like RGBA, GRAY, etc:
```
Pika.ImageType.RGBA_IMAGE
```
## Pika.FillType
e.g. Pika.FillType.TRANSPARENT, Pika.FillType.BACKGROUND
## Pika.ChannelOps
The old channel op definitions in the pikafu module, like
```
CHANNEL_OP_REPLACE
```
are now in their own module:
```
Pika.ChannelOps.REPLACE
```
## Pika.RGB
In legacy plug-ins you could pass a simple list of integers, like (0, 0, 0).
In 3.0+, create a Pika.RGB object:
```
c = Pika.RGB()
c.set(240.0, 180.0, 70.0)
```
or
```
c.r = 0
c.g = 0
c.b = 0
c.a = 1
```