From 5c1676dfe6d2f3c837a5e074117b45613fd29a72 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:30:19 +0200 Subject: Adding upstream version 2.10.34. Signed-off-by: Daniel Baumann --- plug-ins/ifs-compose/Makefile.am | 55 + plug-ins/ifs-compose/Makefile.in | 1014 ++++++++++ plug-ins/ifs-compose/README.ifscompose | 83 + plug-ins/ifs-compose/ifs-compose-storage.c | 551 ++++++ plug-ins/ifs-compose/ifs-compose-utils.c | 1092 +++++++++++ plug-ins/ifs-compose/ifs-compose.c | 2799 ++++++++++++++++++++++++++++ plug-ins/ifs-compose/ifs-compose.h | 180 ++ 7 files changed, 5774 insertions(+) create mode 100644 plug-ins/ifs-compose/Makefile.am create mode 100644 plug-ins/ifs-compose/Makefile.in create mode 100644 plug-ins/ifs-compose/README.ifscompose create mode 100644 plug-ins/ifs-compose/ifs-compose-storage.c create mode 100644 plug-ins/ifs-compose/ifs-compose-utils.c create mode 100644 plug-ins/ifs-compose/ifs-compose.c create mode 100644 plug-ins/ifs-compose/ifs-compose.h (limited to 'plug-ins/ifs-compose') diff --git a/plug-ins/ifs-compose/Makefile.am b/plug-ins/ifs-compose/Makefile.am new file mode 100644 index 0000000..c111473 --- /dev/null +++ b/plug-ins/ifs-compose/Makefile.am @@ -0,0 +1,55 @@ +## Process this file with automake to produce Makefile.in + +if OS_WIN32 +mwindows = -mwindows +else +libm = -lm +endif + +libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la +libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la +libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la +libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la +libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la + +if HAVE_WINDRES +include $(top_srcdir)/build/windows/gimprc-plug-ins.rule +ifs_compose_RC = ifs-compose.rc.o +endif + +AM_LDFLAGS = $(mwindows) + +libexecdir = $(gimpplugindir)/plug-ins/ifs-compose + +libexec_PROGRAMS = ifs-compose + +ifs_compose_SOURCES = \ + ifs-compose.c \ + ifs-compose.h \ + ifs-compose-utils.c \ + ifs-compose-storage.c + +EXTRA_DIST = README.ifscompose + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + $(GTK_CFLAGS) \ + $(GEGL_CFLAGS) \ + -I$(includedir) + +LDADD = \ + $(libm) \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEGL_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(ifs_compose_RC) diff --git a/plug-ins/ifs-compose/Makefile.in b/plug-ins/ifs-compose/Makefile.in new file mode 100644 index 0000000..5c28298 --- /dev/null +++ b/plug-ins/ifs-compose/Makefile.in @@ -0,0 +1,1014 @@ +# Makefile.in generated by automake 1.16.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2020 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Version resources for Microsoft Windows + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +libexec_PROGRAMS = ifs-compose$(EXEEXT) +subdir = plug-ins/ifs-compose +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/m4macros/alsa.m4 \ + $(top_srcdir)/m4macros/ax_compare_version.m4 \ + $(top_srcdir)/m4macros/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4macros/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4macros/ax_prog_cc_for_build.m4 \ + $(top_srcdir)/m4macros/ax_prog_perl_version.m4 \ + $(top_srcdir)/m4macros/detectcflags.m4 \ + $(top_srcdir)/m4macros/pythondev.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(libexecdir)" +PROGRAMS = $(libexec_PROGRAMS) +am_ifs_compose_OBJECTS = ifs-compose.$(OBJEXT) \ + ifs-compose-utils.$(OBJEXT) ifs-compose-storage.$(OBJEXT) +ifs_compose_OBJECTS = $(am_ifs_compose_OBJECTS) +ifs_compose_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +ifs_compose_DEPENDENCIES = $(am__DEPENDENCIES_1) $(libgimpui) \ + $(libgimpwidgets) $(libgimpconfig) $(libgimp) $(libgimpcolor) \ + $(libgimpmath) $(libgimpbase) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(ifs_compose_RC) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/ifs-compose-storage.Po \ + ./$(DEPDIR)/ifs-compose-utils.Po ./$(DEPDIR)/ifs-compose.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(ifs_compose_SOURCES) +DIST_SOURCES = $(ifs_compose_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/build/windows/gimprc-plug-ins.rule \ + $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +AA_LIBS = @AA_LIBS@ +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +ALL_LINGUAS = @ALL_LINGUAS@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +ALTIVEC_EXTRA_CFLAGS = @ALTIVEC_EXTRA_CFLAGS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +APPSTREAM_UTIL = @APPSTREAM_UTIL@ +AR = @AR@ +AS = @AS@ +ATK_CFLAGS = @ATK_CFLAGS@ +ATK_LIBS = @ATK_LIBS@ +ATK_REQUIRED_VERSION = @ATK_REQUIRED_VERSION@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BABL_CFLAGS = @BABL_CFLAGS@ +BABL_LIBS = @BABL_LIBS@ +BABL_REQUIRED_VERSION = @BABL_REQUIRED_VERSION@ +BUG_REPORT_URL = @BUG_REPORT_URL@ +BUILD_EXEEXT = @BUILD_EXEEXT@ +BUILD_OBJEXT = @BUILD_OBJEXT@ +BZIP2_LIBS = @BZIP2_LIBS@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_LIBS = @CAIRO_LIBS@ +CAIRO_PDF_CFLAGS = @CAIRO_PDF_CFLAGS@ +CAIRO_PDF_LIBS = @CAIRO_PDF_LIBS@ +CAIRO_PDF_REQUIRED_VERSION = @CAIRO_PDF_REQUIRED_VERSION@ +CAIRO_REQUIRED_VERSION = @CAIRO_REQUIRED_VERSION@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CC_VERSION = @CC_VERSION@ +CFLAGS = @CFLAGS@ +CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ +CPP_FOR_BUILD = @CPP_FOR_BUILD@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DESKTOP_DATADIR = @DESKTOP_DATADIR@ +DESKTOP_FILE_VALIDATE = @DESKTOP_FILE_VALIDATE@ +DLLTOOL = @DLLTOOL@ +DOC_SHOOTER = @DOC_SHOOTER@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FILE_AA = @FILE_AA@ +FILE_EXR = @FILE_EXR@ +FILE_HEIF = @FILE_HEIF@ +FILE_JP2_LOAD = @FILE_JP2_LOAD@ +FILE_JPEGXL = @FILE_JPEGXL@ +FILE_MNG = @FILE_MNG@ +FILE_PDF_SAVE = @FILE_PDF_SAVE@ +FILE_PS = @FILE_PS@ +FILE_WMF = @FILE_WMF@ +FILE_XMC = @FILE_XMC@ +FILE_XPM = @FILE_XPM@ +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +FONTCONFIG_REQUIRED_VERSION = @FONTCONFIG_REQUIRED_VERSION@ +FREETYPE2_REQUIRED_VERSION = @FREETYPE2_REQUIRED_VERSION@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GDBUS_CODEGEN = @GDBUS_CODEGEN@ +GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@ +GDK_PIXBUF_CSOURCE = @GDK_PIXBUF_CSOURCE@ +GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@ +GDK_PIXBUF_REQUIRED_VERSION = @GDK_PIXBUF_REQUIRED_VERSION@ +GEGL = @GEGL@ +GEGL_CFLAGS = @GEGL_CFLAGS@ +GEGL_LIBS = @GEGL_LIBS@ +GEGL_MAJOR_MINOR_VERSION = @GEGL_MAJOR_MINOR_VERSION@ +GEGL_REQUIRED_VERSION = @GEGL_REQUIRED_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GEXIV2_CFLAGS = @GEXIV2_CFLAGS@ +GEXIV2_LIBS = @GEXIV2_LIBS@ +GEXIV2_REQUIRED_VERSION = @GEXIV2_REQUIRED_VERSION@ +GIMP_API_VERSION = @GIMP_API_VERSION@ +GIMP_APP_VERSION = @GIMP_APP_VERSION@ +GIMP_BINARY_AGE = @GIMP_BINARY_AGE@ +GIMP_COMMAND = @GIMP_COMMAND@ +GIMP_DATA_VERSION = @GIMP_DATA_VERSION@ +GIMP_FULL_NAME = @GIMP_FULL_NAME@ +GIMP_INTERFACE_AGE = @GIMP_INTERFACE_AGE@ +GIMP_MAJOR_VERSION = @GIMP_MAJOR_VERSION@ +GIMP_MICRO_VERSION = @GIMP_MICRO_VERSION@ +GIMP_MINOR_VERSION = @GIMP_MINOR_VERSION@ +GIMP_MKENUMS = @GIMP_MKENUMS@ +GIMP_MODULES = @GIMP_MODULES@ +GIMP_PACKAGE_REVISION = @GIMP_PACKAGE_REVISION@ +GIMP_PKGCONFIG_VERSION = @GIMP_PKGCONFIG_VERSION@ +GIMP_PLUGINS = @GIMP_PLUGINS@ +GIMP_PLUGIN_VERSION = @GIMP_PLUGIN_VERSION@ +GIMP_REAL_VERSION = @GIMP_REAL_VERSION@ +GIMP_RELEASE = @GIMP_RELEASE@ +GIMP_SYSCONF_VERSION = @GIMP_SYSCONF_VERSION@ +GIMP_TOOL_VERSION = @GIMP_TOOL_VERSION@ +GIMP_UNSTABLE = @GIMP_UNSTABLE@ +GIMP_USER_VERSION = @GIMP_USER_VERSION@ +GIMP_VERSION = @GIMP_VERSION@ +GIO_CFLAGS = @GIO_CFLAGS@ +GIO_LIBS = @GIO_LIBS@ +GIO_UNIX_CFLAGS = @GIO_UNIX_CFLAGS@ +GIO_UNIX_LIBS = @GIO_UNIX_LIBS@ +GIO_WINDOWS_CFLAGS = @GIO_WINDOWS_CFLAGS@ +GIO_WINDOWS_LIBS = @GIO_WINDOWS_LIBS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GLIB_REQUIRED_VERSION = @GLIB_REQUIRED_VERSION@ +GMODULE_NO_EXPORT_CFLAGS = @GMODULE_NO_EXPORT_CFLAGS@ +GMODULE_NO_EXPORT_LIBS = @GMODULE_NO_EXPORT_LIBS@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GOBJECT_QUERY = @GOBJECT_QUERY@ +GREP = @GREP@ +GS_LIBS = @GS_LIBS@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_LIBS = @GTK_LIBS@ +GTK_MAC_INTEGRATION_CFLAGS = @GTK_MAC_INTEGRATION_CFLAGS@ +GTK_MAC_INTEGRATION_LIBS = @GTK_MAC_INTEGRATION_LIBS@ +GTK_REQUIRED_VERSION = @GTK_REQUIRED_VERSION@ +GTK_UPDATE_ICON_CACHE = @GTK_UPDATE_ICON_CACHE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@ +HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HARFBUZZ_REQUIRED_VERSION = @HARFBUZZ_REQUIRED_VERSION@ +HAVE_CXX14 = @HAVE_CXX14@ +HAVE_FINITE = @HAVE_FINITE@ +HAVE_ISFINITE = @HAVE_ISFINITE@ +HAVE_VFORK = @HAVE_VFORK@ +HOST_GLIB_COMPILE_RESOURCES = @HOST_GLIB_COMPILE_RESOURCES@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_REQUIRED_VERSION = @INTLTOOL_REQUIRED_VERSION@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +ISO_CODES_LOCALEDIR = @ISO_CODES_LOCALEDIR@ +ISO_CODES_LOCATION = @ISO_CODES_LOCATION@ +JPEG_LIBS = @JPEG_LIBS@ +JSON_GLIB_CFLAGS = @JSON_GLIB_CFLAGS@ +JSON_GLIB_LIBS = @JSON_GLIB_LIBS@ +JXL_CFLAGS = @JXL_CFLAGS@ +JXL_LIBS = @JXL_LIBS@ +JXL_THREADS_CFLAGS = @JXL_THREADS_CFLAGS@ +JXL_THREADS_LIBS = @JXL_THREADS_LIBS@ +LCMS_CFLAGS = @LCMS_CFLAGS@ +LCMS_LIBS = @LCMS_LIBS@ +LCMS_REQUIRED_VERSION = @LCMS_REQUIRED_VERSION@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ +LIBBACKTRACE_LIBS = @LIBBACKTRACE_LIBS@ +LIBHEIF_CFLAGS = @LIBHEIF_CFLAGS@ +LIBHEIF_LIBS = @LIBHEIF_LIBS@ +LIBHEIF_REQUIRED_VERSION = @LIBHEIF_REQUIRED_VERSION@ +LIBJXL_REQUIRED_VERSION = @LIBJXL_REQUIRED_VERSION@ +LIBLZMA_REQUIRED_VERSION = @LIBLZMA_REQUIRED_VERSION@ +LIBMYPAINT_CFLAGS = @LIBMYPAINT_CFLAGS@ +LIBMYPAINT_LIBS = @LIBMYPAINT_LIBS@ +LIBMYPAINT_REQUIRED_VERSION = @LIBMYPAINT_REQUIRED_VERSION@ +LIBOBJS = @LIBOBJS@ +LIBPNG_REQUIRED_VERSION = @LIBPNG_REQUIRED_VERSION@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@ +LIBUNWIND_LIBS = @LIBUNWIND_LIBS@ +LIBUNWIND_REQUIRED_VERSION = @LIBUNWIND_REQUIRED_VERSION@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_CURRENT_MINUS_AGE = @LT_CURRENT_MINUS_AGE@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +LT_VERSION_INFO = @LT_VERSION_INFO@ +LZMA_CFLAGS = @LZMA_CFLAGS@ +LZMA_LIBS = @LZMA_LIBS@ +MAIL = @MAIL@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MIME_INFO_CFLAGS = @MIME_INFO_CFLAGS@ +MIME_INFO_LIBS = @MIME_INFO_LIBS@ +MIME_TYPES = @MIME_TYPES@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MMX_EXTRA_CFLAGS = @MMX_EXTRA_CFLAGS@ +MNG_CFLAGS = @MNG_CFLAGS@ +MNG_LIBS = @MNG_LIBS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +MYPAINT_BRUSHES_CFLAGS = @MYPAINT_BRUSHES_CFLAGS@ +MYPAINT_BRUSHES_LIBS = @MYPAINT_BRUSHES_LIBS@ +NATIVE_GLIB_CFLAGS = @NATIVE_GLIB_CFLAGS@ +NATIVE_GLIB_LIBS = @NATIVE_GLIB_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENEXR_CFLAGS = @OPENEXR_CFLAGS@ +OPENEXR_LIBS = @OPENEXR_LIBS@ +OPENEXR_REQUIRED_VERSION = @OPENEXR_REQUIRED_VERSION@ +OPENJPEG_CFLAGS = @OPENJPEG_CFLAGS@ +OPENJPEG_LIBS = @OPENJPEG_LIBS@ +OPENJPEG_REQUIRED_VERSION = @OPENJPEG_REQUIRED_VERSION@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PANGOCAIRO_CFLAGS = @PANGOCAIRO_CFLAGS@ +PANGOCAIRO_LIBS = @PANGOCAIRO_LIBS@ +PANGOCAIRO_REQUIRED_VERSION = @PANGOCAIRO_REQUIRED_VERSION@ +PATHSEP = @PATHSEP@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PERL_REQUIRED_VERSION = @PERL_REQUIRED_VERSION@ +PERL_VERSION = @PERL_VERSION@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PNG_CFLAGS = @PNG_CFLAGS@ +PNG_LIBS = @PNG_LIBS@ +POFILES = @POFILES@ +POPPLER_CFLAGS = @POPPLER_CFLAGS@ +POPPLER_DATA_CFLAGS = @POPPLER_DATA_CFLAGS@ +POPPLER_DATA_LIBS = @POPPLER_DATA_LIBS@ +POPPLER_DATA_REQUIRED_VERSION = @POPPLER_DATA_REQUIRED_VERSION@ +POPPLER_LIBS = @POPPLER_LIBS@ +POPPLER_REQUIRED_VERSION = @POPPLER_REQUIRED_VERSION@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +PYBIN_PATH = @PYBIN_PATH@ +PYCAIRO_CFLAGS = @PYCAIRO_CFLAGS@ +PYCAIRO_LIBS = @PYCAIRO_LIBS@ +PYGIMP_EXTRA_CFLAGS = @PYGIMP_EXTRA_CFLAGS@ +PYGTK_CFLAGS = @PYGTK_CFLAGS@ +PYGTK_CODEGEN = @PYGTK_CODEGEN@ +PYGTK_DEFSDIR = @PYGTK_DEFSDIR@ +PYGTK_LIBS = @PYGTK_LIBS@ +PYLINK_LIBS = @PYLINK_LIBS@ +PYTHON = @PYTHON@ +PYTHON2_REQUIRED_VERSION = @PYTHON2_REQUIRED_VERSION@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_INCLUDES = @PYTHON_INCLUDES@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RSVG_REQUIRED_VERSION = @RSVG_REQUIRED_VERSION@ +RT_LIBS = @RT_LIBS@ +SCREENSHOT_LIBS = @SCREENSHOT_LIBS@ +SED = @SED@ +SENDMAIL = @SENDMAIL@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOCKET_LIBS = @SOCKET_LIBS@ +SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@ +SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@ +SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@ +STRIP = @STRIP@ +SVG_CFLAGS = @SVG_CFLAGS@ +SVG_LIBS = @SVG_LIBS@ +SYMPREFIX = @SYMPREFIX@ +TIFF_LIBS = @TIFF_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WEBKIT_CFLAGS = @WEBKIT_CFLAGS@ +WEBKIT_LIBS = @WEBKIT_LIBS@ +WEBKIT_REQUIRED_VERSION = @WEBKIT_REQUIRED_VERSION@ +WEBPDEMUX_CFLAGS = @WEBPDEMUX_CFLAGS@ +WEBPDEMUX_LIBS = @WEBPDEMUX_LIBS@ +WEBPMUX_CFLAGS = @WEBPMUX_CFLAGS@ +WEBPMUX_LIBS = @WEBPMUX_LIBS@ +WEBP_CFLAGS = @WEBP_CFLAGS@ +WEBP_LIBS = @WEBP_LIBS@ +WEBP_REQUIRED_VERSION = @WEBP_REQUIRED_VERSION@ +WEB_PAGE = @WEB_PAGE@ +WIN32_LARGE_ADDRESS_AWARE = @WIN32_LARGE_ADDRESS_AWARE@ +WINDRES = @WINDRES@ +WMF_CFLAGS = @WMF_CFLAGS@ +WMF_CONFIG = @WMF_CONFIG@ +WMF_LIBS = @WMF_LIBS@ +WMF_REQUIRED_VERSION = @WMF_REQUIRED_VERSION@ +XDG_EMAIL = @XDG_EMAIL@ +XFIXES_CFLAGS = @XFIXES_CFLAGS@ +XFIXES_LIBS = @XFIXES_LIBS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_REQUIRED_VERSION = @XGETTEXT_REQUIRED_VERSION@ +XMC_CFLAGS = @XMC_CFLAGS@ +XMC_LIBS = @XMC_LIBS@ +XMKMF = @XMKMF@ +XMLLINT = @XMLLINT@ +XMU_LIBS = @XMU_LIBS@ +XPM_LIBS = @XPM_LIBS@ +XSLTPROC = @XSLTPROC@ +XVFB_RUN = @XVFB_RUN@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +Z_LIBS = @Z_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gimpdatadir = @gimpdatadir@ +gimpdir = @gimpdir@ +gimplocaledir = @gimplocaledir@ +gimpplugindir = @gimpplugindir@ +gimpsysconfdir = @gimpsysconfdir@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = $(gimpplugindir)/plug-ins/ifs-compose +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +manpage_gimpdir = @manpage_gimpdir@ +mkdir_p = @mkdir_p@ +ms_librarian = @ms_librarian@ +mypaint_brushes_dir = @mypaint_brushes_dir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +@OS_WIN32_TRUE@mwindows = -mwindows +@OS_WIN32_FALSE@libm = -lm +libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la +libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la +libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la +libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la +libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la +@HAVE_WINDRES_TRUE@GIMPPLUGINRC = $(top_builddir)/build/windows/gimp-plug-ins.rc +@HAVE_WINDRES_TRUE@ifs_compose_RC = ifs-compose.rc.o +AM_LDFLAGS = $(mwindows) +ifs_compose_SOURCES = \ + ifs-compose.c \ + ifs-compose.h \ + ifs-compose-utils.c \ + ifs-compose-storage.c + +EXTRA_DIST = README.ifscompose +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + $(GTK_CFLAGS) \ + $(GEGL_CFLAGS) \ + -I$(includedir) + +LDADD = \ + $(libm) \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEGL_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(ifs_compose_RC) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/build/windows/gimprc-plug-ins.rule $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plug-ins/ifs-compose/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu plug-ins/ifs-compose/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; +$(top_srcdir)/build/windows/gimprc-plug-ins.rule $(am__empty): + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libexecPROGRAMS: $(libexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(libexecdir)" && rm -f $$files + +clean-libexecPROGRAMS: + @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +ifs-compose$(EXEEXT): $(ifs_compose_OBJECTS) $(ifs_compose_DEPENDENCIES) $(EXTRA_ifs_compose_DEPENDENCIES) + @rm -f ifs-compose$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(ifs_compose_OBJECTS) $(ifs_compose_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifs-compose-storage.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifs-compose-utils.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifs-compose.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(libexecdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/ifs-compose-storage.Po + -rm -f ./$(DEPDIR)/ifs-compose-utils.Po + -rm -f ./$(DEPDIR)/ifs-compose.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libexecPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/ifs-compose-storage.Po + -rm -f ./$(DEPDIR)/ifs-compose-utils.Po + -rm -f ./$(DEPDIR)/ifs-compose.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libexecPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libexecPROGRAMS clean-libtool \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-libexecPROGRAMS \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-libexecPROGRAMS + +.PRECIOUS: Makefile + + +# `windres` seems a very stupid tool and it breaks with double shlashes +# in parameter paths. Strengthen the rule a little. +@HAVE_WINDRES_TRUE@%.rc.o: +@HAVE_WINDRES_TRUE@ $(WINDRES) --define ORIGINALFILENAME_STR="$*$(EXEEXT)" \ +@HAVE_WINDRES_TRUE@ --define INTERNALNAME_STR="$*" \ +@HAVE_WINDRES_TRUE@ --define TOP_SRCDIR="`echo $(top_srcdir) | sed 's*//*/*'`" \ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_srcdir)/app | sed 's%/\+%/%'`" \ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_builddir)/app | sed 's%/\+%/%'`"\ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_builddir) | sed 's%/\+%/%'`"\ +@HAVE_WINDRES_TRUE@ $(GIMPPLUGINRC) $@ + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/plug-ins/ifs-compose/README.ifscompose b/plug-ins/ifs-compose/README.ifscompose new file mode 100644 index 0000000..cbaa331 --- /dev/null +++ b/plug-ins/ifs-compose/README.ifscompose @@ -0,0 +1,83 @@ +IfsCompose +---------- + +IfsCompose is a plug-in for GIMP that allows +the creation of Iterated Function System fractals by direct +manipulation onscreen of the component transforms. + + +IFS Fractals +------------ + +You may be familiar with IFS's from the screen +hack 'Flame'. They are also the basis of fractal image compression. + +For a brief introduction to IFS's see Foley and van Dam, et +al,. _Computer Graphics, Principles and Practice_, 2nd Ed., +(Addison Wesley, 1990). + +The standard references in the field are Michael Barnsley's books (though +I haven't looked at them yet): + +M. Barnsley, _Fractals Everywhere_, Academic Press Inc., 1988. +M. Barnsley and L. Hurd, _Fractal Image Compression_, Jones and +Bartlett. + +Briefly, you take a point and repeatedly apply one of a set of +transformations to it, choosing randomly between them, and plot the +point at each step. An interesting result (the Collage Theorem) says +that if you can find a set of transformations that break up an image +into smaller copies of itself, then the resulting fractal exactly +reproduces the original image. For example, here is a classic image +of a leaf and the same image with the four component transforms +colored distinctively. + +But the best way to appreciate this may to install this program and +try it out. I've extended the basic concept as found in +Foley and van Dam to include transformations in color space as +well as in real space. + +Installation +------------ +The included Makefile should work with minor modifications on most +systems if you have installed Gimp normally. Put the resulting binary +in ~/.gimp/plug-ins or the system-wide plug-ins directory. + +The included files gtkaspectframe.c/.h implement a modified frame +widget that guarantees that the aspect ratio of the child widget +remains constant when the parent is resized. It's sort of specialized, +but if you think it would be useful for other purposes, let me know +and I'll lobby for its inclusion in the standard gtk. + +Use +--- +The interface is somewhat complex and it may take you a little while +to get the hang of it. (There are 19 parameters for each +transformation in your fractal, after all). The best way to learn is +probably to start by making small changes, and seeing what they +do. Click on the transformations (represented by polygons) in the +design window to manipulate them interactively. + +Button-1: rotate/scale +Button-2: distort +Button-3: move + +If you hold down shift while clicking, you can select multiple polygons +to apply the transformation to. + +Try not to click too near the center of a polygon, as this will +amplify your actions. + +Note that if you render onto an image with an alpha channel, the +background will be transparent (very useful for compositing several +fractals), otherwise the background will be the current background. + +There are tutorials and some example images at: + + http://www.gtk.org/~otaylor/IfsCompose/ifs_tutorial/tutorial.html + http://tigert.gimp.org/gimp/ifs-compose/ + + +Have fun! + +Owen Taylor diff --git a/plug-ins/ifs-compose/ifs-compose-storage.c b/plug-ins/ifs-compose/ifs-compose-storage.c new file mode 100644 index 0000000..24705be --- /dev/null +++ b/plug-ins/ifs-compose/ifs-compose-storage.c @@ -0,0 +1,551 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * IfsCompose is a interface for creating IFS fractals by + * direct manipulation. + * Copyright (C) 1997 Owen Taylor + * + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "config.h" + +#include /* strlen */ + +#include + +#include + +#include "ifs-compose.h" + + +typedef enum { + TOKEN_INVALID = G_TOKEN_LAST, + TOKEN_ITERATIONS, + TOKEN_MAX_MEMORY, + TOKEN_SUBDIVIDE, + TOKEN_RADIUS, + TOKEN_ASPECT_RATIO, + TOKEN_CENTER_X, + TOKEN_CENTER_Y, + TOKEN_ELEMENT, + TOKEN_X, + TOKEN_Y, + TOKEN_THETA, + TOKEN_SCALE, + TOKEN_ASYM, + TOKEN_SHEAR, + TOKEN_FLIP, + TOKEN_RED_COLOR, + TOKEN_GREEN_COLOR, + TOKEN_BLUE_COLOR, + TOKEN_BLACK_COLOR, + TOKEN_TARGET_COLOR, + TOKEN_HUE_SCALE, + TOKEN_VALUE_SCALE, + TOKEN_SIMPLE_COLOR, + TOKEN_PROB +} IfsComposeToken; + +static struct +{ + const gchar *name; + IfsComposeToken token; +} symbols[] = { + { "iterations", TOKEN_ITERATIONS }, + { "max_memory", TOKEN_MAX_MEMORY }, + { "subdivide", TOKEN_SUBDIVIDE }, + { "radius", TOKEN_RADIUS }, + { "aspect_ratio", TOKEN_ASPECT_RATIO }, + { "center_x", TOKEN_CENTER_X }, + { "center_y", TOKEN_CENTER_Y }, + { "element", TOKEN_ELEMENT }, + { "x", TOKEN_X }, + { "y", TOKEN_Y }, + { "theta", TOKEN_THETA }, + { "scale", TOKEN_SCALE }, + { "asym", TOKEN_ASYM }, + { "shear", TOKEN_SHEAR }, + { "flip", TOKEN_FLIP }, + { "red_color", TOKEN_RED_COLOR }, + { "green_color", TOKEN_GREEN_COLOR }, + { "blue_color", TOKEN_BLUE_COLOR }, + { "black_color", TOKEN_BLACK_COLOR }, + { "target_color", TOKEN_TARGET_COLOR }, + { "hue_scale", TOKEN_HUE_SCALE }, + { "value_scale", TOKEN_VALUE_SCALE }, + { "simple_color", TOKEN_SIMPLE_COLOR }, + { "prob", TOKEN_PROB } +}; + +static GTokenType +ifsvals_parse_color (GScanner *scanner, + GimpRGB *result) +{ + GTokenType token; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_LEFT_CURLY) + return G_TOKEN_LEFT_CURLY; + + token = g_scanner_get_next_token (scanner); + if (token == G_TOKEN_FLOAT) + result->r = scanner->value.v_float; + else if (token == G_TOKEN_INT) + result->r = scanner->value.v_int; + else + return G_TOKEN_FLOAT; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_COMMA) + return G_TOKEN_COMMA; + + token = g_scanner_get_next_token (scanner); + if (token == G_TOKEN_FLOAT) + result->g = scanner->value.v_float; + else if (token == G_TOKEN_INT) + result->g = scanner->value.v_int; + else + return G_TOKEN_FLOAT; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_COMMA) + return G_TOKEN_COMMA; + + token = g_scanner_get_next_token (scanner); + if (token == G_TOKEN_FLOAT) + result->b = scanner->value.v_float; + else if (token == G_TOKEN_INT) + result->b = scanner->value.v_int; + else + return G_TOKEN_FLOAT; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_RIGHT_CURLY) + return G_TOKEN_RIGHT_CURLY; + + return G_TOKEN_NONE; +} + +/* Parse a float which (unlike G_TOKEN_FLOAT) can be negative + */ +static GTokenType +parse_genuine_float (GScanner *scanner, + gdouble *result) +{ + gboolean negate = FALSE; + GTokenType token; + + token = g_scanner_get_next_token (scanner); + + if (token == '-') + { + negate = TRUE; + token = g_scanner_get_next_token (scanner); + } + + if (token == G_TOKEN_FLOAT) + { + *result = negate ? -scanner->value.v_float : scanner->value.v_float; + return G_TOKEN_NONE; + } + else if (token == G_TOKEN_INT) + { + *result = negate ? -scanner->value.v_int : scanner->value.v_int; + return G_TOKEN_NONE; + } + else + return G_TOKEN_FLOAT; +} + +static GTokenType +ifsvals_parse_element (GScanner *scanner, + AffElementVals *result) +{ + GTokenType token; + GTokenType expected_token; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_LEFT_CURLY) + return G_TOKEN_LEFT_CURLY; + + token = g_scanner_get_next_token (scanner); + while (token != G_TOKEN_RIGHT_CURLY) + { + switch ((IfsComposeToken) token) + { + case TOKEN_X: + expected_token = parse_genuine_float (scanner, &result->x); + if (expected_token != G_TOKEN_NONE) + return expected_token; + break; + + case TOKEN_Y: + expected_token = parse_genuine_float (scanner, &result->y); + if (expected_token != G_TOKEN_NONE) + return expected_token; + break; + + case TOKEN_THETA: + expected_token = parse_genuine_float (scanner, &result->theta); + if (expected_token != G_TOKEN_NONE) + return expected_token; + break; + + case TOKEN_SCALE: + expected_token = parse_genuine_float (scanner, &result->scale); + if (expected_token != G_TOKEN_NONE) + return expected_token; + break; + + case TOKEN_ASYM: + expected_token = parse_genuine_float (scanner, &result->asym); + if (expected_token != G_TOKEN_NONE) + return expected_token; + break; + + case TOKEN_SHEAR: + expected_token = parse_genuine_float (scanner, &result->shear); + if (expected_token != G_TOKEN_NONE) + return expected_token; + break; + + case TOKEN_FLIP: + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_INT) + return G_TOKEN_INT; + + result->flip = scanner->value.v_int; + break; + + case TOKEN_RED_COLOR: + token = ifsvals_parse_color (scanner, &result->red_color); + if (token != G_TOKEN_NONE) + return token; + break; + + case TOKEN_GREEN_COLOR: + token = ifsvals_parse_color (scanner, &result->green_color); + if (token != G_TOKEN_NONE) + return token; + break; + + case TOKEN_BLUE_COLOR: + token = ifsvals_parse_color (scanner, &result->blue_color); + if (token != G_TOKEN_NONE) + return token; + break; + + case TOKEN_BLACK_COLOR: + token = ifsvals_parse_color (scanner, &result->black_color); + if (token != G_TOKEN_NONE) + return token; + break; + + case TOKEN_TARGET_COLOR: + token = ifsvals_parse_color (scanner, &result->target_color); + if (token != G_TOKEN_NONE) + return token; + break; + + case TOKEN_HUE_SCALE: + expected_token = parse_genuine_float (scanner, &result->hue_scale); + if (expected_token != G_TOKEN_NONE) + return expected_token; + break; + + case TOKEN_VALUE_SCALE: + expected_token = parse_genuine_float (scanner, &result->value_scale); + if (expected_token != G_TOKEN_NONE) + return expected_token; + break; + + case TOKEN_SIMPLE_COLOR: + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_INT) + return G_TOKEN_INT; + + result->simple_color = scanner->value.v_int; + break; + + case TOKEN_PROB: + token = g_scanner_get_next_token (scanner); + if (token == G_TOKEN_FLOAT) + result->prob = scanner->value.v_float; + else if (token == G_TOKEN_INT) + result->prob = scanner->value.v_int; + else + return G_TOKEN_FLOAT; + + break; + + default: + return G_TOKEN_SYMBOL; + } + + token = g_scanner_get_next_token (scanner); + } + + return G_TOKEN_NONE; +} + +/************************************************************* + * ifsvals_parse: + * Read in ifsvalues from a GScanner + * arguments: + * scanner: + * vals: + * elements: + * + * results: + * If parsing succeeded, TRUE; otherwise FALSE, in which + * case vals and elements are unchanged + *************************************************************/ + +static gboolean +ifsvals_parse (GScanner *scanner, + IfsComposeVals *vals, + AffElement ***elements) +{ + GTokenType token, expected_token; + AffElement *el; + IfsComposeVals new_vals; + GimpRGB color; + + GList *el_list = NULL; + GList *tmp_list; + gint i; + + new_vals = *vals; + new_vals.num_elements = 0; + i = 0; + + expected_token = G_TOKEN_NONE; + while (expected_token == G_TOKEN_NONE) + { + token = g_scanner_get_next_token (scanner); + + if (g_scanner_eof (scanner)) + break; + + switch ((IfsComposeToken) token) + { + case TOKEN_ITERATIONS: + token = g_scanner_get_next_token (scanner); + if (token == G_TOKEN_INT) + new_vals.iterations = scanner->value.v_int; + else + expected_token = G_TOKEN_INT; + break; + + case TOKEN_MAX_MEMORY: + token = g_scanner_get_next_token (scanner); + if (token == G_TOKEN_INT) + new_vals.max_memory = scanner->value.v_int; + else + expected_token = G_TOKEN_INT; + break; + + case TOKEN_SUBDIVIDE: + token = g_scanner_get_next_token (scanner); + if (token == G_TOKEN_INT) + new_vals.subdivide = scanner->value.v_int; + else + expected_token = G_TOKEN_INT; + break; + + case TOKEN_RADIUS: + expected_token = parse_genuine_float (scanner, &new_vals.radius); + break; + + case TOKEN_ASPECT_RATIO: + expected_token = parse_genuine_float (scanner, &new_vals.aspect_ratio); + break; + + case TOKEN_CENTER_X: + expected_token = parse_genuine_float (scanner, &new_vals.center_x); + break; + + case TOKEN_CENTER_Y: + expected_token = parse_genuine_float (scanner, &new_vals.center_y); + break; + + case TOKEN_ELEMENT: + el = aff_element_new (0.0,0.0, &color, ++i); + expected_token = ifsvals_parse_element (scanner, &el->v); + + if (expected_token == G_TOKEN_NONE) + { + el_list = g_list_prepend (el_list, el); + new_vals.num_elements++; + } + else + aff_element_free (el); + + break; + + default: + expected_token = G_TOKEN_SYMBOL; + } + } + + if (expected_token != G_TOKEN_NONE) + { + g_scanner_unexp_token (scanner, + expected_token, + NULL, + NULL, + NULL, + "using default values...", + TRUE); + g_list_free_full (el_list, (GDestroyNotify) g_free); + return FALSE; + } + + *vals = new_vals; + + el_list = g_list_reverse (el_list); + *elements = g_new (AffElement *, new_vals.num_elements); + + tmp_list = el_list; + for (i=0; idata; + tmp_list = tmp_list->next; + } + + g_list_free (el_list); + + return TRUE; +} + +gboolean +ifsvals_parse_string (const gchar *str, + IfsComposeVals *vals, + AffElement ***elements) +{ + GScanner *scanner = g_scanner_new (NULL); + gboolean result; + gint i; + + scanner->config->symbol_2_token = TRUE; + scanner->config->scan_identifier_1char = TRUE; + scanner->input_name = "IfsCompose Saved Data"; + + for (i = 0; i < G_N_ELEMENTS (symbols); i++) + g_scanner_scope_add_symbol (scanner, 0, + symbols[i].name, + GINT_TO_POINTER (symbols[i].token)); + + g_scanner_input_text (scanner, str, strlen (str)); + + result = ifsvals_parse (scanner, vals, elements); + + g_scanner_destroy (scanner); + + return result; +} + +/************************************************************* + * ifsvals_stringify: + * Stringify a set of vals and elements + * arguments: + * vals: + * elements + * results: + * The stringified result (free with g_free) + *************************************************************/ + +gchar * +ifsvals_stringify (IfsComposeVals *vals, + AffElement **elements) +{ + gint i; + gchar buf[G_ASCII_DTOSTR_BUF_SIZE]; + gchar cbuf[3][G_ASCII_DTOSTR_BUF_SIZE]; + GString *result; + + result = g_string_new (NULL); + + g_string_append_printf (result, "iterations %d\n", vals->iterations); + g_string_append_printf (result, "max_memory %d\n", vals->max_memory); + g_string_append_printf (result, "subdivide %d\n", vals->subdivide); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, vals->radius); + g_string_append_printf (result, "radius %s\n", buf); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, vals->aspect_ratio); + g_string_append_printf (result, "aspect_ratio %s\n", buf); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, vals->center_x); + g_string_append_printf (result, "center_x %s\n", buf); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, vals->center_y); + g_string_append_printf (result, "center_y %s\n", buf); + + for (i=0; inum_elements; i++) + { + g_string_append (result, "element {\n"); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.x); + g_string_append_printf (result, " x %s\n", buf); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.y); + g_string_append_printf (result, " y %s\n", buf); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.theta); + g_string_append_printf (result, " theta %s\n", buf); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.scale); + g_string_append_printf (result, " scale %s\n", buf); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.asym); + g_string_append_printf (result, " asym %s\n", buf); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.shear); + g_string_append_printf (result, " shear %s\n", buf); + g_string_append_printf (result, " flip %d\n", elements[i]->v.flip); + + g_ascii_dtostr (cbuf[0], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.red_color.r); + g_ascii_dtostr (cbuf[1], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.red_color.g); + g_ascii_dtostr (cbuf[2], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.red_color.b); + g_string_append_printf (result, " red_color { %s,%s,%s }\n", + cbuf[0], cbuf[1], cbuf[2]); + + g_ascii_dtostr (cbuf[0], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.green_color.r); + g_ascii_dtostr (cbuf[1], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.green_color.g); + g_ascii_dtostr (cbuf[2], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.green_color.b); + g_string_append_printf (result, " green_color { %s,%s,%s }\n", + cbuf[0], cbuf[1], cbuf[2]); + + g_ascii_dtostr (cbuf[0], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.blue_color.r); + g_ascii_dtostr (cbuf[1], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.blue_color.g); + g_ascii_dtostr (cbuf[2], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.blue_color.b); + g_string_append_printf (result, " blue_color { %s,%s,%s }\n", + cbuf[0], cbuf[1], cbuf[2]); + + g_ascii_dtostr (cbuf[0], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.black_color.r); + g_ascii_dtostr (cbuf[1], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.black_color.g); + g_ascii_dtostr (cbuf[2], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.black_color.b); + g_string_append_printf (result, " black_color { %s,%s,%s }\n", + cbuf[0], cbuf[1], cbuf[2]); + + g_ascii_dtostr (cbuf[0], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.target_color.r); + g_ascii_dtostr (cbuf[1], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.target_color.g); + g_ascii_dtostr (cbuf[2], G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.target_color.b); + g_string_append_printf (result, " target_color { %s,%s,%s }\n", + cbuf[0], cbuf[1], cbuf[2]); + + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.hue_scale); + g_string_append_printf (result, " hue_scale %s\n", buf); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.value_scale); + g_string_append_printf (result, " value_scale %s\n", buf); + g_string_append_printf (result, " simple_color %d\n", + elements[i]->v.simple_color); + g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, elements[i]->v.prob); + g_string_append_printf (result, " prob %s\n", buf); + g_string_append (result, "}\n"); + } + + return g_string_free (result, FALSE); +} diff --git a/plug-ins/ifs-compose/ifs-compose-utils.c b/plug-ins/ifs-compose/ifs-compose-utils.c new file mode 100644 index 0000000..32c05cc --- /dev/null +++ b/plug-ins/ifs-compose/ifs-compose-utils.c @@ -0,0 +1,1092 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * IfsCompose is a interface for creating IFS fractals by + * direct manipulation. + * Copyright (C) 1997 Owen Taylor + * + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "config.h" + +#include +#include + +#include + +#include + +#include "ifs-compose.h" + + +typedef struct +{ + GdkPoint point; + gdouble angle; +} SortPoint; + + +/* local functions */ +static void aff_element_compute_click_boundary (AffElement *elem, + gint num_elements, + gdouble *points_x, + gdouble *points_y); +static guchar * create_brush (IfsComposeVals *ifsvals, + gint *brush_size, + gdouble *brush_offset); + + +void +aff2_translate (Aff2 *naff, + gdouble x, + gdouble y) +{ + naff->a11 = 1.0; + naff->a12 = 0; + naff->a21 = 0; + naff->a22 = 1.0; + naff->b1 = x; + naff->b2 = y; +} + +void +aff2_rotate (Aff2 *naff, + gdouble theta) +{ + naff->a11 = cos(theta); + naff->a12 = sin(theta); + naff->a21 = -naff->a12; + naff->a22 = naff->a11; + naff->b1 = 0; + naff->b2 = 0; +} + +void +aff2_scale (Aff2 *naff, + gdouble s, + gboolean flip) +{ + if (flip) + naff->a11 = -s; + else + naff->a11 = s; + + naff->a12 = 0; + naff->a21 = 0; + naff->a22 = s; + naff->b1 = 0; + naff->b2 = 0; +} + +/* Create a unitary transform with given x-y asymmetry and shear */ +void +aff2_distort (Aff2 *naff, + gdouble asym, + gdouble shear) +{ + naff->a11 = asym; + naff->a22 = 1/asym; + naff->a12 = shear; + naff->a21 = 0; + naff->b1 = 0; + naff->b2 = 0; +} + +/* Find a pure stretch in some direction that brings xo,yo to xn,yn */ +void +aff2_compute_stretch (Aff2 *naff, + gdouble xo, + gdouble yo, + gdouble xn, + gdouble yn) +{ + gdouble denom = xo*xn + yo*yn; + + if (denom == 0.0) /* singular */ + { + naff->a11 = 1.0; + naff->a12 = 0.0; + naff->a21 = 0.0; + naff->a22 = 1.0; + } + else + { + naff->a11 = (SQR(xn) + SQR(yo)) / denom; + naff->a22 = (SQR(xo) + SQR(yn)) / denom; + naff->a12 = naff->a21 = (xn * yn - xo * yo) / denom; + } + + naff->b1 = 0.0; + naff->b2 = 0.0; +} + +void +aff2_compose (Aff2 *naff, + Aff2 *aff1, + Aff2 *aff2) +{ + naff->a11 = aff1->a11 * aff2->a11 + aff1->a12 * aff2->a21; + naff->a12 = aff1->a11 * aff2->a12 + aff1->a12 * aff2->a22; + naff->b1 = aff1->a11 * aff2->b1 + aff1->a12 * aff2->b2 + aff1->b1; + naff->a21 = aff1->a21 * aff2->a11 + aff1->a22 * aff2->a21; + naff->a22 = aff1->a21 * aff2->a12 + aff1->a22 * aff2->a22; + naff->b2 = aff1->a21 * aff2->b1 + aff1->a22 * aff2->b2 + aff1->b2; +} + +/* Returns the identity matrix if the original matrix was singular */ +void +aff2_invert (Aff2 *naff, + Aff2 *aff) +{ + gdouble det = aff->a11 * aff->a22 - aff->a12 * aff->a21; + + if (det==0) + { + aff2_scale (naff, 1.0, 0); + } + else + { + naff->a11 = aff->a22 / det; + naff->a22 = aff->a11 / det; + naff->a21 = - aff->a21 / det; + naff->a12 = - aff->a12 / det; + naff->b1 = - naff->a11 * aff->b1 - naff->a12 * aff->b2; + naff->b2 = - naff->a21 * aff->b1 - naff->a22 * aff->b2; + } +} + +void +aff2_apply (Aff2 *aff, + gdouble x, + gdouble y, + gdouble *xf, + gdouble *yf) +{ + gdouble xt = aff->a11 * x + aff->a12 * y + aff->b1; + gdouble yt = aff->a21 * x + aff->a22 * y + aff->b2; + + *xf = xt; + *yf = yt; +} + +/* Find the fixed point of an affine transformation + (Will return garbage for pure translations) */ + +void +aff2_fixed_point (Aff2 *aff, + gdouble *xf, + gdouble *yf) +{ + Aff2 t1,t2; + + t1.a11 = 1 - aff->a11; + t1.a22 = 1 - aff->a22; + t1.a12 = -aff->a12; + t1.a21 = -aff->a21; + t1.b1 = 0; + t1.b2 = 0; + + aff2_invert (&t2, &t1); + aff2_apply (&t2, aff->b1, aff->b2, xf, yf); +} + +void +aff3_apply (Aff3 *t, + gdouble x, + gdouble y, + gdouble z, + gdouble *xf, + gdouble *yf, + gdouble *zf) +{ + gdouble xt = (t->vals[0][0] * x + + t->vals[0][1] * y + + t->vals[0][2] * z + t->vals[0][3]); + gdouble yt = (t->vals[1][0] * x + + t->vals[1][1] * y + + t->vals[1][2] * z + t->vals[1][3]); + gdouble zt = (t->vals[2][0] * x + + t->vals[2][1] * y + + t->vals[2][2] * z + t->vals[2][3]); + + *xf = xt; + *yf = yt; + *zf = zt; +} + +static int +ipolygon_sort_func (const void *a, + const void *b) +{ + if (((SortPoint *)a)->angle < ((SortPoint *)b)->angle) + return -1; + else if (((SortPoint *)a)->angle > ((SortPoint *)b)->angle) + return 1; + else + return 0; +} + +/* Return a newly-allocated polygon which is the convex hull + of the given polygon. + + Uses the Graham scan. see + http://www.cs.curtin.edu.au/units/cg201/notes/node77.html + + for a description +*/ + +IPolygon * +ipolygon_convex_hull (IPolygon *poly) +{ + gint num_new = poly->npoints; + GdkPoint *new_points = g_new (GdkPoint, num_new); + SortPoint *sort_points = g_new (SortPoint, num_new); + IPolygon *new_poly = g_new (IPolygon, 1); + + gint i, j; + gint x1, x2, y1, y2; + gint lowest; + GdkPoint lowest_pt; + + new_poly->points = new_points; + if (num_new <= 3) + { + memcpy (new_points, poly->points, num_new * sizeof (GdkPoint)); + new_poly->npoints = num_new; + g_free (sort_points); + return new_poly; + } + + /* scan for the lowest point */ + lowest_pt = poly->points[0]; + lowest = 0; + + for (i = 1; i < num_new; i++) + if (poly->points[i].y < lowest_pt.y) + { + lowest_pt = poly->points[i]; + lowest = i; + } + + /* sort by angle from lowest point */ + + for (i = 0, j = 0; i < num_new; i++, j++) + { + if (i==lowest) + j--; + else + { + gdouble dy = poly->points[i].y - lowest_pt.y; + gdouble dx = poly->points[i].x - lowest_pt.x; + + if (dy == 0 && dx == 0) + { + j--; + num_new--; + continue; + } + sort_points[j].point = poly->points[i]; + sort_points[j].angle = atan2 (dy, dx); + } + } + + qsort (sort_points, num_new - 1, sizeof (SortPoint), ipolygon_sort_func); + + /* now ensure that all turns as we trace the perimeter are + counter-clockwise */ + + new_points[0] = lowest_pt; + new_points[1] = sort_points[0].point; + x1 = new_points[1].x - new_points[0].x; + y1 = new_points[1].y - new_points[0].y; + + for (i = 1, j = 2; j < num_new; i++, j++) + { + x2 = sort_points[i].point.x - new_points[j - 1].x; + y2 = sort_points[i].point.y - new_points[j - 1].y; + + if (x2 == 0 && y2 == 0) + { + num_new--; + j--; + continue; + } + + while (x1 * y2 - x2 * y1 < 0) /* clockwise rotation */ + { + num_new--; + j--; + x1 = new_points[j - 1].x - new_points[j - 2].x; + y1 = new_points[j - 1].y - new_points[j - 2].y; + x2 = sort_points[i].point.x - new_points[j - 1].x; + y2 = sort_points[i].point.y - new_points[j - 1].y; + } + new_points[j] = sort_points[i].point; + x1 = x2; + y1 = y2; + } + + g_free (sort_points); + + new_poly->npoints = num_new; + + return new_poly; +} + +/* Determines whether a specified point is in the given polygon. + Based on + + inpoly.c by Bob Stein and Craig Yap. + + (Linux Journal, Issue 35 (March 1997), p 68) + */ + +gint +ipolygon_contains (IPolygon *poly, + gint xt, + gint yt) +{ + gint xnew, ynew; + gint xold, yold; + gint x1,y1; + gint x2,y2; + + gint i; + gint inside = 0; + + if (poly->npoints < 3) + return 0; + + xold=poly->points[poly->npoints - 1].x; + yold=poly->points[poly->npoints - 1].y; + for (i = 0; i < poly->npoints; i++) + { + xnew = poly->points[i].x; + ynew = poly->points[i].y; + if (xnew > xold) + { + x1 = xold; + x2 = xnew; + y1 = yold; + y2 = ynew; + } + else + { + x1 = xnew; + x2 = xold; + y1 = ynew; + y2 = yold; + } + if ((xnew < xt) == (xt <= xold) && + (yt - y1)*(x2 - x1) < (y2 - y1)*(xt - x1)) + inside = !inside; + xold = xnew; + yold = ynew; + } + return inside; +} + +void +aff_element_compute_color_trans (AffElement *elem) +{ + int i, j; + + if (elem->v.simple_color) + { + gdouble mag2; + + mag2 = SQR (elem->v.target_color.r); + mag2 += SQR (elem->v.target_color.g); + mag2 += SQR (elem->v.target_color.b); + + /* For mag2 == 0, the transformation blows up in general + but is well defined for hue_scale == value_scale, so + we assume that special case. */ + if (mag2 == 0) + for (i = 0; i < 3; i++) + { + for (j = 0; j < 4; j++) + elem->color_trans.vals[i][j] = 0.0; + + elem->color_trans.vals[i][i] = elem->v.hue_scale; + } + else + { + /* red */ + for (j = 0; j < 3; j++) + { + elem->color_trans.vals[0][j] = elem->v.target_color.r + / mag2 * (elem->v.value_scale - elem->v.hue_scale); + } + + /* green */ + for (j = 0; j < 3; j++) + { + elem->color_trans.vals[1][j] = elem->v.target_color.g + / mag2 * (elem->v.value_scale - elem->v.hue_scale); + } + + /* blue */ + for (j = 0; j < 3; j++) + { + elem->color_trans.vals[2][j] = elem->v.target_color.g + / mag2 * (elem->v.value_scale - elem->v.hue_scale); + } + + elem->color_trans.vals[0][0] += elem->v.hue_scale; + elem->color_trans.vals[1][1] += elem->v.hue_scale; + elem->color_trans.vals[2][2] += elem->v.hue_scale; + + elem->color_trans.vals[0][3] = + (1 - elem->v.value_scale) * elem->v.target_color.r; + elem->color_trans.vals[1][3] = + (1 - elem->v.value_scale) * elem->v.target_color.g; + elem->color_trans.vals[2][3] = + (1 - elem->v.value_scale) * elem->v.target_color.b; + + } + + + aff3_apply (&elem->color_trans, 1.0, 0.0, 0.0, + &elem->v.red_color.r, + &elem->v.red_color.g, + &elem->v.red_color.b); + aff3_apply (&elem->color_trans, 0.0, 1.0, 0.0, + &elem->v.green_color.r, + &elem->v.green_color.g, + &elem->v.green_color.b); + aff3_apply (&elem->color_trans, 0.0, 0.0, 1.0, + &elem->v.blue_color.r, + &elem->v.blue_color.g, + &elem->v.blue_color.b); + aff3_apply (&elem->color_trans, 0.0, 0.0, 0.0, + &elem->v.black_color.r, + &elem->v.black_color.g, + &elem->v.black_color.b); + } + else + { + elem->color_trans.vals[0][0] = + elem->v.red_color.r - elem->v.black_color.r; + elem->color_trans.vals[1][0] = + elem->v.red_color.g - elem->v.black_color.g; + elem->color_trans.vals[2][0] = + elem->v.red_color.b - elem->v.black_color.b; + + elem->color_trans.vals[0][1] = + elem->v.green_color.r - elem->v.black_color.r; + elem->color_trans.vals[1][1] = + elem->v.green_color.g - elem->v.black_color.g; + elem->color_trans.vals[2][1] = + elem->v.green_color.b - elem->v.black_color.b; + + elem->color_trans.vals[0][2] = + elem->v.blue_color.r - elem->v.black_color.r; + elem->color_trans.vals[1][2] = + elem->v.blue_color.g - elem->v.black_color.g; + elem->color_trans.vals[2][2] = + elem->v.blue_color.b - elem->v.black_color.b; + + elem->color_trans.vals[0][3] = elem->v.black_color.r; + elem->color_trans.vals[1][3] = elem->v.black_color.g; + elem->color_trans.vals[2][3] = elem->v.black_color.b; + } +} + +void +aff_element_compute_trans (AffElement *elem, + gdouble width, + gdouble height, + gdouble center_x, + gdouble center_y) +{ + Aff2 t1, t2, t3; + + /* create the rotation, scaling and shearing part of the transform */ + aff2_distort (&t1, elem->v.asym, elem->v.shear); + aff2_scale (&t2, elem->v.scale, elem->v.flip); + aff2_compose (&t3, &t2, &t1); + aff2_rotate (&t2, elem->v.theta); + aff2_compose (&t1, &t2, &t3); + + /* now create the translational part */ + aff2_translate (&t2, -center_x*width, -center_y*width); + aff2_compose (&t3, &t1, &t2); + aff2_translate (&t2, elem->v.x*width, elem->v.y*width); + aff2_compose (&elem->trans, &t2, &t3); +} + +void +aff_element_decompose_trans (AffElement *elem, + Aff2 *aff, + gdouble width, + gdouble height, + gdouble center_x, + gdouble center_y) +{ + Aff2 t1, t2; + gdouble det, scale, sign; + + /* pull of the translational parts */ + aff2_translate (&t1,center_x * width, center_y * width); + aff2_compose (&t2, aff, &t1); + + elem->v.x = t2.b1 / width; + elem->v.y = t2.b2 / width; + + det = t2.a11 * t2.a22 - t2.a12 * t2.a21; + + if (det == 0.0) + { + elem->v.scale = 0.0; + elem->v.theta = 0.0; + elem->v.asym = 1.0; + elem->v.shear = 0.0; + elem->v.flip = 0; + } + else + { + if (det >= 0) + { + scale = elem->v.scale = sqrt (det); + sign = 1; + elem->v.flip = 0; + } + else + { + scale = elem->v.scale = sqrt (-det); + sign = -1; + elem->v.flip = 1; + } + + elem->v.theta = atan2 (-t2.a21, t2.a11); + + if (cos (elem->v.theta) == 0.0) + { + elem->v.asym = - t2.a21 / scale / sin (elem->v.theta); + elem->v.shear = - sign * t2.a22 / scale / sin (elem->v.theta); + } + else + { + elem->v.asym = sign * t2.a11 / scale / cos (elem->v.theta); + elem->v.shear = sign * + (t2.a12/scale - sin (elem->v.theta)/elem->v.asym) + / cos (elem->v.theta); + } + } +} + +static void +aff_element_compute_click_boundary (AffElement *elem, + int num_elements, + gdouble *points_x, + gdouble *points_y) +{ + gint i; + gdouble xtot = 0; + gdouble ytot = 0; + gdouble xc, yc; + gdouble theta; + gdouble sth, cth; /* sin(theta), cos(theta) */ + gdouble axis1, axis2; + gdouble axis1max, axis2max, axis1min, axis2min; + + /* compute the center of mass of the points */ + for (i = 0; i < num_elements; i++) + { + xtot += points_x[i]; + ytot += points_y[i]; + } + xc = xtot / num_elements; + yc = ytot / num_elements; + + /* compute the sum of the (x+iy)^2, and take half the the resulting + angle (xtot+iytot = A*exp(2i*theta)), to get an average direction */ + + xtot = 0; + ytot = 0; + for (i = 0; i < num_elements; i++) + { + xtot += SQR (points_x[i] - xc) - SQR (points_y[i] - yc); + ytot += 2 * (points_x[i] - xc) * (points_y[i] - yc); + } + theta = 0.5 * atan2 (ytot, xtot); + sth = sin (theta); + cth = cos (theta); + + /* compute the minimum rectangle at angle theta that bounds the points, + 1/2 side lengths left in axis1, axis2, center in xc, yc */ + + axis1max = axis1min = 0.0; + axis2max = axis2min = 0.0; + for (i = 0; i < num_elements; i++) + { + gdouble proj1 = (points_x[i] - xc) * cth + (points_y[i] - yc) * sth; + gdouble proj2 = -(points_x[i] - xc) * sth + (points_y[i] - yc) * cth; + if (proj1 < axis1min) + axis1min = proj1; + if (proj1 > axis1max) + axis1max = proj1; + if (proj2 < axis2min) + axis2min = proj2; + if (proj2 > axis2max) + axis2max = proj2; + } + axis1 = 0.5 * (axis1max - axis1min); + axis2 = 0.5 * (axis2max - axis2min); + xc += 0.5 * ((axis1max + axis1min) * cth - (axis2max + axis2min) * sth); + yc += 0.5 * ((axis1max + axis1min) * sth + (axis2max + axis2min) * cth); + + /* if the the rectangle is less than 10 pixels in any dimension, + make it click_boundary, otherwise set click_boundary = draw_boundary */ + + if (axis1 < 8.0 || axis2 < 8.0) + { + GdkPoint *points = g_new (GdkPoint, 4); + + elem->click_boundary = g_new (IPolygon, 1); + elem->click_boundary->points = points; + elem->click_boundary->npoints = 4; + + if (axis1 < 8.0) axis1 = 8.0; + if (axis2 < 8.0) axis2 = 8.0; + + points[0].x = xc + axis1 * cth - axis2 * sth; + points[0].y = yc + axis1 * sth + axis2 * cth; + points[1].x = xc - axis1 * cth - axis2 * sth; + points[1].y = yc - axis1 * sth + axis2 * cth; + points[2].x = xc - axis1 * cth + axis2 * sth; + points[2].y = yc - axis1 * sth - axis2 * cth; + points[3].x = xc + axis1 * cth + axis2 * sth; + points[3].y = yc + axis1 * sth - axis2 * cth; + } + else + elem->click_boundary = elem->draw_boundary; +} + +void +aff_element_compute_boundary (AffElement *elem, + gint width, + gint height, + AffElement **elements, + gint num_elements) +{ + gint i; + IPolygon tmp_poly; + gdouble *points_x; + gdouble *points_y; + + if (elem->click_boundary && elem->click_boundary != elem->draw_boundary) + g_free (elem->click_boundary); + if (elem->draw_boundary) + g_free (elem->draw_boundary); + + tmp_poly.npoints = num_elements; + tmp_poly.points = g_new (GdkPoint, num_elements); + points_x = g_new (gdouble, num_elements); + points_y = g_new (gdouble, num_elements); + + for (i = 0; i < num_elements; i++) + { + aff2_apply (&elem->trans, + elements[i]->v.x * width, elements[i]->v.y * width, + &points_x[i],&points_y[i]); + tmp_poly.points[i].x = (gint)points_x[i]; + tmp_poly.points[i].y = (gint)points_y[i]; + } + + elem->draw_boundary = ipolygon_convex_hull (&tmp_poly); + aff_element_compute_click_boundary (elem, num_elements, points_x, points_y); + + g_free (tmp_poly.points); +} + +void +aff_element_draw (AffElement *elem, + gboolean selected, + gint width, + gint height, + cairo_t *cr, + GdkColor *color, + PangoLayout *layout) +{ + PangoRectangle rect; + gint i; + + pango_layout_set_text (layout, elem->name, -1); + pango_layout_get_pixel_extents (layout, NULL, &rect); + + gdk_cairo_set_source_color (cr, color); + + cairo_move_to (cr, + elem->v.x * width - rect.width / 2, + elem->v.y * width + rect.height / 2); + pango_cairo_show_layout (cr, layout); + cairo_fill (cr); + + cairo_set_line_width (cr, 1.0); + + if (elem->click_boundary != elem->draw_boundary) + { + cairo_move_to (cr, + elem->click_boundary->points[0].x, + elem->click_boundary->points[0].y); + + for (i = 1; i < elem->click_boundary->npoints; i++) + cairo_line_to (cr, + elem->click_boundary->points[i].x, + elem->click_boundary->points[i].y); + + cairo_close_path (cr); + + cairo_stroke (cr); + } + + if (selected) + cairo_set_line_width (cr, 3.0); + + cairo_move_to (cr, + elem->draw_boundary->points[0].x, + elem->draw_boundary->points[0].y); + + for (i = 1; i < elem->draw_boundary->npoints; i++) + cairo_line_to (cr, + elem->draw_boundary->points[i].x, + elem->draw_boundary->points[i].y); + + cairo_close_path (cr); + + cairo_stroke (cr); +} + +AffElement * +aff_element_new (gdouble x, + gdouble y, + GimpRGB *color, + gint count) +{ + AffElement *elem = g_new (AffElement, 1); + gchar buffer[16]; + + elem->v.x = x; + elem->v.y = y; + elem->v.theta = 0.0; + elem->v.scale = 0.5; + elem->v.asym = 1.0; + elem->v.shear = 0.0; + elem->v.flip = 0; + + elem->v.red_color = *color; + elem->v.blue_color = *color; + elem->v.green_color = *color; + elem->v.black_color = *color; + + elem->v.target_color = *color; + elem->v.hue_scale = 0.5; + elem->v.value_scale = 0.5; + + elem->v.simple_color = TRUE; + + elem->draw_boundary = NULL; + elem->click_boundary = NULL; + + aff_element_compute_color_trans (elem); + + elem->v.prob = 1.0; + + sprintf (buffer,"%d", count); + elem->name = g_strdup (buffer); + + return elem; +} + +void +aff_element_free (AffElement *elem) +{ + if (elem->click_boundary != elem->draw_boundary) + g_free (elem->click_boundary); + + g_free (elem->draw_boundary); + g_free (elem); +} + +#ifdef DEBUG_BRUSH +static brush_chars[] = {' ',':','*','@'}; +#endif + +static guchar * +create_brush (IfsComposeVals *ifsvals, + gint *brush_size, + gdouble *brush_offset) +{ + gint i, j; + gint ii, jj; + guchar *brush; +#ifdef DEBUG_BRUSH + gdouble totpix = 0.0; +#endif + + gdouble radius = ifsvals->radius * ifsvals->subdivide; + + *brush_size = ceil (2 * radius); + *brush_offset = 0.5 * (*brush_size - 1); + + brush = g_new (guchar, SQR (*brush_size)); + + for (i = 0; i < *brush_size; i++) + { + for (j = 0; j < *brush_size; j++) + { + gdouble pixel = 0.0; + gdouble d = sqrt (SQR (i - *brush_offset) + + SQR (j - *brush_offset)); + + if (d - 0.5 * G_SQRT2 > radius) + pixel = 0.0; + else if (d + 0.5 * G_SQRT2 < radius) + pixel = 1.0; + else + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + { + d = sqrt (SQR (i - *brush_offset + ii * 0.1 - 0.45) + + SQR (j - *brush_offset + jj * 0.1 - 0.45)); + pixel += (d < radius) / 100.0; + } + + brush[i * *brush_size + j] = 255.999 * pixel; + +#ifdef DEBUG_BRUSH + putchar(brush_chars[(gint)(pixel * 3.999)]); + totpix += pixel; +#endif /* DEBUG_BRUSH */ + } +#ifdef DEBUG_BRUSH + putchar('\n'); +#endif /* DEBUG_BRUSH */ + } +#ifdef DEBUG_BRUSH + printf ("Brush total / area = %f\n", totpix / SQR (ifsvals->subdivide)); +#endif /* DEBUG_BRUSH */ + return brush; +} + +void +ifs_render (AffElement **elements, + gint num_elements, + gint width, + gint height, + gint nsteps, + IfsComposeVals *vals, + gint band_y, + gint band_height, + guchar *data, + guchar *mask, + guchar *nhits, + gboolean preview) +{ + gint i, k, n; + gdouble x, y; + gdouble r, g, b; + gint ri, gi, bi; + guint32 p0, psum; + gdouble pt; + guchar *ptr; + guint32 *prob; + gdouble *fprob; + gint subdivide; + guchar *brush = NULL; + gint brush_size = 1; + gdouble brush_offset = 0.0; + + if (preview) + subdivide = 1; + else + subdivide = vals->subdivide; + + /* compute the probabilities and transforms */ + fprob = g_new (gdouble, num_elements); + prob = g_new (guint32, num_elements); + pt = 0.0; + + for (i = 0; i < num_elements; i++) + { + aff_element_compute_trans(elements[i], + width * subdivide, + height * subdivide, + vals->center_x, + vals->center_y); + fprob[i] = fabs( + elements[i]->trans.a11 * elements[i]->trans.a22 + - elements[i]->trans.a12 * elements[i]->trans.a21); + + /* As a heuristic, if the determinant is really small, it's + probably a line element, so increase the probability so + it gets rendered */ + + /* FIXME: figure out what 0.01 really should be */ + if (fprob[i] < 0.01) + fprob[i] = 0.01; + + fprob[i] *= elements[i]->v.prob; + + pt += fprob[i]; + } + + psum = 0; + for (i = 0; i < num_elements; i++) + { + psum += (guint32) -1 * (fprob[i] / pt); + prob[i] = psum; + } + + prob[i - 1] = (guint32) -1; /* make sure we don't get bitten by roundoff */ + + /* create the brush */ + if (!preview) + brush = create_brush (vals, &brush_size, &brush_offset); + + x = y = 0; + r = g = b = 0; + + /* n is used to limit the number of progress updates */ + n = nsteps / 32; + + /* now run the iteration */ + for (i = 0; i < nsteps; i++) + { + if (!preview && ((i % n) == 0)) + gimp_progress_update ((gdouble) i / (gdouble) nsteps); + + p0 = g_random_int (); + k = 0; + + while (p0 > prob[k]) + k++; + + aff2_apply (&elements[k]->trans, x, y, &x, &y); + aff3_apply (&elements[k]->color_trans, r, g, b, &r, &g, &b); + + if (i < 50) + continue; + + ri = (gint) (255.0 * r + 0.5); + gi = (gint) (255.0 * g + 0.5); + bi = (gint) (255.0 * b + 0.5); + + if ((ri < 0) || (ri > 255) || + (gi < 0) || (gi > 255) || + (bi < 0) || (bi > 255)) + continue; + + if (preview) + { + if ((x < width) && (y < (band_y + band_height)) && + (x >= 0) && (y >= band_y)) + { + ptr = data + 3 * (((gint) (y - band_y)) * width + (gint) x); + + *ptr++ = ri; + *ptr++ = gi; + *ptr = bi; + } + } + else + { + if ((x < width * subdivide) && (y < height * subdivide) && + (x >= 0) && (y >= 0)) + { + gint ii; + gint jj; + gint jj0 = floor (y - brush_offset - band_y * subdivide); + gint ii0 = floor (x - brush_offset); + gint jjmin = 0; + gint iimin = 0; + gint jjmax; + gint iimax; + + if (ii0 < 0) + iimin = - ii0; + else + iimin = 0; + + if (jj0 < 0) + jjmin = - jj0; + else + jjmin = 0; + + if (jj0 + brush_size >= subdivide * band_height) + jjmax = subdivide * band_height - jj0; + else + jjmax = brush_size; + + if (ii0 + brush_size >= subdivide * width) + iimax = subdivide * width - ii0; + else + iimax = brush_size; + + for (jj = jjmin; jj < jjmax; jj++) + for (ii = iimin; ii < iimax; ii++) + { + guint m_old; + guint m_new; + guint m_pix; + guint n_hits; + guint old_scale; + guint pix_scale; + gint index = (jj0 + jj) * width * subdivide + ii0 + ii; + + n_hits = nhits[index]; + if (n_hits == 255) + continue; + + m_pix = brush[jj * brush_size + ii]; + if (!m_pix) + continue; + + nhits[index] = ++n_hits; + m_old = mask[index]; + m_new = m_old + m_pix - m_old * m_pix / 255; + mask[index] = m_new; + + /* relative probability that old colored pixel is on top */ + old_scale = m_old * (255 * n_hits - m_pix); + + /* relative probability that new colored pixel is on top */ + pix_scale = m_pix * ((255 - m_old) * n_hits + m_old); + + ptr = data + 3 * index; + + *ptr = ((old_scale * (*ptr) + pix_scale * ri) / + (old_scale + pix_scale)); + ptr++; + + *ptr = ((old_scale * (*ptr) + pix_scale * gi) / + (old_scale + pix_scale)); + ptr++; + + *ptr = ((old_scale * (*ptr) + pix_scale * bi) / + (old_scale + pix_scale)); + } + } + } + } /* main iteration */ + + if (!preview ) + gimp_progress_update (1.0); + + g_free (brush); + g_free (prob); + g_free (fprob); +} diff --git a/plug-ins/ifs-compose/ifs-compose.c b/plug-ins/ifs-compose/ifs-compose.c new file mode 100644 index 0000000..27cad9c --- /dev/null +++ b/plug-ins/ifs-compose/ifs-compose.c @@ -0,0 +1,2799 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * IfsCompose is a interface for creating IFS fractals by + * direct manipulation. + * Copyright (C) 1997 Owen Taylor + * + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* TODO + * ---- + * + * 1. Run in non-interactive mode (need to figure out useful way for a + * script to give the 19N parameters for an image). Perhaps just + * support saving parameters to a file, script passes file name. + * 2. Figure out if we need multiple phases for supersampled brushes. + */ + +#include "config.h" + +#include +#include + +#include + +#include +#include + +#include "ifs-compose.h" + +#include "libgimp/stdplugins-intl.h" + + +#define RESPONSE_RESET 1 +#define RESPONSE_OPEN 2 +#define RESPONSE_SAVE 3 + +#define DESIGN_AREA_MAX_SIZE 300 + +#define PREVIEW_RENDER_CHUNK 10000 + +#define UNDO_LEVELS 24 + +#define PLUG_IN_PARASITE "ifscompose-parasite" +#define PLUG_IN_PROC "plug-in-ifscompose" +#define PLUG_IN_BINARY "ifs-compose" +#define PLUG_IN_ROLE "gimp-ifs-compose" + +typedef enum +{ + OP_TRANSLATE, + OP_ROTATE, /* or scale */ + OP_STRETCH +} DesignOp; + +typedef enum +{ + VALUE_PAIR_INT, + VALUE_PAIR_DOUBLE +} ValuePairType; + +typedef struct +{ + GtkAdjustment *adjustment; + GtkWidget *scale; + GtkWidget *spin; + + ValuePairType type; + guint timeout_id; + + union + { + gdouble *d; + gint *i; + } data; +} ValuePair; + +typedef struct +{ + IfsComposeVals ifsvals; + AffElement **elements; + gboolean *element_selected; + gint current_element; +} UndoItem; + +typedef struct +{ + GimpRGB *color; + GtkWidget *hbox; + GtkWidget *orig_preview; + GtkWidget *button; + gboolean fixed_point; +} ColorMap; + +typedef struct +{ + GtkWidget *dialog; + + ValuePair *iterations_pair; + ValuePair *subdivide_pair; + ValuePair *radius_pair; + ValuePair *memory_pair; +} IfsOptionsDialog; + +typedef struct +{ + GtkWidget *area; + GtkUIManager *ui_manager; + GdkPixmap *pixmap; + + DesignOp op; + gdouble op_x; + gdouble op_y; + gdouble op_xcenter; + gdouble op_ycenter; + gdouble op_center_x; + gdouble op_center_y; + guint button_state; + gint num_selected; +} IfsDesignArea; + +typedef struct +{ + ValuePair *prob_pair; + ValuePair *x_pair; + ValuePair *y_pair; + ValuePair *scale_pair; + ValuePair *angle_pair; + ValuePair *asym_pair; + ValuePair *shear_pair; + GtkWidget *flip_check_button; + + ColorMap *red_cmap; + ColorMap *green_cmap; + ColorMap *blue_cmap; + ColorMap *black_cmap; + ColorMap *target_cmap; + ValuePair *hue_scale_pair; + ValuePair *value_scale_pair; + GtkWidget *simple_button; + GtkWidget *full_button; + GtkWidget *current_frame; + + GtkWidget *preview; + guchar *preview_data; + gint preview_iterations; + + gint drawable_width; + gint drawable_height; + gint preview_width; + gint preview_height; + + AffElement *selected_orig; + gint current_element; + AffElementVals current_vals; + + gboolean in_update; /* true if we're currently in + update_values() - don't do anything + on updates */ +} IfsDialog; + +typedef struct +{ + gboolean run; +} IfsComposeInterface; + +/* Declare local functions. + */ +static void query (void); +static void run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals); + +/* user interface functions */ +static gint ifs_compose_dialog (gint32 drawable_id); +static void ifs_options_dialog (GtkWidget *parent); +static GtkWidget * ifs_compose_trans_page (void); +static GtkWidget * ifs_compose_color_page (void); +static GtkUIManager * design_op_menu_create (GtkWidget *window); +static void design_op_actions_update (void); +static void design_area_create (GtkWidget *window, + gint design_width, + gint design_height); + +/* functions for drawing design window */ +static void update_values (void); +static void set_current_element (gint index); +static void design_area_realize (GtkWidget *widget); +static gint design_area_expose (GtkWidget *widget, + GdkEventExpose *event); +static gint design_area_button_press (GtkWidget *widget, + GdkEventButton *event); +static gint design_area_button_release (GtkWidget *widget, + GdkEventButton *event); +static void design_area_select_all_callback (GtkWidget *widget, + gpointer data); +static gint design_area_configure (GtkWidget *widget, + GdkEventConfigure *event); +static gint design_area_motion (GtkWidget *widget, + GdkEventMotion *event); +static void design_area_redraw (void); + +/* Undo ring functions */ +static void undo_begin (void); +static void undo_update (gint element); +static void undo_exchange (gint el); +static void undo (void); +static void redo (void); + +static void recompute_center (gboolean save_undo); +static void recompute_center_cb (GtkWidget *widget, + gpointer data); + +static void ifs_compose (gint32 drawable_id); + +static ColorMap *color_map_create (const gchar *name, + GimpRGB *orig_color, + GimpRGB *data, + gboolean fixed_point); +static void color_map_color_changed_cb (GtkWidget *widget, + ColorMap *color_map); +static void color_map_update (ColorMap *color_map); + +/* interface functions */ +static void simple_color_toggled (GtkWidget *widget, gpointer data); +static void simple_color_set_sensitive (void); +static void val_changed_update (void); +static ValuePair *value_pair_create (gpointer data, + gdouble lower, + gdouble upper, + gboolean create_scale, + ValuePairType type); +static void value_pair_update (ValuePair *value_pair); +static void value_pair_scale_callback (GtkAdjustment *adjustment, + ValuePair *value_pair); + +static void design_op_update_callback (GtkRadioAction *action, + GtkRadioAction *current, + gpointer data); +static void flip_check_button_callback (GtkWidget *widget, gpointer data); +static gint preview_idle_render (gpointer data); + +static void ifs_compose_preview (void); +static void ifs_compose_set_defaults (void); +static void ifs_compose_new_callback (GtkAction *action, + gpointer data); +static void ifs_compose_delete_callback (GtkAction *action, + gpointer data); +static void ifs_compose_options_callback (GtkAction *action, + gpointer data); +static void ifs_compose_load (GtkWidget *parent); +static void ifs_compose_save (GtkWidget *parent); +static void ifs_compose_response (GtkWidget *widget, + gint response_id, + gpointer data); + +/* + * Some static variables + */ + +static IfsDialog *ifsD = NULL; +static IfsOptionsDialog *ifsOptD = NULL; +static IfsDesignArea *ifsDesign = NULL; + + +static AffElement **elements = NULL; +static gint *element_selected = NULL; +/* labels are generated by printing this int */ +static gint count_for_naming = 0; + +static UndoItem undo_ring[UNDO_LEVELS]; +static gint undo_cur = -1; +static gint undo_num = 0; +static gint undo_start = 0; + + +/* num_elements = 0, signals not inited */ +static IfsComposeVals ifsvals = +{ + 0, /* num_elements */ + 50000, /* iterations */ + 4096, /* max_memory */ + 4, /* subdivide */ + 0.75, /* radius */ + 1.0, /* aspect ratio */ + 0.5, /* center_x */ + 0.5, /* center_y */ +}; + +static IfsComposeInterface ifscint = +{ + FALSE, /* run */ +}; + +const GimpPlugInInfo PLUG_IN_INFO = +{ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ +}; + + +MAIN () + +static void +query (void) +{ + static const GimpParamDef args[] = + { + { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" }, + { GIMP_PDB_IMAGE, "image", "Input image" }, + { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }, + }; + + static const GimpParamDef *return_vals = NULL; + static int nreturn_vals = 0; + + gimp_install_procedure (PLUG_IN_PROC, + N_("Create an Iterated Function System (IFS) fractal"), + "Interactively create an Iterated Function System " + "fractal. Use the window on the upper left to adjust " + "the component transformations of the fractal. The " + "operation that is performed is selected by the " + "buttons underneath the window, or from a menu " + "popped up by the right mouse button. The fractal " + "will be rendered with a transparent background if " + "the current image has an alpha channel.", + "Owen Taylor", + "Owen Taylor", + "1997", + N_("_IFS Fractal..."), + "*", + GIMP_PLUGIN, + G_N_ELEMENTS (args), nreturn_vals, + args, return_vals); + + gimp_plugin_menu_register (PLUG_IN_PROC, + "/Filters/Render/Fractals"); +} + +static void +run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals) +{ + static GimpParam values[1]; + GimpRunMode run_mode; + GimpPDBStatusType status = GIMP_PDB_SUCCESS; + GimpParasite *parasite = NULL; + gint32 image_id; + gint32 drawable_id; + gboolean found_parasite = FALSE; + + INIT_I18N (); + gegl_init (NULL, NULL); + + run_mode = param[0].data.d_int32; + + *nreturn_vals = 1; + *return_vals = values; + + values[0].type = GIMP_PDB_STATUS; + values[0].data.d_status = status; + + image_id = param[1].data.d_image; + drawable_id = param[2].data.d_drawable; + + switch (run_mode) + { + case GIMP_RUN_INTERACTIVE: + /* Possibly retrieve data; first look for a parasite - + * if not found, fall back to global values + */ + parasite = gimp_item_get_parasite (drawable_id, + PLUG_IN_PARASITE); + if (parasite) + { + found_parasite = ifsvals_parse_string (gimp_parasite_data (parasite), + &ifsvals, &elements); + gimp_parasite_free (parasite); + } + + if (!found_parasite) + { + gint length = gimp_get_data_size (PLUG_IN_PROC); + + if (length > 0) + { + gchar *data = g_new (gchar, length); + + gimp_get_data (PLUG_IN_PROC, data); + ifsvals_parse_string (data, &ifsvals, &elements); + g_free (data); + } + } + + /* after ifsvals_parse_string, need to set up naming */ + count_for_naming = ifsvals.num_elements; + + /* First acquire information with a dialog */ + if (! ifs_compose_dialog (drawable_id)) + return; + break; + + case GIMP_RUN_NONINTERACTIVE: + status = GIMP_PDB_CALLING_ERROR; + break; + + case GIMP_RUN_WITH_LAST_VALS: + { + gint length = gimp_get_data_size (PLUG_IN_PROC); + + if (length > 0) + { + gchar *data = g_new (gchar, length); + + gimp_get_data (PLUG_IN_PROC, data); + ifsvals_parse_string (data, &ifsvals, &elements); + g_free (data); + } + else + { + ifs_compose_set_defaults (); + } + } + break; + + default: + break; + } + + /* Render the fractal */ + if (status == GIMP_PDB_SUCCESS) + { + if (run_mode == GIMP_RUN_INTERACTIVE) + { + gchar *str; + GimpParasite *parasite; + + gimp_image_undo_group_start (image_id); + + /* run the effect */ + ifs_compose (drawable_id); + + /* Store data for next invocation - both globally and + * as a parasite on this layer + */ + str = ifsvals_stringify (&ifsvals, elements); + + gimp_set_data (PLUG_IN_PROC, str, strlen (str) + 1); + + parasite = gimp_parasite_new (PLUG_IN_PARASITE, + GIMP_PARASITE_PERSISTENT | + GIMP_PARASITE_UNDOABLE, + strlen (str) + 1, str); + gimp_item_attach_parasite (drawable_id, parasite); + gimp_parasite_free (parasite); + + g_free (str); + + gimp_image_undo_group_end (image_id); + + gimp_displays_flush (); + } + else + { + /* run the effect */ + ifs_compose (drawable_id); + } + } + + values[0].data.d_status = status; +} + +static GtkWidget * +ifs_compose_trans_page (void) +{ + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *label; + + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); + + table = gtk_table_new (3, 6, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 12); + gtk_table_set_col_spacing (GTK_TABLE (table), 2, 6); + gtk_table_set_col_spacing (GTK_TABLE (table), 4, 6); + gtk_table_set_row_spacings (GTK_TABLE (table), 12); + gtk_table_set_row_spacing (GTK_TABLE (table), 2, 6); + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); + + /* X */ + + label = gtk_label_new (_("X:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsD->x_pair = value_pair_create (&ifsD->current_vals.x, 0.0, 1.0, FALSE, + VALUE_PAIR_DOUBLE); + gtk_table_attach (GTK_TABLE (table), ifsD->x_pair->spin, 1, 2, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->x_pair->spin); + + /* Y */ + + label = gtk_label_new (_("Y:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsD->y_pair = value_pair_create (&ifsD->current_vals.y, 0.0, 1.0, FALSE, + VALUE_PAIR_DOUBLE); + gtk_table_attach (GTK_TABLE (table), ifsD->y_pair->spin, 1, 2, 1, 2, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->y_pair->spin); + + /* Scale */ + + label = gtk_label_new (_("Scale:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsD->scale_pair = value_pair_create (&ifsD->current_vals.scale, 0.0, 1.0, + FALSE, VALUE_PAIR_DOUBLE); + gtk_table_attach (GTK_TABLE (table), ifsD->scale_pair->spin, 3, 4, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->scale_pair->spin); + + /* Angle */ + + label = gtk_label_new (_("Angle:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsD->angle_pair = value_pair_create (&ifsD->current_vals.theta, -180, 180, + FALSE, VALUE_PAIR_DOUBLE); + gtk_table_attach (GTK_TABLE (table), ifsD->angle_pair->spin, 3, 4, 1, 2, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->angle_pair->spin); + + /* Asym */ + + label = gtk_label_new (_("Asymmetry:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 4, 5, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsD->asym_pair = value_pair_create (&ifsD->current_vals.asym, 0.10, 10.0, + FALSE, VALUE_PAIR_DOUBLE); + gtk_table_attach (GTK_TABLE (table), ifsD->asym_pair->spin, 5, 6, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->asym_pair->spin); + + /* Shear */ + + label = gtk_label_new (_("Shear:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 4, 5, 1, 2, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsD->shear_pair = value_pair_create (&ifsD->current_vals.shear, -10.0, 10.0, + FALSE, VALUE_PAIR_DOUBLE); + gtk_table_attach (GTK_TABLE (table), ifsD->shear_pair->spin, 5, 6, 1, 2, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->shear_pair->spin); + + /* Flip */ + + ifsD->flip_check_button = gtk_check_button_new_with_label (_("Flip")); + gtk_table_attach (GTK_TABLE (table), ifsD->flip_check_button, 0, 6, 2, 3, + GTK_FILL, GTK_FILL, 0, 0); + g_signal_connect (ifsD->flip_check_button, "toggled", + G_CALLBACK (flip_check_button_callback), + NULL); + gtk_widget_show (ifsD->flip_check_button); + + return vbox; +} + +static GtkWidget * +ifs_compose_color_page (void) +{ + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *label; + GSList *group = NULL; + GimpRGB color; + + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); + + table = gtk_table_new (3, 5, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 12); + gtk_table_set_row_spacings (GTK_TABLE (table), 6); + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); + + /* Simple color control section */ + + ifsD->simple_button = gtk_radio_button_new_with_label (group, _("Simple")); + gtk_table_attach (GTK_TABLE (table), ifsD->simple_button, 0, 1, 0, 2, + GTK_FILL, GTK_FILL, 0, 0); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (ifsD->simple_button)); + g_signal_connect (ifsD->simple_button, "toggled", + G_CALLBACK (simple_color_toggled), + NULL); + gtk_widget_show (ifsD->simple_button); + + ifsD->target_cmap = color_map_create (_("IFS Fractal: Target"), NULL, + &ifsD->current_vals.target_color, TRUE); + gtk_table_attach (GTK_TABLE (table), ifsD->target_cmap->hbox, 1, 2, 0, 2, + GTK_FILL, 0, 0, 0); + gtk_widget_show (ifsD->target_cmap->hbox); + + label = gtk_label_new (_("Scale hue by:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsD->hue_scale_pair = value_pair_create (&ifsD->current_vals.hue_scale, + 0.0, 1.0, TRUE, VALUE_PAIR_DOUBLE); + gtk_table_attach (GTK_TABLE (table), ifsD->hue_scale_pair->scale, 3, 4, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->hue_scale_pair->scale); + gtk_table_attach (GTK_TABLE (table), ifsD->hue_scale_pair->spin, 4, 5, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->hue_scale_pair->spin); + + label = gtk_label_new (_("Scale value by:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsD->value_scale_pair = value_pair_create (&ifsD->current_vals.value_scale, + 0.0, 1.0, TRUE, VALUE_PAIR_DOUBLE); + gtk_table_attach (GTK_TABLE (table), ifsD->value_scale_pair->scale, + 3, 4, 1, 2, GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->value_scale_pair->scale); + gtk_table_attach (GTK_TABLE (table), ifsD->value_scale_pair->spin, + 4, 5, 1, 2, GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->value_scale_pair->spin); + + /* Full color control section */ + + ifsD->full_button = gtk_radio_button_new_with_label (group, _("Full")); + gtk_table_attach (GTK_TABLE (table), ifsD->full_button, 0, 1, 2, 3, + GTK_FILL, GTK_FILL, 0, 0); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (ifsD->full_button)); + gtk_widget_show (ifsD->full_button); + + gimp_rgb_parse_name (&color, "red", -1); + gimp_rgb_set_alpha (&color, 1.0); + ifsD->red_cmap = color_map_create (_("IFS Fractal: Red"), &color, + &ifsD->current_vals.red_color, FALSE); + gtk_table_attach (GTK_TABLE (table), ifsD->red_cmap->hbox, 1, 2, 2, 3, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->red_cmap->hbox); + + gimp_rgb_parse_name (&color, "green", -1); + gimp_rgb_set_alpha (&color, 1.0); + ifsD->green_cmap = color_map_create (_("IFS Fractal: Green"), &color, + &ifsD->current_vals.green_color, FALSE); + gtk_table_attach (GTK_TABLE (table), ifsD->green_cmap->hbox, 2, 3, 2, 3, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->green_cmap->hbox); + + gimp_rgb_parse_name (&color, "blue", -1); + gimp_rgb_set_alpha (&color, 1.0); + ifsD->blue_cmap = color_map_create (_("IFS Fractal: Blue"), &color, + &ifsD->current_vals.blue_color, FALSE); + gtk_table_attach (GTK_TABLE (table), ifsD->blue_cmap->hbox, 3, 4, 2, 3, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->blue_cmap->hbox); + + gimp_rgb_parse_name (&color, "black", -1); + gimp_rgb_set_alpha (&color, 1.0); + ifsD->black_cmap = color_map_create (_("IFS Fractal: Black"), &color, + &ifsD->current_vals.black_color, FALSE); + gtk_table_attach (GTK_TABLE (table), ifsD->black_cmap->hbox, 4, 5, 2, 3, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsD->black_cmap->hbox); + + return vbox; +} + +static gint +ifs_compose_dialog (gint32 drawable_id) +{ + GtkWidget *dialog; + GtkWidget *label; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *main_vbox; + GtkWidget *toolbar; + GtkWidget *aspect_frame; + GtkWidget *notebook; + GtkWidget *page; + gint design_width = gimp_drawable_width (drawable_id); + gint design_height = gimp_drawable_height (drawable_id); + + if (design_width > design_height) + { + if (design_width > DESIGN_AREA_MAX_SIZE) + { + design_height = design_height * DESIGN_AREA_MAX_SIZE / design_width; + design_width = DESIGN_AREA_MAX_SIZE; + } + } + else + { + if (design_height > DESIGN_AREA_MAX_SIZE) + { + design_width = design_width * DESIGN_AREA_MAX_SIZE / design_height; + design_height = DESIGN_AREA_MAX_SIZE; + } + } + + ifsD = g_new0 (IfsDialog, 1); + + ifsD->drawable_width = gimp_drawable_width (drawable_id); + ifsD->drawable_height = gimp_drawable_height (drawable_id); + ifsD->preview_width = design_width; + ifsD->preview_height = design_height; + + gimp_ui_init (PLUG_IN_BINARY, TRUE); + + dialog = gimp_dialog_new (_("IFS Fractal"), PLUG_IN_ROLE, + NULL, 0, + gimp_standard_help_func, PLUG_IN_PROC, + + _("_Open"), RESPONSE_OPEN, + _("_Save"), RESPONSE_SAVE, + _("_Reset"), RESPONSE_RESET, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_OK"), GTK_RESPONSE_OK, + + NULL); + + gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), + RESPONSE_OPEN, + RESPONSE_SAVE, + RESPONSE_RESET, + GTK_RESPONSE_OK, + GTK_RESPONSE_CANCEL, + -1); + + gimp_window_set_transient (GTK_WINDOW (dialog)); + + g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer) &dialog); + + g_signal_connect (dialog, "response", + G_CALLBACK (ifs_compose_response), + NULL); + g_signal_connect (dialog, "destroy", + G_CALLBACK (gtk_main_quit), + NULL); + + design_area_create (dialog, design_width, design_height); + + toolbar = gtk_ui_manager_get_widget (ifsDesign->ui_manager, + "/ifs-compose-toolbar"); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), + toolbar, FALSE, FALSE, 0); + gtk_widget_show (toolbar); + + /* The main vbox */ + main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), + main_vbox, TRUE, TRUE, 0); + + /* The design area */ + + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); + gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); + + aspect_frame = gtk_aspect_frame_new (NULL, + 0.5, 0.5, + (gdouble) design_width / design_height, + 0); + gtk_frame_set_shadow_type (GTK_FRAME (aspect_frame), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (hbox), aspect_frame, TRUE, TRUE, 0); + gtk_widget_show (aspect_frame); + + gtk_container_add (GTK_CONTAINER (aspect_frame), ifsDesign->area); + gtk_widget_show (ifsDesign->area); + + /* The Preview */ + + aspect_frame = gtk_aspect_frame_new (NULL, + 0.5, 0.5, + (gdouble) design_width / design_height, + 0); + gtk_frame_set_shadow_type (GTK_FRAME (aspect_frame), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (hbox), aspect_frame, TRUE, TRUE, 0); + + ifsD->preview = gimp_preview_area_new (); + gtk_widget_set_size_request (ifsD->preview, + ifsD->preview_width, + ifsD->preview_height); + gtk_container_add (GTK_CONTAINER (aspect_frame), ifsD->preview); + gtk_widget_show (ifsD->preview); + + gtk_widget_show (aspect_frame); + + gtk_widget_show (hbox); + + /* The current transformation frame */ + + ifsD->current_frame = gimp_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (main_vbox), ifsD->current_frame, + FALSE, FALSE, 0); + + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); + gtk_container_add (GTK_CONTAINER (ifsD->current_frame), vbox); + + /* The notebook */ + + notebook = gtk_notebook_new (); + gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP); + gtk_box_pack_start (GTK_BOX (vbox), notebook, FALSE, FALSE, 0); + gtk_widget_show (notebook); + + page = ifs_compose_trans_page (); + label = gtk_label_new (_("Spatial Transformation")); + gtk_label_set_xalign (GTK_LABEL (label), 0.5); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); + gtk_widget_show (page); + + page = ifs_compose_color_page (); + label = gtk_label_new (_("Color Transformation")); + gtk_label_set_xalign (GTK_LABEL (label), 0.5); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); + gtk_widget_show (page); + + /* The probability entry */ + + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new (_("Relative probability:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + ifsD->prob_pair = value_pair_create (&ifsD->current_vals.prob, 0.0, 5.0, TRUE, + VALUE_PAIR_DOUBLE); + gtk_box_pack_start (GTK_BOX (hbox), ifsD->prob_pair->scale, TRUE, TRUE, 0); + gtk_widget_show (ifsD->prob_pair->scale); + gtk_box_pack_start (GTK_BOX (hbox), ifsD->prob_pair->spin, FALSE, TRUE, 0); + gtk_widget_show (ifsD->prob_pair->spin); + + gtk_widget_show (hbox); + gtk_widget_show (vbox); + gtk_widget_show (ifsD->current_frame); + + gtk_widget_show (main_vbox); + + if (ifsvals.num_elements == 0) + { + ifs_compose_set_defaults (); + } + else + { + gint i; + gdouble ratio = (gdouble) ifsD->drawable_height / ifsD->drawable_width; + + element_selected = g_new (gint, ifsvals.num_elements); + element_selected[0] = TRUE; + for (i = 1; i < ifsvals.num_elements; i++) + element_selected[i] = FALSE; + + if (ratio != ifsvals.aspect_ratio) + { + /* Adjust things so that what fit onto the old image, fits + onto the new image */ + Aff2 t1, t2, t3; + gdouble x_offset, y_offset; + gdouble center_x, center_y; + gdouble scale; + + if (ratio < ifsvals.aspect_ratio) + { + scale = ratio/ifsvals.aspect_ratio; + x_offset = (1-scale)/2; + y_offset = 0; + } + else + { + scale = 1; + x_offset = 0; + y_offset = (ratio - ifsvals.aspect_ratio)/2; + } + aff2_scale (&t1, scale, 0); + aff2_translate (&t2, x_offset, y_offset); + aff2_compose (&t3, &t2, &t1); + aff2_invert (&t1, &t3); + + aff2_apply (&t3, ifsvals.center_x, ifsvals.center_y, ¢er_x, + ¢er_y); + + for (i = 0; i < ifsvals.num_elements; i++) + { + aff_element_compute_trans (elements[i],1, ifsvals.aspect_ratio, + ifsvals.center_x, ifsvals.center_y); + aff2_compose (&t2, &elements[i]->trans, &t1); + aff2_compose (&elements[i]->trans, &t3, &t2); + aff_element_decompose_trans (elements[i],&elements[i]->trans, + 1, ifsvals.aspect_ratio, + center_x, center_y); + } + ifsvals.center_x = center_x; + ifsvals.center_y = center_y; + + ifsvals.aspect_ratio = ratio; + } + + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_compute_color_trans (elements[i]); + /* boundary and spatial transformations will be computed + when the design_area gets a ConfigureNotify event */ + + set_current_element (0); + + ifsD->selected_orig = g_new (AffElement, ifsvals.num_elements); + } + + gtk_widget_show (dialog); + + ifs_compose_preview (); + + gtk_main (); + + g_object_unref (ifsDesign->ui_manager); + + if (dialog) + gtk_widget_destroy (dialog); + + if (ifsOptD) + gtk_widget_destroy (ifsOptD->dialog); + + gdk_flush (); + + g_free (ifsD); + + return ifscint.run; +} + +static void +design_area_create (GtkWidget *window, + gint design_width, + gint design_height) +{ + ifsDesign = g_new0 (IfsDesignArea, 1); + + ifsDesign->op = OP_TRANSLATE; + + ifsDesign->area = gtk_drawing_area_new (); + gtk_widget_set_size_request (ifsDesign->area, design_width, design_height); + + g_signal_connect (ifsDesign->area, "realize", + G_CALLBACK (design_area_realize), + NULL); + g_signal_connect (ifsDesign->area, "expose-event", + G_CALLBACK (design_area_expose), + NULL); + g_signal_connect (ifsDesign->area, "button-press-event", + G_CALLBACK (design_area_button_press), + NULL); + g_signal_connect (ifsDesign->area, "button-release-event", + G_CALLBACK (design_area_button_release), + NULL); + g_signal_connect (ifsDesign->area, "motion-notify-event", + G_CALLBACK (design_area_motion), + NULL); + g_signal_connect (ifsDesign->area, "configure-event", + G_CALLBACK (design_area_configure), + NULL); + gtk_widget_set_events (ifsDesign->area, + GDK_EXPOSURE_MASK | + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK); + + ifsDesign->ui_manager = design_op_menu_create (window); + design_op_actions_update (); +} + +static GtkUIManager * +design_op_menu_create (GtkWidget *window) +{ + static GtkActionEntry actions[] = + { + { "ifs-compose-menu", NULL, "IFS Fractal Menu" }, + + { "new", GIMP_ICON_DOCUMENT_NEW, + N_("_New"), "N", NULL, + G_CALLBACK (ifs_compose_new_callback) }, + + { "delete", GIMP_ICON_EDIT_DELETE, + N_("_Delete"), "D", NULL, + G_CALLBACK (ifs_compose_delete_callback) }, + + { "undo", GIMP_ICON_EDIT_UNDO, + N_("_Undo"), "Z", NULL, + G_CALLBACK (undo) }, + + { "redo", GIMP_ICON_EDIT_REDO, + N_("_Redo"), "Y", NULL, + G_CALLBACK (redo) }, + + { "select-all", GIMP_ICON_SELECTION_ALL, + N_("Select _All"), "A", NULL, + G_CALLBACK (design_area_select_all_callback) }, + + { "center", GIMP_ICON_CENTER, + N_("Re_center"), "C", N_("Recompute Center"), + G_CALLBACK (recompute_center_cb) }, + + { "options", GIMP_ICON_PREFERENCES_SYSTEM, + N_("Render Options"), NULL, NULL, + G_CALLBACK (ifs_compose_options_callback) } + }; + static GtkRadioActionEntry radio_actions[] = + { + { "move", GIMP_ICON_TOOL_MOVE, + N_("Move"), "M", NULL, OP_TRANSLATE }, + + { "rotate", GIMP_ICON_TOOL_ROTATE, + N_("Rotate"), "R", N_("Rotate / Scale"), OP_ROTATE }, + + { "stretch", GIMP_ICON_TOOL_PERSPECTIVE, + N_("Stretch"), "S", NULL, OP_STRETCH } + }; + + GtkUIManager *ui_manager = gtk_ui_manager_new (); + GtkActionGroup *group = gtk_action_group_new ("Actions"); + + gtk_action_group_set_translation_domain (group, NULL); + + gtk_action_group_add_actions (group, + actions, + G_N_ELEMENTS (actions), + window); + gtk_action_group_add_radio_actions (group, + radio_actions, + G_N_ELEMENTS (radio_actions), + ifsDesign->op, + G_CALLBACK (design_op_update_callback), + window); + + gtk_window_add_accel_group (GTK_WINDOW (window), + gtk_ui_manager_get_accel_group (ui_manager)); + gtk_accel_group_lock (gtk_ui_manager_get_accel_group (ui_manager)); + + gtk_ui_manager_insert_action_group (ui_manager, group, -1); + g_object_unref (group); + + gtk_ui_manager_add_ui_from_string (ui_manager, + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "", + -1, NULL); + + gtk_ui_manager_add_ui_from_string (ui_manager, + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "", + -1, NULL); + + return ui_manager; +} + +static void +design_op_actions_update (void) +{ + GtkAction *act; + + act = gtk_ui_manager_get_action (ifsDesign->ui_manager, + "/ui/dummy-menubar/ifs-compose-menu/undo"); + gtk_action_set_sensitive (act, undo_cur >= 0); + + act = gtk_ui_manager_get_action (ifsDesign->ui_manager, + "/ui/dummy-menubar/ifs-compose-menu/redo"); + gtk_action_set_sensitive (act, undo_cur != undo_num - 1); + + act = gtk_ui_manager_get_action (ifsDesign->ui_manager, + "/ui/dummy-menubar/ifs-compose-menu/delete"); + gtk_action_set_sensitive (act, ifsvals.num_elements > 2); +} + +static void +ifs_options_dialog (GtkWidget *parent) +{ + if (!ifsOptD) + { + GtkWidget *table; + GtkWidget *label; + + ifsOptD = g_new0 (IfsOptionsDialog, 1); + + ifsOptD->dialog = + gimp_dialog_new (_("IFS Fractal Render Options"), PLUG_IN_ROLE, + parent, 0, + gimp_standard_help_func, PLUG_IN_PROC, + + _("_Close"), GTK_RESPONSE_CLOSE, + + NULL); + + g_signal_connect (ifsOptD->dialog, "response", + G_CALLBACK (gtk_widget_hide), + NULL); + + /* Table of options */ + + table = gtk_table_new (4, 3, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 12); + gtk_table_set_row_spacings (GTK_TABLE (table), 6); + gtk_table_set_col_spacings (GTK_TABLE (table), 6); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (ifsOptD->dialog))), + table, FALSE, FALSE, 0); + gtk_widget_show (table); + + label = gtk_label_new (_("Max. memory:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsOptD->memory_pair = value_pair_create (&ifsvals.max_memory, + 1, 1000000, FALSE, + VALUE_PAIR_INT); + gtk_table_attach (GTK_TABLE (table), ifsOptD->memory_pair->spin, + 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsOptD->memory_pair->spin); + + label = gtk_label_new (_("Iterations:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsOptD->iterations_pair = value_pair_create (&ifsvals.iterations, + 1, 10000000, FALSE, + VALUE_PAIR_INT); + gtk_table_attach (GTK_TABLE (table), ifsOptD->iterations_pair->spin, + 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsOptD->iterations_pair->spin); + gtk_widget_show (label); + + label = gtk_label_new (_("Subdivide:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsOptD->subdivide_pair = value_pair_create (&ifsvals.subdivide, + 1, 10, FALSE, + VALUE_PAIR_INT); + gtk_table_attach (GTK_TABLE (table), ifsOptD->subdivide_pair->spin, + 1, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsOptD->subdivide_pair->spin); + + label = gtk_label_new (_("Spot radius:")); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, + GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + ifsOptD->radius_pair = value_pair_create (&ifsvals.radius, + 0, 5, TRUE, + VALUE_PAIR_DOUBLE); + gtk_table_attach (GTK_TABLE (table), ifsOptD->radius_pair->scale, + 1, 2, 3, 4, GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsOptD->radius_pair->scale); + gtk_table_attach (GTK_TABLE (table), ifsOptD->radius_pair->spin, + 2, 3, 3, 4, GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (ifsOptD->radius_pair->spin); + + value_pair_update (ifsOptD->iterations_pair); + value_pair_update (ifsOptD->subdivide_pair); + value_pair_update (ifsOptD->memory_pair); + value_pair_update (ifsOptD->radius_pair); + + gtk_widget_show (ifsOptD->dialog); + } + else + { + gtk_window_present (GTK_WINDOW (ifsOptD->dialog)); + } +} + +static void +ifs_compose (gint32 drawable_id) +{ + GeglBuffer *buffer = gimp_drawable_get_shadow_buffer (drawable_id); + gint width = gimp_drawable_width (drawable_id); + gint height = gimp_drawable_height (drawable_id); + gboolean alpha = gimp_drawable_has_alpha (drawable_id); + const Babl *format; + gint num_bands; + gint band_height; + gint band_y; + gint band_no; + gint i, j; + guchar *data; + guchar *mask = NULL; + guchar *nhits; + guchar rc, gc, bc; + GimpRGB color; + + if (alpha) + format = babl_format ("R'G'B'A u8"); + else + format = babl_format ("R'G'B' u8"); + + num_bands = ceil ((gdouble) (width * height * SQR (ifsvals.subdivide) * 5) + / (1024 * ifsvals.max_memory)); + band_height = (height + num_bands - 1) / num_bands; + + if (band_height > height) + band_height = height; + + mask = g_new (guchar, width * band_height * SQR (ifsvals.subdivide)); + data = g_new (guchar, width * band_height * SQR (ifsvals.subdivide) * 3); + nhits = g_new (guchar, width * band_height * SQR (ifsvals.subdivide)); + + gimp_context_get_background (&color); + gimp_rgb_get_uchar (&color, &rc, &gc, &bc); + + for (band_no = 0, band_y = 0; band_no < num_bands; band_no++) + { + GeglBufferIterator *iter; + GeglRectangle *roi; + + gimp_progress_init_printf (_("Rendering IFS (%d/%d)"), + band_no + 1, num_bands); + + /* render the band to a buffer */ + if (band_y + band_height > height) + band_height = height - band_y; + + /* we don't need to clear data since we store nhits */ + memset (mask, 0, width * band_height * SQR (ifsvals.subdivide)); + memset (nhits, 0, width * band_height * SQR (ifsvals.subdivide)); + + ifs_render (elements, + ifsvals.num_elements, width, height, ifsvals.iterations, + &ifsvals, band_y, band_height, data, mask, nhits, FALSE); + + /* transfer the image to the drawable */ + + iter = gegl_buffer_iterator_new (buffer, + GEGL_RECTANGLE (0, band_y, + width, band_height), 0, + format, + GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE, 1); + roi = &iter->items[0].roi; + + while (gegl_buffer_iterator_next (iter)) + { + guchar *destrow = iter->items[0].data; + + for (j = roi->y; j < (roi->y + roi->height); j++) + { + guchar *dest = destrow; + + for (i = roi->x; i < (roi->x + roi->width); i++) + { + /* Accumulate a reduced pixel */ + + gint rtot = 0; + gint btot = 0; + gint gtot = 0; + gint mtot = 0; + gint ii, jj; + + for (jj = 0; jj < ifsvals.subdivide; jj++) + { + guchar *ptr; + guchar *maskptr; + + ptr = data + + 3 * (((j - band_y) * ifsvals.subdivide + jj) * + ifsvals.subdivide * width + + i * ifsvals.subdivide); + + maskptr = mask + + ((j - band_y) * ifsvals.subdivide + jj) * + ifsvals.subdivide * width + + i * ifsvals.subdivide; + + for (ii = 0; ii < ifsvals.subdivide; ii++) + { + guchar maskval = *maskptr++; + + mtot += maskval; + rtot += maskval* *ptr++; + gtot += maskval* *ptr++; + btot += maskval* *ptr++; + } + } + + if (mtot) + { + rtot /= mtot; + gtot /= mtot; + btot /= mtot; + mtot /= SQR (ifsvals.subdivide); + } + + if (alpha) + { + *dest++ = rtot; + *dest++ = gtot; + *dest++ = btot; + *dest++ = mtot; + } + else + { + *dest++ = (mtot * rtot + (255 - mtot) * rc) / 255; + *dest++ = (mtot * gtot + (255 - mtot) * gc) / 255; + *dest++ = (mtot * btot + (255 - mtot) * bc) / 255; + } + } + + if (alpha) + destrow += roi->width * 4; + else + destrow += roi->width * 3; + } + } + + band_y += band_height; + } + + g_free (mask); + g_free (data); + g_free (nhits); + + g_object_unref (buffer); + + gimp_drawable_merge_shadow (drawable_id, TRUE); + gimp_drawable_update (drawable_id, 0, 0, width, height); +} + +static void +update_values (void) +{ + ifsD->in_update = TRUE; + + ifsD->current_vals = elements[ifsD->current_element]->v; + ifsD->current_vals.theta *= 180/G_PI; + + value_pair_update (ifsD->prob_pair); + value_pair_update (ifsD->x_pair); + value_pair_update (ifsD->y_pair); + value_pair_update (ifsD->scale_pair); + value_pair_update (ifsD->angle_pair); + value_pair_update (ifsD->asym_pair); + value_pair_update (ifsD->shear_pair); + color_map_update (ifsD->red_cmap); + color_map_update (ifsD->green_cmap); + color_map_update (ifsD->blue_cmap); + color_map_update (ifsD->black_cmap); + color_map_update (ifsD->target_cmap); + value_pair_update (ifsD->hue_scale_pair); + value_pair_update (ifsD->value_scale_pair); + + if (elements[ifsD->current_element]->v.simple_color) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->simple_button), + TRUE); + else + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->full_button), + TRUE); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->flip_check_button), + elements[ifsD->current_element]->v.flip); + + ifsD->in_update = FALSE; + + simple_color_set_sensitive (); +} + +static void +set_current_element (gint index) +{ + gchar *frame_name = g_strdup_printf (_("Transformation %s"), + elements[index]->name); + + ifsD->current_element = index; + + gtk_frame_set_label (GTK_FRAME (ifsD->current_frame),frame_name); + g_free (frame_name); + + update_values (); +} + +static void +design_area_realize (GtkWidget *widget) +{ + const gint cursors[3] = + { + GDK_FLEUR, /* OP_TRANSLATE */ + GDK_EXCHANGE, /* OP_ROTATE */ + GDK_CROSSHAIR /* OP_SHEAR */ + }; + + GdkDisplay *display = gtk_widget_get_display (widget); + GdkCursor *cursor = gdk_cursor_new_for_display (display, + cursors[ifsDesign->op]); + gdk_window_set_cursor (gtk_widget_get_window (widget), cursor); + gdk_cursor_unref (cursor); +} + +static gboolean +design_area_expose (GtkWidget *widget, + GdkEventExpose *event) +{ + GtkStyle *style = gtk_widget_get_style (widget); + GtkStateType state = gtk_widget_get_state (widget); + cairo_t *cr; + GtkAllocation allocation; + PangoLayout *layout; + gint i; + gint cx, cy; + + gtk_widget_get_allocation (widget, &allocation); + + cr = gdk_cairo_create (ifsDesign->pixmap); + + gdk_cairo_set_source_color (cr, &style->bg[state]); + cairo_paint (cr); + + cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); + cairo_translate (cr, 0.5, 0.5); + + /* draw an indicator for the center */ + + cx = ifsvals.center_x * allocation.width; + cy = ifsvals.center_y * allocation.width; + + cairo_move_to (cr, cx - 10, cy); + cairo_line_to (cr, cx + 10, cy); + + cairo_move_to (cr, cx, cy - 10); + cairo_line_to (cr, cx, cy + 10); + + gdk_cairo_set_source_color (cr, &style->fg[state]); + cairo_set_line_width (cr, 1.0); + cairo_stroke (cr); + + layout = gtk_widget_create_pango_layout (widget, NULL); + + for (i = 0; i < ifsvals.num_elements; i++) + { + aff_element_draw (elements[i], element_selected[i], + allocation.width, + allocation.height, + cr, + &style->fg[state], + layout); + } + + g_object_unref (layout); + + cairo_destroy (cr); + + cr = gdk_cairo_create (gtk_widget_get_window (widget)); + + gdk_cairo_region (cr, event->region); + cairo_clip (cr); + + gdk_cairo_set_source_pixmap (cr, ifsDesign->pixmap, 0.0, 0.0); + cairo_paint (cr); + + cairo_destroy (cr); + + return FALSE; +} + +static gboolean +design_area_configure (GtkWidget *widget, + GdkEventConfigure *event) +{ + GtkAllocation allocation; + gint i; + + gtk_widget_get_allocation (widget, &allocation); + + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_compute_trans (elements[i], + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_compute_boundary (elements[i], + allocation.width, allocation.height, + elements, ifsvals.num_elements); + + if (ifsDesign->pixmap) + { + g_object_unref (ifsDesign->pixmap); + } + ifsDesign->pixmap = gdk_pixmap_new (gtk_widget_get_window (widget), + allocation.width, + allocation.height, + -1); /* Is this correct? */ + + return FALSE; +} + +static gint +design_area_button_press (GtkWidget *widget, + GdkEventButton *event) +{ + GtkAllocation allocation; + gint i; + gint old_current; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + gtk_widget_grab_focus (widget); + + if (gdk_event_triggers_context_menu ((GdkEvent *) event)) + { + GtkWidget *menu = + gtk_ui_manager_get_widget (ifsDesign->ui_manager, + "/dummy-menubar/ifs-compose-menu"); + + if (GTK_IS_MENU_ITEM (menu)) + menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu)); + + gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget)); + + gtk_menu_popup (GTK_MENU (menu), + NULL, NULL, NULL, NULL, + event->button, event->time); + + return FALSE; + } + + old_current = ifsD->current_element; + ifsD->current_element = -1; + + /* Find out where the button press was */ + for (i = 0; i < ifsvals.num_elements; i++) + { + if (ipolygon_contains (elements[i]->click_boundary, event->x, event->y)) + { + set_current_element (i); + break; + } + } + + /* if the user started manipulating an object, set up a new + position on the undo ring */ + if (ifsD->current_element >= 0) + undo_begin (); + + if (!(event->state & GDK_SHIFT_MASK) + && ( (ifsD->current_element<0) + || !element_selected[ifsD->current_element] )) + { + for (i = 0; i < ifsvals.num_elements; i++) + element_selected[i] = FALSE; + } + + if (ifsD->current_element >= 0) + { + ifsDesign->button_state |= GDK_BUTTON1_MASK; + + element_selected[ifsD->current_element] = TRUE; + + ifsDesign->num_selected = 0; + ifsDesign->op_xcenter = 0.0; + ifsDesign->op_ycenter = 0.0; + for (i = 0; i < ifsvals.num_elements; i++) + { + if (element_selected[i]) + { + ifsD->selected_orig[i] = *elements[i]; + ifsDesign->op_xcenter += elements[i]->v.x; + ifsDesign->op_ycenter += elements[i]->v.y; + ifsDesign->num_selected++; + undo_update (i); + } + } + ifsDesign->op_xcenter /= ifsDesign->num_selected; + ifsDesign->op_ycenter /= ifsDesign->num_selected; + ifsDesign->op_x = (gdouble)event->x / allocation.width; + ifsDesign->op_y = (gdouble)event->y / allocation.width; + ifsDesign->op_center_x = ifsvals.center_x; + ifsDesign->op_center_y = ifsvals.center_y; + } + else + { + ifsD->current_element = old_current; + element_selected[old_current] = TRUE; + } + + design_area_redraw (); + + return FALSE; +} + +static gint +design_area_button_release (GtkWidget *widget, + GdkEventButton *event) +{ + if (event->button == 1 && + (ifsDesign->button_state & GDK_BUTTON1_MASK)) + { + ifsDesign->button_state &= ~GDK_BUTTON1_MASK; + ifs_compose_preview (); + } + return FALSE; +} + +static gint +design_area_motion (GtkWidget *widget, + GdkEventMotion *event) +{ + GtkAllocation allocation; + gint i; + gdouble xo; + gdouble yo; + gdouble xn; + gdouble yn; + Aff2 trans, t1, t2, t3; + + if (! (ifsDesign->button_state & GDK_BUTTON1_MASK)) + return FALSE; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + xo = (ifsDesign->op_x - ifsDesign->op_xcenter); + yo = (ifsDesign->op_y - ifsDesign->op_ycenter); + xn = (gdouble) event->x / allocation.width - ifsDesign->op_xcenter; + yn = (gdouble) event->y / allocation.width - ifsDesign->op_ycenter; + + switch (ifsDesign->op) + { + case OP_ROTATE: + aff2_translate (&t1,-ifsDesign->op_xcenter * allocation.width, + -ifsDesign->op_ycenter * allocation.width); + aff2_scale (&t2, + sqrt((SQR(xn)+SQR(yn))/(SQR(xo)+SQR(yo))), + 0); + aff2_compose (&t3, &t2, &t1); + aff2_rotate (&t1, - atan2(yn, xn) + atan2(yo, xo)); + aff2_compose (&t2, &t1, &t3); + aff2_translate (&t3, ifsDesign->op_xcenter * allocation.width, + ifsDesign->op_ycenter * allocation.width); + aff2_compose (&trans, &t3, &t2); + break; + + case OP_STRETCH: + aff2_translate (&t1,-ifsDesign->op_xcenter * allocation.width, + -ifsDesign->op_ycenter * allocation.width); + aff2_compute_stretch (&t2, xo, yo, xn, yn); + aff2_compose (&t3, &t2, &t1); + aff2_translate (&t1, ifsDesign->op_xcenter * allocation.width, + ifsDesign->op_ycenter * allocation.width); + aff2_compose (&trans, &t1, &t3); + break; + + case OP_TRANSLATE: + aff2_translate (&trans, + (xn-xo) * allocation.width, + (yn-yo) * allocation.width); + break; + } + + for (i = 0; i < ifsvals.num_elements; i++) + if (element_selected[i]) + { + if (ifsDesign->num_selected == ifsvals.num_elements) + { + gdouble cx, cy; + aff2_invert (&t1, &trans); + aff2_compose (&t2, &trans, &ifsD->selected_orig[i].trans); + aff2_compose (&elements[i]->trans, &t2, &t1); + + cx = ifsDesign->op_center_x * allocation.width; + cy = ifsDesign->op_center_y * allocation.width; + aff2_apply (&trans, cx, cy, &cx, &cy); + ifsvals.center_x = cx / allocation.width; + ifsvals.center_y = cy / allocation.width; + } + else + { + aff2_compose (&elements[i]->trans, &trans, + &ifsD->selected_orig[i].trans); + } + + aff_element_decompose_trans (elements[i],&elements[i]->trans, + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + aff_element_compute_trans (elements[i], + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + } + + update_values (); + design_area_redraw (); + + /* Ask for more motion events in case the event was a hint */ + gdk_event_request_motions (event); + + return FALSE; +} + +static void +design_area_redraw (void) +{ + GtkAllocation allocation; + gint i; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_compute_boundary (elements[i], + allocation.width, allocation.height, + elements, ifsvals.num_elements); + + gtk_widget_queue_draw (ifsDesign->area); +} + +/* Undo ring functions */ +static void +undo_begin (void) +{ + gint i, j; + gint to_delete; + gint new_index; + + if (undo_cur == UNDO_LEVELS-1) + { + to_delete = 1; + undo_start = (undo_start + 1) % UNDO_LEVELS; + } + else + { + undo_cur++; + to_delete = undo_num - undo_cur; + } + + undo_num = undo_num - to_delete + 1; + new_index = (undo_start + undo_cur) % UNDO_LEVELS; + + /* remove any redo elements or the oldest element if necessary */ + for (j = new_index; to_delete > 0; j = (j+1) % UNDO_LEVELS, to_delete--) + { + for (i = 0; i < undo_ring[j].ifsvals.num_elements; i++) + if (undo_ring[j].elements[i]) + aff_element_free (undo_ring[j].elements[i]); + g_free (undo_ring[j].elements); + g_free (undo_ring[j].element_selected); + } + + undo_ring[new_index].ifsvals = ifsvals; + undo_ring[new_index].elements = g_new (AffElement *,ifsvals.num_elements); + undo_ring[new_index].element_selected = g_new (gboolean, + ifsvals.num_elements); + undo_ring[new_index].current_element = ifsD->current_element; + + for (i = 0; i < ifsvals.num_elements; i++) + { + undo_ring[new_index].elements[i] = NULL; + undo_ring[new_index].element_selected[i] = element_selected[i]; + } + + design_op_actions_update (); +} + +static void +undo_update (gint el) +{ + AffElement *elem; + /* initialize */ + + elem = NULL; + + if (!undo_ring[(undo_start + undo_cur) % UNDO_LEVELS].elements[el]) + undo_ring[(undo_start + undo_cur) % UNDO_LEVELS].elements[el] + = elem = g_new (AffElement, 1); + + *elem = *elements[el]; + elem->draw_boundary = NULL; + elem->click_boundary = NULL; +} + +static void +undo_exchange (gint el) +{ + GtkAllocation allocation; + gint i; + AffElement **telements; + gboolean *tselected; + IfsComposeVals tifsvals; + gint tcurrent; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + /* swap the arrays and values*/ + telements = elements; + elements = undo_ring[el].elements; + undo_ring[el].elements = telements; + + tifsvals = ifsvals; + ifsvals = undo_ring[el].ifsvals; + undo_ring[el].ifsvals = tifsvals; + + tselected = element_selected; + element_selected = undo_ring[el].element_selected; + undo_ring[el].element_selected = tselected; + + tcurrent = ifsD->current_element; + ifsD->current_element = undo_ring[el].current_element; + undo_ring[el].current_element = tcurrent; + + /* now swap back any unchanged elements */ + for (i = 0; i < ifsvals.num_elements; i++) + if (!elements[i]) + { + elements[i] = undo_ring[el].elements[i]; + undo_ring[el].elements[i] = NULL; + } + else + aff_element_compute_trans (elements[i], + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + + set_current_element (ifsD->current_element); + + design_area_redraw (); + + ifs_compose_preview (); +} + +static void +undo (void) +{ + if (undo_cur >= 0) + { + undo_exchange ((undo_start + undo_cur) % UNDO_LEVELS); + undo_cur--; + } + + design_op_actions_update (); +} + +static void +redo (void) +{ + if (undo_cur != undo_num - 1) + { + undo_cur++; + undo_exchange ((undo_start + undo_cur) % UNDO_LEVELS); + } + + design_op_actions_update (); +} + +static void +design_area_select_all_callback (GtkWidget *widget, + gpointer data) +{ + gint i; + + for (i = 0; i < ifsvals.num_elements; i++) + element_selected[i] = TRUE; + + design_area_redraw (); +} + +/* Interface functions */ + +static void +val_changed_update (void) +{ + GtkAllocation allocation; + AffElement *cur; + + if (ifsD->in_update) + return; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + cur = elements[ifsD->current_element]; + + undo_begin (); + undo_update (ifsD->current_element); + + cur->v = ifsD->current_vals; + cur->v.theta *= G_PI/180.0; + aff_element_compute_trans (cur, + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + aff_element_compute_color_trans (cur); + + design_area_redraw (); + + ifs_compose_preview (); +} + +/* Pseudo-widget representing a color mapping */ + +#define COLOR_SAMPLE_SIZE 30 + +static ColorMap * +color_map_create (const gchar *name, + GimpRGB *orig_color, + GimpRGB *data, + gboolean fixed_point) +{ + GtkWidget *frame; + GtkWidget *arrow; + ColorMap *color_map = g_new (ColorMap, 1); + + gimp_rgb_set_alpha (data, 1.0); + color_map->color = data; + color_map->fixed_point = fixed_point; + color_map->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); + + frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (color_map->hbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + color_map->orig_preview = + gimp_color_area_new (fixed_point ? data : orig_color, + GIMP_COLOR_AREA_FLAT, 0); + gtk_drag_dest_unset (color_map->orig_preview); + gtk_widget_set_size_request (color_map->orig_preview, + COLOR_SAMPLE_SIZE, COLOR_SAMPLE_SIZE); + gtk_container_add (GTK_CONTAINER (frame), color_map->orig_preview); + gtk_widget_show (color_map->orig_preview); + + arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (color_map->hbox), arrow, FALSE, FALSE, 0); + gtk_widget_show (arrow); + + color_map->button = gimp_color_button_new (name, + COLOR_SAMPLE_SIZE, + COLOR_SAMPLE_SIZE, + data, + GIMP_COLOR_AREA_FLAT); + gtk_box_pack_start (GTK_BOX (color_map->hbox), color_map->button, + FALSE, FALSE, 0); + gtk_widget_show (color_map->button); + + g_signal_connect (color_map->button, "color-changed", + G_CALLBACK (gimp_color_button_get_color), + data); + + g_signal_connect (color_map->button, "color-changed", + G_CALLBACK (color_map_color_changed_cb), + color_map); + + return color_map; +} + +static void +color_map_color_changed_cb (GtkWidget *widget, + ColorMap *color_map) +{ + if (ifsD->in_update) + return; + + undo_begin (); + undo_update (ifsD->current_element); + + elements[ifsD->current_element]->v = ifsD->current_vals; + elements[ifsD->current_element]->v.theta *= G_PI/180.0; + aff_element_compute_color_trans (elements[ifsD->current_element]); + + update_values (); + + ifs_compose_preview (); +} + +static void +color_map_update (ColorMap *color_map) +{ + gimp_color_button_set_color (GIMP_COLOR_BUTTON (color_map->button), + color_map->color); + + if (color_map->fixed_point) + gimp_color_area_set_color (GIMP_COLOR_AREA (color_map->orig_preview), + color_map->color); +} + +static void +simple_color_set_sensitive (void) +{ + gint sc = elements[ifsD->current_element]->v.simple_color; + + gtk_widget_set_sensitive (ifsD->target_cmap->hbox, sc); + gtk_widget_set_sensitive (ifsD->hue_scale_pair->scale, sc); + gtk_widget_set_sensitive (ifsD->hue_scale_pair->spin, sc); + gtk_widget_set_sensitive (ifsD->value_scale_pair->scale, sc); + gtk_widget_set_sensitive (ifsD->value_scale_pair->spin, sc); + + gtk_widget_set_sensitive (ifsD->red_cmap->hbox, !sc); + gtk_widget_set_sensitive (ifsD->green_cmap->hbox, !sc); + gtk_widget_set_sensitive (ifsD->blue_cmap->hbox, !sc); + gtk_widget_set_sensitive (ifsD->black_cmap->hbox, !sc); +} + +static void +simple_color_toggled (GtkWidget *widget, + gpointer data) +{ + AffElement *cur = elements[ifsD->current_element]; + + cur->v.simple_color = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + + ifsD->current_vals.simple_color = cur->v.simple_color; + + if (cur->v.simple_color) + aff_element_compute_color_trans (cur); + + val_changed_update (); + simple_color_set_sensitive (); +} + +/* Generic mechanism for scale/entry combination (possibly without + scale) */ + +static ValuePair * +value_pair_create (gpointer data, + gdouble lower, + gdouble upper, + gboolean create_scale, + ValuePairType type) +{ + + ValuePair *value_pair = g_new (ValuePair, 1); + + value_pair->data.d = data; + value_pair->type = type; + value_pair->timeout_id = 0; + + value_pair->adjustment = (GtkAdjustment *) + gtk_adjustment_new (1.0, lower, upper, + (upper - lower) / 100, + (upper - lower) / 10, + 0.0); + value_pair->spin = gimp_spin_button_new (value_pair->adjustment, 1.0, 3); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (value_pair->spin), TRUE); + gtk_widget_set_size_request (value_pair->spin, 72, -1); + + g_signal_connect (value_pair->adjustment, "value-changed", + G_CALLBACK (value_pair_scale_callback), + value_pair); + + if (create_scale) + { + value_pair->scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, + value_pair->adjustment); + + if (type == VALUE_PAIR_INT) + gtk_scale_set_digits (GTK_SCALE (value_pair->scale), 0); + else + gtk_scale_set_digits (GTK_SCALE (value_pair->scale), 3); + + gtk_scale_set_draw_value (GTK_SCALE (value_pair->scale), FALSE); + } + else + { + value_pair->scale = NULL; + } + + return value_pair; +} + +static void +value_pair_update (ValuePair *value_pair) +{ + if (value_pair->type == VALUE_PAIR_INT) + gtk_adjustment_set_value (value_pair->adjustment, *value_pair->data.i); + else + gtk_adjustment_set_value (value_pair->adjustment, *value_pair->data.d); + +} + +static gboolean +value_pair_scale_callback_real (gpointer data) +{ + ValuePair *value_pair = data; + gint changed = FALSE; + + if (value_pair->type == VALUE_PAIR_DOUBLE) + { + if ((gdouble) *value_pair->data.d != + gtk_adjustment_get_value (value_pair->adjustment)) + { + changed = TRUE; + *value_pair->data.d = gtk_adjustment_get_value (value_pair->adjustment); + } + } + else + { + if (*value_pair->data.i != + (gint) gtk_adjustment_get_value (value_pair->adjustment)) + { + changed = TRUE; + *value_pair->data.i = gtk_adjustment_get_value (value_pair->adjustment); + } + } + + if (changed) + val_changed_update (); + + value_pair->timeout_id = 0; + + return FALSE; +} + +static void +value_pair_scale_callback (GtkAdjustment *adjustment, + ValuePair *value_pair) +{ + if (value_pair->timeout_id != 0) + return; + + value_pair->timeout_id = g_timeout_add (500, /* update every half second */ + value_pair_scale_callback_real, + value_pair); +} + +static void +design_op_update_callback (GtkRadioAction *action, + GtkRadioAction *current, + gpointer data) +{ + ifsDesign->op = gtk_radio_action_get_current_value (action); + + /* cursor switch */ + if (gtk_widget_get_realized (ifsDesign->area)) + design_area_realize (ifsDesign->area); +} + +static void +recompute_center_cb (GtkWidget *widget, + gpointer data) +{ + recompute_center (TRUE); +} + +static void +recompute_center (gboolean save_undo) +{ + GtkAllocation allocation; + gint i; + gdouble x, y; + gdouble center_x = 0.0; + gdouble center_y = 0.0; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + if (save_undo) + undo_begin (); + + for (i = 0; i < ifsvals.num_elements; i++) + { + if (save_undo) + undo_update (i); + + aff_element_compute_trans (elements[i],1, ifsvals.aspect_ratio, + ifsvals.center_x, ifsvals.center_y); + aff2_fixed_point (&elements[i]->trans, &x, &y); + center_x += x; + center_y += y; + } + + ifsvals.center_x = center_x/ifsvals.num_elements; + ifsvals.center_y = center_y/ifsvals.num_elements; + + for (i = 0; i < ifsvals.num_elements; i++) + { + aff_element_decompose_trans (elements[i],&elements[i]->trans, + 1, ifsvals.aspect_ratio, + ifsvals.center_x, ifsvals.center_y); + } + + if (allocation.width > 1 && allocation.height > 1) + { + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_compute_trans (elements[i], + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + design_area_redraw (); + update_values (); + } +} + +static void +flip_check_button_callback (GtkWidget *widget, + gpointer data) +{ + GtkAllocation allocation; + guint i; + gboolean active; + + if (ifsD->in_update) + return; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + + undo_begin (); + for (i = 0; i < ifsvals.num_elements; i++) + { + if (element_selected[i]) + { + undo_update (i); + elements[i]->v.flip = active; + aff_element_compute_trans (elements[i], + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + } + } + + update_values (); + design_area_redraw (); + + ifs_compose_preview (); +} + +static void +ifs_compose_set_defaults (void) +{ + gint i; + GimpRGB color; + + gimp_context_get_foreground (&color); + + ifsvals.aspect_ratio = + (gdouble)ifsD->drawable_height / ifsD->drawable_width; + + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_free (elements[i]); + count_for_naming = 0; + + ifsvals.num_elements = 3; + elements = g_realloc (elements, ifsvals.num_elements * sizeof(AffElement *)); + element_selected = g_realloc (element_selected, + ifsvals.num_elements * sizeof(gboolean)); + + elements[0] = aff_element_new (0.3, 0.37 * ifsvals.aspect_ratio, &color, + ++count_for_naming); + element_selected[0] = FALSE; + elements[1] = aff_element_new (0.7, 0.37 * ifsvals.aspect_ratio, &color, + ++count_for_naming); + element_selected[1] = FALSE; + elements[2] = aff_element_new (0.5, 0.7 * ifsvals.aspect_ratio, &color, + ++count_for_naming); + element_selected[2] = FALSE; + + ifsvals.center_x = 0.5; + ifsvals.center_y = 0.5 * ifsvals.aspect_ratio; + ifsvals.iterations = ifsD->drawable_height * ifsD->drawable_width; + ifsvals.subdivide = 3; + ifsvals.max_memory = 4096; + + if (ifsOptD) + { + value_pair_update (ifsOptD->iterations_pair); + value_pair_update (ifsOptD->subdivide_pair); + value_pair_update (ifsOptD->radius_pair); + value_pair_update (ifsOptD->memory_pair); + } + + ifsvals.radius = 0.7; + + set_current_element (0); + element_selected[0] = TRUE; + recompute_center (FALSE); + + if (ifsD->selected_orig) + g_free (ifsD->selected_orig); + + ifsD->selected_orig = g_new (AffElement, ifsvals.num_elements); +} + +/* show a transient message dialog */ +static void +ifscompose_message_dialog (GtkMessageType type, + GtkWindow *parent, + const gchar *title, + const gchar *message) +{ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (parent, 0, type, GTK_BUTTONS_OK, + "%s", message); + + if (title) + gtk_window_set_title (GTK_WINDOW (dialog), title); + + gtk_window_set_role (GTK_WINDOW (dialog), "ifscompose-message"); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); +} + +/* save an ifs file */ +static void +ifsfile_save_response (GtkWidget *dialog, + gint response_id, + gpointer data) +{ + if (response_id == GTK_RESPONSE_OK) + { + gchar *filename; + gchar *str; + FILE *fh; + + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + + str = ifsvals_stringify (&ifsvals, elements); + + fh = g_fopen (filename, "wb"); + if (! fh) + { + gchar *message = + g_strdup_printf (_("Could not open '%s' for writing: %s"), + gimp_filename_to_utf8 (filename), + g_strerror (errno)); + + ifscompose_message_dialog (GTK_MESSAGE_ERROR, GTK_WINDOW (dialog), + _("Save failed"), message); + + g_free (message); + g_free (filename); + + return; + } + + fputs (str, fh); + fclose (fh); + } + + gtk_widget_destroy (dialog); +} + +/* replace ifsvals and elements with specified new values + * recompute and update everything necessary */ +static void +ifsfile_replace_ifsvals (IfsComposeVals *new_ifsvals, + AffElement **new_elements) +{ + GtkAllocation allocation; + guint i; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_free (elements[i]); + g_free (elements); + + ifsvals = *new_ifsvals; + elements = new_elements; + for (i = 0; i < ifsvals.num_elements; i++) + { + aff_element_compute_trans (elements[i], + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + aff_element_compute_color_trans (elements[i]); + } + + element_selected = g_realloc (element_selected, + ifsvals.num_elements * sizeof(gboolean)); + for (i = 0; i < ifsvals.num_elements; i++) + element_selected[i] = FALSE; + + if (ifsOptD) + { + value_pair_update (ifsOptD->iterations_pair); + value_pair_update (ifsOptD->subdivide_pair); + value_pair_update (ifsOptD->radius_pair); + value_pair_update (ifsOptD->memory_pair); + } + + set_current_element (0); + element_selected[0] = TRUE; + recompute_center (FALSE); + + if (ifsD->selected_orig) + g_free (ifsD->selected_orig); + + ifsD->selected_orig = g_new (AffElement, ifsvals.num_elements); +} + +/* load an ifs file */ +static void +ifsfile_load_response (GtkWidget *dialog, + gint response_id, + gpointer data) +{ + if (response_id == GTK_RESPONSE_OK) + { + gchar *filename; + gchar *buffer; + AffElement **new_elements; + IfsComposeVals new_ifsvals; + GError *error = NULL; + guint i; + + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + + if (! g_file_get_contents (filename, &buffer, NULL, &error)) + { + ifscompose_message_dialog (GTK_MESSAGE_ERROR, GTK_WINDOW (dialog), + _("Open failed"), error->message); + g_error_free (error); + g_free (filename); + return; + } + + if (! ifsvals_parse_string (buffer, &new_ifsvals, &new_elements)) + { + gchar *message = g_strdup_printf (_("File '%s' doesn't seem to be " + "an IFS Fractal file."), + gimp_filename_to_utf8 (filename)); + + ifscompose_message_dialog (GTK_MESSAGE_ERROR, GTK_WINDOW (dialog), + _("Open failed"), message); + g_free (filename); + g_free (message); + g_free (buffer); + + return; + } + + g_free (buffer); + g_free (filename); + + undo_begin (); + for (i = 0; i < ifsvals.num_elements; i++) + undo_update (i); + + ifsfile_replace_ifsvals (&new_ifsvals, new_elements); + + design_op_actions_update (); + + ifs_compose_preview (); + + design_area_redraw (); + } + + gtk_widget_destroy (GTK_WIDGET (dialog)); +} + +static void +ifs_compose_save (GtkWidget *parent) +{ + static GtkWidget *dialog = NULL; + + if (! dialog) + { + dialog = + gtk_file_chooser_dialog_new (_("Save as IFS Fractal file"), + GTK_WINDOW (parent), + GTK_FILE_CHOOSER_ACTION_SAVE, + + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Save"), GTK_RESPONSE_OK, + + NULL); + + gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), + GTK_RESPONSE_OK, + GTK_RESPONSE_CANCEL, + -1); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), + TRUE); + + g_signal_connect (dialog, "destroy", + G_CALLBACK (gtk_widget_destroyed), + &dialog); + g_signal_connect (dialog, "response", + G_CALLBACK (ifsfile_save_response), + NULL); + } + + gtk_window_present (GTK_WINDOW (dialog)); +} + +static void +ifs_compose_load (GtkWidget *parent) +{ + static GtkWidget *dialog = NULL; + + if (! dialog) + { + dialog = + gtk_file_chooser_dialog_new (_("Open IFS Fractal file"), + GTK_WINDOW (parent), + GTK_FILE_CHOOSER_ACTION_OPEN, + + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Open"), GTK_RESPONSE_OK, + + NULL); + + gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), + GTK_RESPONSE_OK, + GTK_RESPONSE_CANCEL, + -1); + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + + g_signal_connect (dialog, "destroy", + G_CALLBACK (gtk_widget_destroyed), + &dialog); + g_signal_connect (dialog, "response", + G_CALLBACK (ifsfile_load_response), + NULL); + } + + gtk_window_present (GTK_WINDOW (dialog)); +} + +static void +ifs_compose_new_callback (GtkAction *action, + gpointer data) +{ + GtkAllocation allocation; + GimpRGB color; + gint i; + AffElement *elem; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + undo_begin (); + + gimp_context_get_foreground (&color); + + elem = aff_element_new (0.5, 0.5 * allocation.height / allocation.width, + &color, + ++count_for_naming); + + ifsvals.num_elements++; + elements = g_realloc (elements, ifsvals.num_elements * sizeof (AffElement *)); + element_selected = g_realloc (element_selected, + ifsvals.num_elements * sizeof (gboolean)); + + for (i = 0; i < ifsvals.num_elements-1; i++) + element_selected[i] = FALSE; + element_selected[ifsvals.num_elements-1] = TRUE; + + elements[ifsvals.num_elements-1] = elem; + set_current_element (ifsvals.num_elements-1); + + ifsD->selected_orig = g_realloc (ifsD->selected_orig, + ifsvals.num_elements * sizeof(AffElement)); + aff_element_compute_trans (elem, + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + + design_area_redraw (); + + ifs_compose_preview (); + + design_op_actions_update (); +} + +static void +ifs_compose_delete_callback (GtkAction *action, + gpointer data) +{ + gint i; + gint new_current; + + undo_begin (); + undo_update (ifsD->current_element); + + aff_element_free (elements[ifsD->current_element]); + + if (ifsD->current_element < ifsvals.num_elements-1) + { + undo_update (ifsvals.num_elements-1); + elements[ifsD->current_element] = elements[ifsvals.num_elements-1]; + new_current = ifsD->current_element; + } + else + new_current = ifsvals.num_elements-2; + + ifsvals.num_elements--; + + for (i = 0; i < ifsvals.num_elements; i++) + if (element_selected[i]) + { + new_current = i; + break; + } + + element_selected[new_current] = TRUE; + set_current_element (new_current); + + design_area_redraw (); + + ifs_compose_preview (); + + design_op_actions_update (); +} + +static void +ifs_compose_options_callback (GtkAction *action, + gpointer data) +{ + ifs_options_dialog (GTK_WIDGET (data)); +} + +static gint +preview_idle_render (gpointer data) +{ + GtkAllocation allocation; + gint iterations = PREVIEW_RENDER_CHUNK; + gint i; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + if (iterations > ifsD->preview_iterations) + iterations = ifsD->preview_iterations; + + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_compute_trans (elements[i], + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + + ifs_render (elements, ifsvals.num_elements, + allocation.width, allocation.height, + iterations,&ifsvals, 0, allocation.height, + ifsD->preview_data, NULL, NULL, TRUE); + + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_compute_trans (elements[i], + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + + ifsD->preview_iterations -= iterations; + + gimp_preview_area_draw (GIMP_PREVIEW_AREA (ifsD->preview), + 0, 0, allocation.width, allocation.height, + GIMP_RGB_IMAGE, + ifsD->preview_data, + allocation.width * 3); + + return (ifsD->preview_iterations != 0); +} + +static void +ifs_compose_preview (void) +{ + /* Expansion isn't really supported for previews */ + gint i; + gint width = ifsD->preview_width; + gint height = ifsD->preview_height; + guchar rc, gc, bc; + guchar *ptr; + GimpRGB color; + + if (!ifsD->preview_data) + ifsD->preview_data = g_new (guchar, 3 * width * height); + + gimp_context_get_background (&color); + gimp_rgb_get_uchar (&color, &rc, &gc, &bc); + + ptr = ifsD->preview_data; + for (i = 0; i < width * height; i++) + { + *ptr++ = rc; + *ptr++ = gc; + *ptr++ = bc; + } + + if (ifsD->preview_iterations == 0) + g_idle_add (preview_idle_render, NULL); + + ifsD->preview_iterations = + ifsvals.iterations * ((gdouble) width * height / + (ifsD->drawable_width * ifsD->drawable_height)); +} + +static void +ifs_compose_response (GtkWidget *widget, + gint response_id, + gpointer data) +{ + switch (response_id) + { + case RESPONSE_OPEN: + ifs_compose_load (widget); + break; + + case RESPONSE_SAVE: + ifs_compose_save (widget); + break; + + case RESPONSE_RESET: + { + GtkAllocation allocation; + gint i; + + gtk_widget_get_allocation (ifsDesign->area, &allocation); + + undo_begin (); + for (i = 0; i < ifsvals.num_elements; i++) + undo_update (i); + + ifs_compose_set_defaults (); + + ifs_compose_preview (); + + for (i = 0; i < ifsvals.num_elements; i++) + aff_element_compute_trans (elements[i], + allocation.width, allocation.height, + ifsvals.center_x, ifsvals.center_y); + + design_area_redraw (); + design_op_actions_update (); + } + break; + + case GTK_RESPONSE_OK: + ifscint.run = TRUE; + + default: + gtk_widget_destroy (widget); + break; + } +} diff --git a/plug-ins/ifs-compose/ifs-compose.h b/plug-ins/ifs-compose/ifs-compose.h new file mode 100644 index 0000000..28b9a3b --- /dev/null +++ b/plug-ins/ifs-compose/ifs-compose.h @@ -0,0 +1,180 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * IfsCompose is a interface for creating IFS fractals by + * direct manipulation. + * Copyright (C) 1997 Owen Taylor + * + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +typedef struct { + gdouble a11,a12,a21,a22,b1,b2; +} Aff2; + +typedef struct { + gdouble vals[3][4]; +} Aff3; + +typedef struct { + GdkPoint *points; + gint npoints; +} IPolygon; + +typedef struct { + gdouble x, y; + gdouble theta; + gdouble scale; + gdouble asym; + gdouble shear; + gint flip; + + GimpRGB red_color; + GimpRGB green_color; + GimpRGB blue_color; + GimpRGB black_color; + + GimpRGB target_color; + gdouble hue_scale; + gdouble value_scale; + + gint simple_color; + gdouble prob; +} AffElementVals; + +typedef struct +{ + gint num_elements; + gint iterations; + gint max_memory; + gint subdivide; + gdouble radius; + gdouble aspect_ratio; + gdouble center_x; + gdouble center_y; +} IfsComposeVals; + +typedef struct { + AffElementVals v; + + Aff2 trans; + Aff3 color_trans; + + gchar *name; + + IPolygon *click_boundary; + IPolygon *draw_boundary; +} AffElement; + + +/* manipulation of affine transforms */ +void aff2_translate (Aff2 *naff, + gdouble x, + gdouble y); +void aff2_rotate (Aff2 *naff, + gdouble theta); +void aff2_scale (Aff2 *naff, + gdouble s, + gint flip); +void aff2_distort (Aff2 *naff, + gdouble asym, + gdouble shear); +void aff2_compute_stretch (Aff2 *naff, + gdouble xo, + gdouble yo, + gdouble xn, + gdouble yn); +void aff2_compute_distort (Aff2 *naff, + gdouble xo, + gdouble yo, + gdouble xn, + gdouble yn); +void aff2_compose (Aff2 *naff, + Aff2 *aff1, + Aff2 *aff2); +void aff2_invert (Aff2 *naff, + Aff2 *aff); +void aff2_apply (Aff2 *aff, + gdouble x, + gdouble y, + gdouble *xf, + gdouble *yf); +void aff2_fixed_point (Aff2 *aff, + gdouble *xf, + gdouble *yf); +void aff3_apply (Aff3 *t, + gdouble x, + gdouble y, + gdouble z, + gdouble *xf, + gdouble *yf, + gdouble *zf); + + +/* manipulation of polygons */ +IPolygon *ipolygon_convex_hull (IPolygon *poly); +gint ipolygon_contains (IPolygon *poly, + gint xt, + gint yt); + + +/* manipulation of composite transforms */ +AffElement *aff_element_new (gdouble x, + gdouble y, + GimpRGB *color, + gint count); +void aff_element_free (AffElement *elem); +void aff_element_compute_trans (AffElement *elem, + gdouble width, + gdouble height, + gdouble center_x, + gdouble center_y); +void aff_element_compute_color_trans (AffElement *elem); +void aff_element_decompose_trans (AffElement *elem, + Aff2 *aff, + gdouble width, + gdouble height, + gdouble center_x, + gdouble center_y); +void aff_element_compute_boundary (AffElement *elem, + gint width, + gint height, + AffElement **elements, + gint num_elements); +void aff_element_draw (AffElement *elem, + gint selected, + gint width, + gint height, + cairo_t *cr, + GdkColor *color, + PangoLayout *layout); + + +void ifs_render (AffElement **elements, + gint num_elements, + gint width, + gint height, + gint nsteps, + IfsComposeVals *vals, + gint band_y, + gint band_height, + guchar *data, + guchar *mask, + guchar *nhits, + gboolean preview); + +gchar * ifsvals_stringify (IfsComposeVals *vals, + AffElement **elements); +gboolean ifsvals_parse_string (const gchar *str, + IfsComposeVals *vals, + AffElement ***elements); -- cgit v1.2.3