![]() The plugin should return an integer value representing the version of the Tux Paint 'Magic' tool plugin API the plugin was built against. Plugin "housekeeping" functions Uint32 api_version(void) That is, if your plugin is called " zoom.so" (on Linux) or " zoom.dll" (on Windows), then the names of your functions must begin with " zoom_" (e.g., " zoom_get_name(.)"). Note: Remember, your plugin's function names must be preceded by your plugin's filename. Your plugin is required to contain, at the least, all of the following functions. Since it is a pointer, you access its elements via " ->" (arrow) rather than ". ![]() Note: " update_rect" is a C pointer (an " SDL_Rect *" rather than just an " SDL_Rect") because you need to fill in its contents. Or, if your effect changes the entire canvas (e.g., flips it upside-down), you'd fill it as follows: If your effect affects a 32x32 area centered around the mouse pointer, you would fill the SDL_Rect as follows: Your magical effects should end up here! SDL_Rect * update_rectĪ pointer to an SDL 'rectangle' structure that you use to tell Tux Paint what part of the canvas has been updated. (That is, read from " snapshot" and write to " canvas", below.) SDL_Surface * canvas If you don't continuously affect the image during one hold of the mouse button, you should base your effects off the contents of this canvas. SDL_Surface * snapshotĪ snapshot of the previous Tux Paint canvas, taken when the the mouse was first clicked to activate the current magic tool. (If not, "which" will always be 0.) See "Creating plugins with multiple effects", below. Note: The magic_api struct is defined in the C header file " tp_magic_api.h", which you should include at the top of your plugin's C source file:Īn index the plugin should use to differentiate different 'Magic' tools, if the plugin provides more than one. The contents of this struct are described below. Pointer to a C structure containing pointers to Tux Paint functions and other data that the plugin can (and sometimes should) use. Here is a description of arguments that many of your plugin's functions will need to accept. This includes private functions (ones not used by Tux Paint directly), unless you declare those as ' static'. Note: To avoid 'namespace' collisions, each function's name must start with the shared object's filename (e.g., "blur.so" or "blur.dll" would have functions whose names begin with " blur_"). 'Magic' tool plugins must contain the functions listed below. ![]() The C header file and command-line tool mentioned above are included with Tux Paint - or in some cases, as part of a "Tux Paint 'Magic' Tool Plugin Development package". Also, when you run the C compiler to build a plugin, you should use the command-line tool " tp-magic-config" to get the appropriate compiler flags (such as where the compiler can find the Tux Paint plugin header file, as well as SDL's header files) for building a plugin. Plugins should #include the C header file " tp_magic_api.h", which exposes the 'Magic' tool plugin API. A pointer to this structure gets passed along to the plugin's functions as an argument when Tux Paint invokes them. This is exposed as a C structure (or " struct") which contains pointers to functions and other data inside Tux Paint. In turn, Tux Paint provides a number of helper functions that the plugin may (or sometimes is required to) use. dll" files on Windows) and find the functions within. Tux Paint utilizes SDL's "SDL_LoadObject()" and "SDL_LoadFunction()" routines to load plugins (shared objects files e.g., ". Those who create 'Magic' tool plugins for Tux Paint must provide some interfaces (C functions) that Tux Paint may invoke. Familiarity with the SDL API is highly recommended, but some basic SDL concepts will be covered in this document. Therefore, for the moment at least, one must understand the C language and how to compile C-based programs. Tux Paint is written in the C programming language, and uses the Simple DirectMedia Layer library ('libSDL', or simply 'SDL' available from ).
0 Comments
Leave a Reply. |