4 Gimp plugin "TestGimpDiagram"
6 Test the GImpDiagram class
8 Copyright (C) 2018 Antonio Ospite <ao2@ao2.it>
10 This program is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 from diagram.gimp_diagram import GimpDiagram
30 gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
33 def test_diagram_main(image):
34 pdb.gimp_image_undo_group_start(image)
35 pdb.gimp_context_push()
36 pdb.gimp_context_set_defaults()
38 template_layer_name = "TestGimpDiagram"
39 template_layer = pdb.gimp_image_get_layer_by_name(image,
41 if not template_layer:
42 template_layer = pdb.gimp_layer_new(image, image.width, image.height,
47 pdb.gimp_image_add_layer(image, template_layer, -1)
49 diagram = GimpDiagram(image.width, image.height, image, template_layer,
50 font_size=10, stroke_size=2)
52 diagram.draw_regular_polygon(200, 200, 6, 100, 0,
55 diagram.draw_regular_polygon(200, 200, 6, 100, pi / 12.,
56 stroke_color=(1, 0, 0, 0.2))
58 diagram.draw_centered_text(200, 200, "__30__", pi / 6., (0, 0, 0))
60 pdb.gimp_context_pop()
61 pdb.gimp_image_undo_group_end(image)
64 if __name__ == "__main__":
66 "python_fu_test_gimp_diagram",
67 N_("Test GimpDiagram"),
69 "Antonio Ospite <ao2@ao2.it>",
70 "Copyright (C) 2018 Antonio Ospite <ao2@ao2.it>",
72 N_("TestGImpDiagram..."),
75 (PF_IMAGE, "image", "Input image", None),
79 menu="<Image>/Filters/Render",
80 domain=("gimp20-python", gimp.locale_directory)