Magic tools (and tp-magic-config) supports local (user) plugins.
Added copyright & credit info to new Magic tool plugin .c files. Updated Magic plugin doc API.
This commit is contained in:
parent
cf10090cc1
commit
0d6c2cf1b9
30 changed files with 1146 additions and 350 deletions
7
Makefile
7
Makefile
|
|
@ -7,7 +7,7 @@
|
|||
# bill@newbreedsoftware.com
|
||||
# http://www.tuxpaint.org/
|
||||
|
||||
# June 14, 2002 - August 2, 2007
|
||||
# June 14, 2002 - August 7, 2007
|
||||
|
||||
|
||||
# The version number, for release:
|
||||
|
|
@ -345,8 +345,9 @@ install-magic-plugins:
|
|||
@cp magic/icons/*.png $(DATA_PREFIX)/images/magic
|
||||
@chmod a+r,g-w,o-w $(DATA_PREFIX)/images/magic/*.png
|
||||
@install -d $(DATA_PREFIX)/sounds/magic
|
||||
@cp magic/sounds/*.wav $(DATA_PREFIX)/sounds/magic
|
||||
@chmod a+r,g-w,o-w $(DATA_PREFIX)/sounds/magic/*.wav
|
||||
@cp magic/sounds/*.wav magic/sounds/*.ogg $(DATA_PREFIX)/sounds/magic
|
||||
@chmod a+r,g-w,o-w $(DATA_PREFIX)/sounds/magic/*.wav \
|
||||
$(DATA_PREFIX)/sounds/magic/*.ogg
|
||||
|
||||
install-magic-plugin-dev: src/tp_magic_api.h
|
||||
@echo
|
||||
|
|
|
|||
|
|
@ -119,6 +119,13 @@ $Id$
|
|||
* Flower
|
||||
(utilizes Bezier curve example code from Wikipedia.org)
|
||||
|
||||
(Glass Tile, Emboss, Flower and Ripples sounds based on sounds
|
||||
from KDE 3.5.7; http://www.kde.org/ )
|
||||
(Metal Paint sound based on sound from Engima;
|
||||
http://www.nongnu.org/enigma/ )
|
||||
(Waves sound based on sound from Super Tux;
|
||||
http://supertux.berlios.de/ )
|
||||
|
||||
* New Localizations:
|
||||
------------------
|
||||
* Esperanto translation
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
July 5, 2007 - August 2, 2007
|
||||
July 5, 2007 - August 7, 2007
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ Interfaces
|
|||
'0' otherwise. Useful to create 'Magic' tools that affect the
|
||||
canvas with a circular brush shape.
|
||||
|
||||
* void line(int which, SDL_Surface * canvas,
|
||||
* void line(void * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x1, int y1, int x2, int y2,
|
||||
int step, FUNC callback)
|
||||
This function calculates all points on a line between the
|
||||
|
|
@ -364,9 +364,10 @@ Interfaces
|
|||
calls the 'callback' function.
|
||||
|
||||
It sends the 'callback' function the (x,y) coordinates on the
|
||||
line, Tux Paint's "magic_api" struct (as a "void *" pointer), a
|
||||
'which' value, represening which of the plugin's 'Magic' tool is
|
||||
being used, and the current and snapshot canvases.
|
||||
line, Tux Paint's "magic_api" struct (as a "void *" pointer
|
||||
which you need to send to it), a 'which' value, represening
|
||||
which of the plugin's 'Magic' tool is being used, and the
|
||||
current and snapshot canvases.
|
||||
|
||||
Example prototype of a callback function that may be sent to
|
||||
Tux Paint's "line()" 'Magic' tool plugin helper function:
|
||||
|
|
@ -374,6 +375,12 @@ Interfaces
|
|||
void exampleCallBack(void * ptr_to_api, int which_tool,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
|
||||
Example use of the "line()" helper (e.g., within a plugin's
|
||||
draw() function):
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy, x, y,
|
||||
1, exampleCallBack);
|
||||
|
||||
* Uint8 touched(int x, int y)
|
||||
This function allows you to avoid re-processing the same pixels
|
||||
multiple times when the user drags the mouse across an area of
|
||||
|
|
@ -424,6 +431,11 @@ Interfaces
|
|||
should be placed for the installed version of Tux Paint to find
|
||||
them. (See "Installing," below.)
|
||||
|
||||
Note: If your plugin is installed locally (e.g., in your
|
||||
"~/.tuxpaint/plugins/" directory), rather than globally
|
||||
(system-wide), the "data_directory" value will be different.
|
||||
(e.g., "/home/username/.tuxpaint/plugins/data/").
|
||||
|
||||
Tux Paint System Calls
|
||||
|
||||
* void show_progress_bar(void)
|
||||
|
|
@ -660,6 +672,10 @@ Installing
|
|||
by this command will be the global location where the installed copy
|
||||
of Tux Paint looks for plugins (e.g., "/usr/lib/tuxpaint/plugins").
|
||||
|
||||
Alternatively, you may use "tp-magic-config --localpluginprefix" to
|
||||
find out where Tux Paint expects to find local plugins for the
|
||||
current user (e.g., "/home/username/.tuxpaint/plugins").
|
||||
|
||||
As stand-alone commands, using the BASH shell, for example:
|
||||
|
||||
# cp my_plugin.so `tp-magic-config --pluginprefix`
|
||||
|
|
@ -689,6 +705,8 @@ Installing
|
|||
|
||||
Note: See the note above regarding the "`" (grave) character.
|
||||
|
||||
Note: Currently, there is no "--localplugindocprefix" option.
|
||||
|
||||
Icons, Sounds and other Data Files
|
||||
|
||||
Use the "tp-magic-config --dataprefix" command, supplied as part of
|
||||
|
|
@ -696,7 +714,13 @@ Installing
|
|||
effects, etc.) should be installed. The value returned by this
|
||||
command will be the same as the value of the "data_directory" string
|
||||
stored within the "magic_api" structure that your plugin's functions
|
||||
receive.
|
||||
receive (e.g., "/usr/share/tuxpaint/").
|
||||
|
||||
For locally-installed plugins (for the current user only), use
|
||||
"tp-magic-config --localdataprefix". It will return the value of
|
||||
"data_directory" string that locally-installed plugins will see
|
||||
within their "magic_api" structure (e.g.,
|
||||
"/home/username/.tuxpaint/plugins/data/").
|
||||
|
||||
Note: Tux Paint's default Magic tool plugins install their data
|
||||
within "magic" subdirectories of Tux Paint's "images" and "sounds"
|
||||
|
|
@ -764,6 +788,9 @@ Installing
|
|||
(".html" and ".txt" files) within Tux Paint's documentation
|
||||
directory.
|
||||
|
||||
Note: The above Makefile example assumes the user will have
|
||||
priveleges to install Tux Paint plugins system-wide.
|
||||
|
||||
Windows
|
||||
|
||||
TBD
|
||||
|
|
@ -864,18 +891,22 @@ Glossary
|
|||
"int i;". Later, "&i" refers to the memory where "i" is stored, not
|
||||
the value of "i" itself; it is a 'pointer to "i"'.)
|
||||
* API: Application Programming Interface. TBD
|
||||
* argument: TBD
|
||||
* argument: A value sent to a function.
|
||||
* arrow: "->". A symbol in C that references an element within a pointer
|
||||
to a struct.
|
||||
* backquote: See "grave."
|
||||
* backtick: See "grave."
|
||||
* blue: See "RGBA"
|
||||
* boolean 'or': TBD
|
||||
* boolean 'or': A mathematical operation that results in a true value if
|
||||
either operand is true. ("1 | 0", "0 | 1" and "1 | 1" all result in
|
||||
"1". "0 | 0" results in "0".)
|
||||
* |: See "boolean 'or'"
|
||||
* .: See "dot"
|
||||
* `: See "grave."
|
||||
* *: See "star"
|
||||
* byte: TBD
|
||||
* byte: A unit of memory made up of 8 bits. As a signed value, it can
|
||||
represent -128 through 127. As an unsigned value, it can represent 0
|
||||
through 255.
|
||||
* callback: TBD
|
||||
* C enumeration: TBD
|
||||
* C function: TBD
|
||||
|
|
@ -894,7 +925,8 @@ Glossary
|
|||
"#define RADIUS 16"; all instances of "RADIUS" will be replaced with
|
||||
"16"), but can also be used to create macros. Typically placed within
|
||||
C header files.
|
||||
* dimensions: TBD
|
||||
* dimensions: The size of an object, in terms of its width (left to
|
||||
right) and height (top to bottom).
|
||||
* .dll: See "Shared Object"
|
||||
* dot: ".". A symbol in C that references an element within a struct.
|
||||
* drag: The action of moving a mouse while the button remains held.
|
||||
|
|
@ -904,11 +936,15 @@ Glossary
|
|||
* enum: See "C enumeration"
|
||||
* float: See "floating point"
|
||||
* floating point: TBD
|
||||
* format: TBD
|
||||
* format: An SDL_Surface element (a pointer to an SDL_PixelFormat
|
||||
structure) that contains information about a surface; for example, the
|
||||
number of bits used to represent each pixel). (See also the
|
||||
"SDL_PixelFormat(3) man page)
|
||||
* free(): A C function that frees (deallocates) memory allocated by
|
||||
other C functions (such as "strdup()").
|
||||
* function: See "C function"
|
||||
* gcc: TBD (See also the "gcc(1)" man page)
|
||||
* gcc: The GNU C compiler, a portable Open Source compiler. (See also
|
||||
the "gcc(1)" man page)
|
||||
* GNU C Compiler: See "gcc"
|
||||
* grave: The "`" character; used by the BASH shell to use the output of
|
||||
a command as the command-line arguments to another.
|
||||
|
|
@ -930,8 +966,13 @@ Glossary
|
|||
* macro: TBD
|
||||
* magic_api: A C structure that is passed along to a plugin's functions
|
||||
that exposes data and functions within the running copy of Tux Paint.
|
||||
* make: TBD
|
||||
* Makefile: TBD
|
||||
* make: A utility that automatically determines which pieces of a larger
|
||||
program need to be recompiled, and issues the commands to recompile
|
||||
them. (See also "Makefile")
|
||||
* Makefile: A text file used by the "make" utility; it describes the
|
||||
relationships among files in your program, and the commands for
|
||||
updating each file. (For example, to compile a human-readable
|
||||
source-code file into a computer-readable executable program file.)
|
||||
* Magic tool: One of a number of effects or drawing tools in Tux Paint,
|
||||
made available via the "Magic" tool button.
|
||||
* Mix_Chunk *: (A pointer to) a C structure defined by SDL_mixer that
|
||||
|
|
@ -944,7 +985,12 @@ Glossary
|
|||
* OGG: See "Ogg Vorbis"
|
||||
* Ogg Vorbis: TBD (See also: "WAV")
|
||||
* Plugin: TBD
|
||||
* PNG: TBD (See also the "png(5) man page)
|
||||
* PNG: Portable Network Graphics. An extensible file format for the
|
||||
lossless, portable, well-compressed storage of raster images. It's the
|
||||
file format Tux Paint uses to save images, and for its brushes and
|
||||
stamps. It's an easy way to store 32bpp RGBA images (24bpp true color
|
||||
with full 8bpp alpha transparency), excellent for use in graphics
|
||||
programs like Tux Paint. (See also the "png(5) man page)
|
||||
* pointer: See "C pointer"
|
||||
* red: See "RGBA"
|
||||
* release: The action of releasing a button on a mouse.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ New Breed Software</p>
|
|||
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
||||
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a></p>
|
||||
|
||||
<p>July 5, 2007 - August 2, 2007</p>
|
||||
<p>July 5, 2007 - August 7, 2007</p>
|
||||
</center>
|
||||
|
||||
<hr size=2 noshade>
|
||||
|
|
@ -41,51 +41,51 @@ concept.)</p>
|
|||
<h2>Table of Contents</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="prereq">Prequisites</a>
|
||||
<li><a href="interfaces">Interfaces</a>
|
||||
<li><a href="#prereqs">Prequisites</a>
|
||||
<li><a href="#interfaces">Interfaces</a>
|
||||
<ul>
|
||||
<li><a href="#">'Magic' tool plugin functions</a>
|
||||
<li><a href="#magic_plugin_funcs">'Magic' tool plugin functions</a>
|
||||
<ul>
|
||||
<li><a href="#">Common arguments to plugin functions</a>
|
||||
<li><a href="#">Required Plugin Functions</a>
|
||||
<li><a href="#common_args">Common arguments to plugin functions</a>
|
||||
<li><a href="#toolfuncs">Required Plugin Functions</a>
|
||||
<ul>
|
||||
<li><a href="#">Plugin "housekeeping" functions</a>
|
||||
<li><a href="#">Plugin event functions</a>
|
||||
<li><a href="#housekeeping">Plugin "housekeeping" functions</a>
|
||||
<li><a href="#eventfuncs">Plugin event functions</a>
|
||||
</ul>
|
||||
</ul>
|
||||
<li><a href="#tpfuncs">Tux Paint Functions and Data</a>
|
||||
<ul>
|
||||
<li><a href="#">Pixel Manipulations</a>
|
||||
<li><a href="#">Helper Functions</a>
|
||||
<li><a href="#">Informational</a>
|
||||
<li><a href="#">Tux Paint System Calls</a>
|
||||
<li><a href="#">Color Conversions</a>
|
||||
<li><a href="#pixel_manip">Pixel Manipulations</a>
|
||||
<li><a href="#helper_funcs">Helper Functions</a>
|
||||
<li><a href="#informational">Informational</a>
|
||||
<li><a href="#syscalls">Tux Paint System Calls</a>
|
||||
<li><a href="#color_convs">Color Conversions</a>
|
||||
</ul>
|
||||
<li><a href="#">Helper Macros in "tp_magic_api.h"</a>
|
||||
<li><a href="#">Constant Definitions in "tp_magic_api.h"</a>
|
||||
<li><a href="#macros">Helper Macros in "tp_magic_api.h"</a>
|
||||
<li><a href="#consts">Constant Definitions in "tp_magic_api.h"</a>
|
||||
</ul>
|
||||
<li><a href="#compiling">Compiling</a>
|
||||
<ul>
|
||||
<li><a href="#">Linux and other Unix-like Platforms</a>
|
||||
<li><a href="#">Windows</a>
|
||||
<li><a href="#">Mac OS X</a>
|
||||
<li><a href="#compiling-linux">Linux and other Unix-like Platforms</a>
|
||||
<li><a href="#compiling-windows">Windows</a>
|
||||
<li><a href="#compiling-osx">Mac OS X</a>
|
||||
</ul>
|
||||
<li><a href="#installing">Installing</a>
|
||||
<ul>
|
||||
<li><a href="#">Linux and other Unix-like Platforms</a>
|
||||
<li><a href="#">Windows</a>
|
||||
<li><a href="#">Mac OS X</a>
|
||||
<li><a href="#installing-linux">Linux and other Unix-like Platforms</a>
|
||||
<li><a href="#installing-windows">Windows</a>
|
||||
<li><a href="#installing-osx">Mac OS X</a>
|
||||
</ul>
|
||||
<li><a href="#multiple">Creating plugins with multiple effects</a>
|
||||
<li><a href="#">Example Code</a>
|
||||
<li><a href="#">Getting Help</a>
|
||||
<li><a href="#examples">Example Code</a>
|
||||
<li><a href="#help">Getting Help</a>
|
||||
<li><a href="#glossary">Glossary</a>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr size=1 noshade>
|
||||
|
||||
<h2><a name="prereq">Prerequisites</a></h2>
|
||||
<h2><a name="prereqs">Prerequisites</a></h2>
|
||||
|
||||
<blockquote>
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ recommended, but some basic SDL concepts will be covered in this document.</p>
|
|||
|
||||
<hr size=1 noshade>
|
||||
|
||||
<h2>Interfaces</h2>
|
||||
<h2><a name="interfaces">Interfaces</a></h2>
|
||||
|
||||
<blockquote>
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ plugin header file, as well as SDL's header files) for building a plugin.
|
|||
with Tux Paint — or in some cases, as part of a "Tux Paint
|
||||
'Magic' Tool Plugin Development package".</p>
|
||||
|
||||
<h3>'Magic' tool plugin functions</h3>
|
||||
<h3><a name="magic_plugin_funcs">'Magic' tool plugin functions</a></h3>
|
||||
|
||||
<blockquote>
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ would have functions whose names begin with "<code>blur_</code>"). <i>This
|
|||
includes private functions</i> (ones not used by Tux Paint directly),
|
||||
unless you declare those as '<code>static</code>'.</p>
|
||||
|
||||
<h4>Common arguments to plugin functions:</h4>
|
||||
<h4><a name="common_args">Common arguments to plugin functions:</a></h4>
|
||||
|
||||
Here is a description of arguments that many of your plugin's functions
|
||||
will need to accept.
|
||||
|
|
@ -222,7 +222,7 @@ preceded by your plugin's filename. That is, if your plugin is called
|
|||
then the names of your functions must begin with "<code><b>zoom_</b></code>"
|
||||
(e.g., "<code>zoom_get_name(...)</code>").</p>
|
||||
|
||||
<h5>Plugin "housekeeping" functions:</h5>
|
||||
<h5><a name="housekeeping">Plugin "housekeeping" functions:</a></h5>
|
||||
|
||||
<ul>
|
||||
<li><code><b>Uint32 api_version(void)</b></code><br>
|
||||
|
|
@ -316,7 +316,7 @@ then the names of your functions must begin with "<code><b>zoom_</b></code>"
|
|||
|
||||
</ul>
|
||||
|
||||
<h5>Plugin event functions:</h5>
|
||||
<h5><a name="eventfuncs">Plugin event functions:</a></h5>
|
||||
|
||||
<ul>
|
||||
<li><code><b>void set_color(magic_api * api,
|
||||
|
|
@ -399,7 +399,7 @@ access via the "<code>magic_api</code>" structure, sent to all of the
|
|||
plugin's functions.
|
||||
(See "<a href="#toolfuncs">Required Plugin Functions</a>," above.)</p>
|
||||
|
||||
<h4>Pixel Manipulations</h4>
|
||||
<h4><a name="pixel_manip">Pixel Manipulations</a></h4>
|
||||
|
||||
<blockquote>
|
||||
|
||||
|
|
@ -434,7 +434,7 @@ plugin's functions.
|
|||
|
||||
</blockquote>
|
||||
|
||||
<h4>Helper Functions</h4>
|
||||
<h4><a name="helper_funcs">Helper Functions</a></h4>
|
||||
|
||||
<blockquote>
|
||||
|
||||
|
|
@ -447,8 +447,9 @@ plugin's functions.
|
|||
brush shape.<br>
|
||||
<br>
|
||||
|
||||
<li><code><b>void line(int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x1, int y1,
|
||||
<li><code><b>void line(void * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int x1, int y1,
|
||||
int x2, int y2, int step, FUNC callback)</b></code><br>
|
||||
This function calculates all points on a line between the coordinates
|
||||
(x1,y1) and (x2,y2). Every 'step' iterations, it calls the 'callback'
|
||||
|
|
@ -456,9 +457,9 @@ plugin's functions.
|
|||
<br>
|
||||
It sends the 'callback' function the (x,y) coordinates on the line,
|
||||
Tux Paint's "<code>magic_api</code>" struct (as a
|
||||
"<code>void *</code>" pointer), a 'which' value, represening which
|
||||
of the plugin's 'Magic' tool is being used, and the current and snapshot
|
||||
canvases.<br>
|
||||
"<code>void *</code>" pointer which you need to send to it),
|
||||
a 'which' value, represening which of the plugin's 'Magic' tool is
|
||||
being used, and the current and snapshot canvases.<br>
|
||||
<br>
|
||||
Example prototype of a callback function that may be sent to
|
||||
Tux Paint's "<code>line()</code>" 'Magic' tool plugin helper function:
|
||||
|
|
@ -468,6 +469,13 @@ plugin's functions.
|
|||
int x, int y);
|
||||
</code></blockquote>
|
||||
<br>
|
||||
Example use of the "<code>line()</code>" helper (e.g., within a plugin's
|
||||
<code>draw()</code> function):
|
||||
<blockquote><code>
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy,
|
||||
x, y, 1, exampleCallBack);
|
||||
</code></blockquote>
|
||||
<br>
|
||||
|
||||
<li><code><b>Uint8 touched(int x, int y)</b></code><br>
|
||||
This function allows you to avoid re-processing the same pixels multiple
|
||||
|
|
@ -496,7 +504,7 @@ plugin's functions.
|
|||
|
||||
</blockquote>
|
||||
|
||||
<h4>Informational</h4>
|
||||
<h4><a name="informational">Informational</a></h4>
|
||||
|
||||
<blockquote>
|
||||
|
||||
|
|
@ -532,12 +540,17 @@ plugin's functions.
|
|||
placed for the installed version of Tux Paint to find them.
|
||||
(See "<a href="#installing">Installing</a>," below.)<br>
|
||||
<br>
|
||||
<b>Note:</b> If your plugin is installed locally (e.g., in your
|
||||
"<code>~/.tuxpaint/plugins/</code>" directory), rather than globally
|
||||
(system-wide), the "<code>data_directory</code>" value will be different.
|
||||
(e.g., "<code>/home/<i>username</i>/.tuxpaint/plugins/data/</code>").<br>
|
||||
<br>
|
||||
|
||||
</ul>
|
||||
|
||||
</blockquote>
|
||||
|
||||
<h4>Tux Paint System Calls</h4>
|
||||
<h4><a name="syscalls">Tux Paint System Calls</a></h4>
|
||||
|
||||
<blockquote>
|
||||
<ul>
|
||||
|
|
@ -589,7 +602,7 @@ plugin's functions.
|
|||
</ul>
|
||||
</blockquote>
|
||||
|
||||
<h4>Color Conversions</h4>
|
||||
<h4><a name="color_convs">Color Conversions</a></h4>
|
||||
|
||||
<blockquote>
|
||||
<ul>
|
||||
|
|
@ -629,7 +642,7 @@ plugin's functions.
|
|||
</blockquote>
|
||||
</blockquote>
|
||||
|
||||
<h3>Helper Macros in "<code>tp_magic_api.h</code>":</h3>
|
||||
<h3><a name="macros">Helper Macros in "<code>tp_magic_api.h</code>":</a></h3>
|
||||
|
||||
<blockquote>
|
||||
<p>Along with the "<code>magic_api</code>" C structure containing functions
|
||||
|
|
@ -664,7 +677,7 @@ also contains some helper macros that you may use.</p>
|
|||
|
||||
</blockquote>
|
||||
|
||||
<h3>Constant Defintions in "<code>tp_magic_api.h</code>":</h3>
|
||||
<h3><a name="consts">Constant Defintions in "<code>tp_magic_api.h</code>":</a></h3>
|
||||
|
||||
<blockquote>
|
||||
<p>The following is a summary of constant values that are set
|
||||
|
|
@ -704,7 +717,7 @@ also contains some helper macros that you may use.</p>
|
|||
|
||||
<blockquote>
|
||||
|
||||
<h3>Linux and other Unix-like Platforms</h3>
|
||||
<h3><a name="compiling-linux">Linux and other Unix-like Platforms</a></h3>
|
||||
|
||||
<blockquote>
|
||||
|
||||
|
|
@ -824,13 +837,13 @@ also contains some helper macros that you may use.</p>
|
|||
|
||||
</blockquote>
|
||||
|
||||
<h3>Windows</h3>
|
||||
<h3><a name="compiling-windows">Windows</a></h3>
|
||||
|
||||
<blockquote>
|
||||
<p>TBD</p>
|
||||
</blockquote>
|
||||
|
||||
<h3>Mac OS X</h3>
|
||||
<h3><a name="compiling-osx">Mac OS X</a></h3>
|
||||
|
||||
<blockquote>
|
||||
<p>TBD</p>
|
||||
|
|
@ -844,7 +857,7 @@ also contains some helper macros that you may use.</p>
|
|||
|
||||
<blockquote>
|
||||
|
||||
<h3>Linux and other Unix-like Platforms</h3>
|
||||
<h3><a name="installing-linux">Linux and other Unix-like Platforms</a></h3>
|
||||
|
||||
<blockquote>
|
||||
<p>Use the "<code>tp-magic-config</code>" command-line tool, supplied as
|
||||
|
|
@ -862,6 +875,11 @@ also contains some helper macros that you may use.</p>
|
|||
the global location where the installed copy of Tux Paint looks
|
||||
for plugins (e.g., "<code>/usr/lib/tuxpaint/plugins</code>").</p>
|
||||
|
||||
<p>Alternatively, you may use
|
||||
"<code>tp-magic-config --localpluginprefix</code>" to find out where
|
||||
Tux Paint expects to find local plugins for the current user (e.g.,
|
||||
"<code>/home/<i>username</i>/.tuxpaint/plugins</code>").</p>
|
||||
|
||||
<p>As stand-alone commands, using the BASH shell, for example:</p>
|
||||
|
||||
<blockquote>
|
||||
|
|
@ -904,6 +922,9 @@ also contains some helper macros that you may use.</p>
|
|||
<p><b>Note:</b> See the <a href="#grave">note above regarding the
|
||||
"<font size=+1><b>`</b></font>" (grave) character</a>.</p>
|
||||
|
||||
<p><b>Note:</b> Currently, there is no "<code>--localplugindocprefix</code>"
|
||||
option.</p>
|
||||
|
||||
</blockquote>
|
||||
|
||||
<h4>Icons, Sounds and other Data Files</h4>
|
||||
|
|
@ -915,7 +936,14 @@ also contains some helper macros that you may use.</p>
|
|||
(PNG icon, Ogg Vorbis sound effects, etc.) should be installed.
|
||||
The value returned by this command will be the same as the value of the
|
||||
"<code>data_directory</code>" string stored within the
|
||||
"<code>magic_api</code>" structure that your plugin's functions receive.</p>
|
||||
"<code>magic_api</code>" structure that your plugin's functions receive
|
||||
(e.g., "<code>/usr/share/tuxpaint/</code>").</p>
|
||||
|
||||
<p>For locally-installed plugins (for the current user only), use
|
||||
"<code>tp-magic-config --localdataprefix</code>". It will return the
|
||||
value of "<code>data_directory</code>" string that locally-installed
|
||||
plugins will see within their "<code>magic_api</code>" structure
|
||||
(e.g., "<code>/home/<i>username</i>/.tuxpaint/plugins/data/</code>").</p>
|
||||
|
||||
<p><b>Note:</b> Tux Paint's default Magic tool plugins install their
|
||||
data within "<code>magic</code>" subdirectories of Tux Paint's
|
||||
|
|
@ -997,16 +1025,19 @@ also contains some helper macros that you may use.</p>
|
|||
("<code>.html</code>" and "<code>.txt</code>" files) within Tux Paint's
|
||||
documentation directory.</p>
|
||||
|
||||
<p><b>Note:</b> The above Makefile example assumes the user will have
|
||||
priveleges to install Tux Paint plugins system-wide.</p>
|
||||
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
|
||||
<h3>Windows</h3>
|
||||
<h3><a name="installing-windows">Windows</a></h3>
|
||||
|
||||
<blockquote>
|
||||
<p>TBD</p>
|
||||
</blockquote>
|
||||
|
||||
<h3>Mac OS X</h3>
|
||||
<h3><a name="installing-osx">Mac OS X</a></h3>
|
||||
|
||||
<blockquote>
|
||||
<p>TBD</p>
|
||||
|
|
@ -1092,7 +1123,7 @@ simply be '1', your arrays will be of length '1', etc.)</p>
|
|||
|
||||
<hr size=1 noshade>
|
||||
|
||||
<h2>Example Code</h2>
|
||||
<h2><a name="examples">Example Code</a></h2>
|
||||
|
||||
<blockquote>
|
||||
<p>The C source file
|
||||
|
|
@ -1102,7 +1133,7 @@ simply be '1', your arrays will be of length '1', etc.)</p>
|
|||
|
||||
<hr size=1 noshade>
|
||||
|
||||
<h2>Getting Help</h2>
|
||||
<h2><a name="help">Getting Help</a></h2>
|
||||
|
||||
<blockquote>
|
||||
|
||||
|
|
@ -1127,17 +1158,17 @@ mailing lists:
|
|||
<li><b>&:</b> See "ampersand"
|
||||
<li><b>ampersand:</b> "<code>&</code>". A symbol in C that allows you to refer to the memory address of a variable; that is, a pointer. (For example, consider "<code>int i;</code>". Later, "<code>&i</code>" refers to the memory where "<code>i</code>" is stored, not the value of "<code>i</code>" itself; it is a 'pointer to "<code>i</code>"'.)
|
||||
<li><b>API:</b> Application Programming Interface. <i>TBD</i>
|
||||
<li><b>argument:</b> <i>TBD</i>
|
||||
<li><b>argument:</b> A value sent to a function.
|
||||
<li><b>arrow:</b> "<code>-></code>". A symbol in C that references an element within a pointer to a struct.
|
||||
<li><b>backquote:</b> See "grave."
|
||||
<li><b>backtick:</b> See "grave."
|
||||
<li><b>blue:</b> See "RGBA"
|
||||
<li><b>boolean 'or':</b> <i>TBD</i>
|
||||
<li><b>boolean 'or':</b> A mathematical operation that results in a true value if either operand is true. ("1 | 0", "0 | 1" and "1 | 1" all result in "1". "0 | 0" results in "0".)
|
||||
<li><b>|:</b> See "boolean 'or'"
|
||||
<li><b>.:</b> See "dot"
|
||||
<li><b>`:</b> See "grave."
|
||||
<li><b>*:</b> See "star"
|
||||
<li><b>byte:</b> <i>TBD</i>
|
||||
<li><b>byte:</b> A unit of memory made up of 8 bits. As a signed value, it can represent -128 through 127. As an unsigned value, it can represent 0 through 255.
|
||||
<li><b>callback:</b> <i>TBD</i>
|
||||
<li><b>C enumeration:</b> <i>TBD</i>
|
||||
<li><b>C function:</b> <i>TBD</i>
|
||||
|
|
@ -1148,7 +1179,7 @@ mailing lists:
|
|||
<li><b>C pointer:</b> A variable that contains the location of a piece of memory; usually used to 'point' to another variable. Since C functions can only return one value as a result, pointers are often sent to functions to allow the function to change the values of multiple variables. (For example, Tux Paint's "<code>rgbtohsv()</code>" and "<code>hsvtorgb()</code>".)
|
||||
<li><b>C structure:</b> <i>TBD</i>
|
||||
<li><b>#define:</b> A C statement that defines a substitution that can occur later in the code. Generally used for constant values (e.g., "<code>#define RADIUS 16</code>"; all instances of "<code>RADIUS</code>" will be replaced with "<code>16</code>"), but can also be used to create macros. Typically placed within C header files.
|
||||
<li><b>dimensions:</b> <i>TBD</i>
|
||||
<li><b>dimensions:</b> The size of an object, in terms of its width (left to right) and height (top to bottom).
|
||||
<li><b>.dll:</b> See "Shared Object"
|
||||
<li><b>dot:</b> "<code>.</code>". A symbol in C that references an element within a struct.
|
||||
<li><b>drag:</b> The action of moving a mouse while the button remains held.
|
||||
|
|
@ -1156,10 +1187,10 @@ mailing lists:
|
|||
<li><b>enum:</b> See "C enumeration"
|
||||
<li><b>float:</b> See "floating point"
|
||||
<li><b>floating point:</b> <i>TBD</i>
|
||||
<li><b>format:</b> <i>TBD</i>
|
||||
<li><b>format:</b> An <code>SDL_Surface</code> element (a pointer to an <code>SDL_PixelFormat</code> structure) that contains information about a surface; for example, the number of bits used to represent each pixel). (See also the "<code>SDL_PixelFormat(3)</code> <i>man page</i>)
|
||||
<li><b>free():</b> A C function that frees (deallocates) memory allocated by other C functions (such as "<code>strdup()</code>").
|
||||
<li><b>function:</b> See "C function"
|
||||
<li><b>gcc:</b> <i>TBD</i> (See also the "<code>gcc(1)</code>" <i>man page</i>)
|
||||
<li><b>gcc:</b> The GNU C compiler, a portable Open Source compiler. (See also the "<code>gcc(1)</code>" <i>man page</i>)
|
||||
<li><b>GNU C Compiler:</b> See "gcc"
|
||||
<li><b>grave:</b> The "<code><font size=+1>`</font></code>" character; used by the BASH shell to use the output of a command as the command-line arguments to another.
|
||||
<li><b>green:</b> See "RGBA"
|
||||
|
|
@ -1177,8 +1208,8 @@ mailing lists:
|
|||
<li><b>linear:</b> <i>TBD</i>
|
||||
<li><b>macro:</b> <i>TBD</i>
|
||||
<li><b>magic_api:</b> A C structure that is passed along to a plugin's functions that exposes data and functions within the running copy of Tux Paint.
|
||||
<li><b>make:</b> <i>TBD</i>
|
||||
<li><b>Makefile:</b> <i>TBD</i>
|
||||
<li><b>make:</b> A utility that automatically determines which pieces of a larger program need to be recompiled, and issues the commands to recompile them. (See also "Makefile")
|
||||
<li><b>Makefile:</b> A text file used by the "make" utility; it describes the relationships among files in your program, and the commands for updating each file. (For example, to compile a human-readable source-code file into a computer-readable executable program file.)
|
||||
<li><b>Magic tool</b>: One of a number of effects or drawing tools in Tux Paint, made available via the "Magic" tool button.
|
||||
<li><b>Mix_Chunk *:</b> (A pointer to) a C structure defined by SDL_mixer that contains a sound.
|
||||
<li><b>Mix_FreeChunk():</b> An SDL_mixer function that frees (deallocates) memory allocated for an SDL_mixer sound 'chunk' ("<code>Mix_Chunk *</code>").
|
||||
|
|
@ -1187,7 +1218,7 @@ mailing lists:
|
|||
<li><b>OGG</b>: See "Ogg Vorbis"
|
||||
<li><b>Ogg Vorbis:</b> <i>TBD</i> (See also: "WAV")
|
||||
<li><b>Plugin</b>: <i>TBD</i>
|
||||
<li><b>PNG:</b> <i>TBD</i> (See also the "<code>png(5)</code> <i>man page</i>)
|
||||
<li><b>PNG:</b> Portable Network Graphics. An extensible file format for the lossless, portable, well-compressed storage of raster images. It's the file format Tux Paint uses to save images, and for its brushes and stamps. It's an easy way to store 32bpp RGBA images (24bpp true color with full 8bpp alpha transparency), excellent for use in graphics programs like Tux Paint. (See also the "<code>png(5)</code> <i>man page</i>)
|
||||
<li><b>pointer:</b> See "C pointer"
|
||||
<li><b>red:</b> See "RGBA"
|
||||
<li><b>release:</b> The action of releasing a button on a mouse.
|
||||
|
|
|
|||
|
|
@ -146,9 +146,10 @@ int example_init(magic_api * api)
|
|||
// we installed our plugin and its data.)
|
||||
|
||||
snprintf(fname, sizeof(fname),
|
||||
"%s/sounds/magic/%s.wav",
|
||||
"%s/sounds/magic/%s",
|
||||
api->data_directory, snd_filenames[i]);
|
||||
|
||||
printf("Trying to load %s sound file\n", fname);
|
||||
|
||||
// Try to load the file!
|
||||
|
||||
|
|
@ -334,7 +335,8 @@ void example_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
// useful things (which of our "Magic" tools is being used and
|
||||
// the current and snapshot canvases).
|
||||
|
||||
api->line(which, canvas, snapshot, ox, oy, x, y, 1, example_line_callback);
|
||||
api->line((void *) api, which, canvas, snapshot,
|
||||
ox, oy, x, y, 1, example_line_callback);
|
||||
|
||||
|
||||
// If we need to, swap the X and/or Y values, so that
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
blocks_chalk_drip.c
|
||||
|
||||
Blocks, Chalk and Drip Magic Tools Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -217,7 +246,7 @@ void blocks_chalk_drip_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, blocks_chalk_drip_linecb);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, blocks_chalk_drip_linecb);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,34 @@
|
|||
/*
|
||||
blur.c
|
||||
|
||||
Blur Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
Major improvements by Albert Cahalan <albert@users.sf.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -130,7 +161,7 @@ void blur_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_blur);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_blur);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,34 @@
|
|||
/*
|
||||
bricks.c
|
||||
|
||||
Bricks Magic Tools Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Albert Cahalan <albert@users.sf.net>
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -179,7 +210,7 @@ void bricks_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_bricks);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_bricks);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
cartoon.c
|
||||
|
||||
Cartoon Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -148,7 +177,7 @@ void cartoon_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_cartoon);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_cartoon);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
emboss.c
|
||||
|
||||
Emboss Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -18,7 +47,7 @@ int emboss_init(magic_api * api)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/emboss.wav",
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/emboss.ogg",
|
||||
api->data_directory);
|
||||
emboss_snd = Mix_LoadWAV(fname);
|
||||
|
||||
|
|
@ -104,7 +133,7 @@ void emboss_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_emboss);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_emboss);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
@ -115,7 +144,7 @@ void emboss_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
update_rect->h = (y + 16) - update_rect->h;
|
||||
|
||||
api->playsound(emboss_snd,
|
||||
(x * 255) / canvas->w, (y * 255) / canvas->h);
|
||||
(x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
||||
// Affect the canvas on click:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
fade_darken.c
|
||||
|
||||
Fade and Darken Magic Tools Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -125,7 +154,7 @@ void fade_darken_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_LockSurface(last);
|
||||
SDL_LockSurface(canvas);
|
||||
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_fade_darken);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_fade_darken);
|
||||
|
||||
SDL_UnlockSurface(canvas);
|
||||
SDL_UnlockSurface(last);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,36 @@
|
|||
/*
|
||||
fill.c
|
||||
|
||||
Fill Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
Flood fill code based on Wikipedia example:
|
||||
http://www.wikipedia.org/wiki/Flood_fill/C_example
|
||||
by Damian Yerrick - http://www.wikipedia.org/wiki/Damian_Yerrick
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
flower.c
|
||||
|
||||
Flower Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -13,7 +42,7 @@ enum { LEAFSIDE_RIGHT_DOWN,
|
|||
LEAFSIDE_RIGHT_UP,
|
||||
LEAFSIDE_LEFT_UP };
|
||||
|
||||
Mix_Chunk * flower_snd;
|
||||
Mix_Chunk * flower_click_snd, * flower_release_snd;
|
||||
Uint8 flower_r, flower_g, flower_b;
|
||||
int flower_min_x, flower_max_x, flower_bottom_x, flower_bottom_y;
|
||||
int flower_side_first;
|
||||
|
|
@ -49,9 +78,13 @@ int flower_init(magic_api * api)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/flower.wav",
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/flower_click.ogg",
|
||||
api->data_directory);
|
||||
flower_snd = Mix_LoadWAV(fname);
|
||||
flower_click_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/flower_release.ogg",
|
||||
api->data_directory);
|
||||
flower_release_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/images/magic/flower_base.png",
|
||||
api->data_directory);
|
||||
|
|
@ -172,6 +205,8 @@ void flower_click(magic_api * api, int which,
|
|||
flower_side_first = SIDE_LEFT;
|
||||
|
||||
flower_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
||||
api->playsound(flower_click_snd, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
||||
// Affect the canvas on release:
|
||||
|
|
@ -211,7 +246,7 @@ void flower_release(magic_api * api, int which,
|
|||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
|
||||
api->playsound(flower_snd, (x * 255) / canvas->w, 255); /* FIXME: Distance? */
|
||||
api->playsound(flower_release_snd, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -410,8 +445,11 @@ void flower_drawstalk(magic_api * api, SDL_Surface * canvas,
|
|||
|
||||
void flower_shutdown(magic_api * api)
|
||||
{
|
||||
if (flower_snd != NULL)
|
||||
Mix_FreeChunk(flower_snd);
|
||||
if (flower_click_snd != NULL)
|
||||
Mix_FreeChunk(flower_click_snd);
|
||||
|
||||
if (flower_release_snd != NULL)
|
||||
Mix_FreeChunk(flower_release_snd);
|
||||
|
||||
if (flower_base != NULL)
|
||||
SDL_FreeSurface(flower_base);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
foam.c
|
||||
|
||||
Foam Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -30,7 +59,7 @@ int foam_init(magic_api * api)
|
|||
char fname[1024];
|
||||
SDL_Surface * foam_data;
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/foam.wav",
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/foam.ogg",
|
||||
api->data_directory);
|
||||
foam_snd = Mix_LoadWAV(fname);
|
||||
|
||||
|
|
@ -115,7 +144,7 @@ void foam_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_foam);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_foam);
|
||||
|
||||
foam_release(api, which, canvas, last, x, y, update_rect);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
glasstile.c
|
||||
|
||||
Glass Tile Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -21,7 +50,7 @@ int glasstile_init(magic_api * api)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/glasstile.wav",
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/glasstile.ogg",
|
||||
api->data_directory);
|
||||
glasstile_snd = Mix_LoadWAV(fname);
|
||||
|
||||
|
|
@ -157,7 +186,7 @@ void glasstile_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_glasstile);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_glasstile);
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,33 @@
|
|||
/*
|
||||
grass.c
|
||||
|
||||
Grass Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
by Albert Cahalan <albert@users.sf.net>
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -74,7 +104,7 @@ void grass_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 4, do_grass);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 4, do_grass);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
kalidescope.c
|
||||
|
||||
Kaleidoscope Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -89,7 +118,7 @@ void kalidescope_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_kalidescope);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_kalidescope);
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
metalpaint.c
|
||||
|
||||
Metal Paint Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -96,7 +125,7 @@ void metalpaint_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_metalpaint);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_metalpaint);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
mirror_flip.c
|
||||
|
||||
Mirror and Flip Magic Tools Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
negative.c
|
||||
|
||||
Negative Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -86,7 +115,7 @@ void negative_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_LockSurface(last);
|
||||
SDL_LockSurface(canvas);
|
||||
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_negative);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_negative);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
rainbow.c
|
||||
|
||||
Rainbow Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -118,7 +147,7 @@ void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
rainbow_hexes[rainbow_color][1],
|
||||
rainbow_hexes[rainbow_color][2]);
|
||||
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, rainbow_linecb);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, rainbow_linecb);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
ripples.c
|
||||
|
||||
Ripples Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -23,7 +52,7 @@ int ripples_init(magic_api * api)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/ripples.wav",
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/ripples.ogg",
|
||||
api->data_directory);
|
||||
ripples_snd = Mix_LoadWAV(fname);
|
||||
|
||||
|
|
@ -109,7 +138,7 @@ void ripples_click(magic_api * api, int which,
|
|||
|
||||
ripples_brite = (ripples_z * 20 * deg_sin(d + 45)) / ((fli / 4) + 1);
|
||||
|
||||
api->line(which, canvas, last, ox, oy, nx, ny, 1, ripples_linecb);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, nx, ny, 1, ripples_linecb);
|
||||
|
||||
ox = nx;
|
||||
oy = ny;
|
||||
|
|
@ -120,6 +149,8 @@ void ripples_click(magic_api * api, int which,
|
|||
update_rect->y = y - 100;
|
||||
update_rect->w = 200;
|
||||
update_rect->h = 200;
|
||||
|
||||
api->playsound(ripples_snd, (x * 255) / api->canvas_w, 255);
|
||||
}
|
||||
|
||||
// Affect the canvas on release:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,33 @@
|
|||
/*
|
||||
smudge.c
|
||||
|
||||
Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
by Albert Cahalan <albert@users.sf.net>
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -97,7 +127,7 @@ void smudge_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_smudge);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_smudge);
|
||||
|
||||
api->playsound(smudge_snd, (x * 255) / canvas->w, 255);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
sparkles.c
|
||||
|
||||
Sparkles Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -8,7 +37,7 @@
|
|||
|
||||
/* Our globals: */
|
||||
|
||||
Mix_Chunk * sparkles_snd;
|
||||
Mix_Chunk * sparkles1_snd, * sparkles2_snd;
|
||||
Uint8 sparkles_r, sparkles_g, sparkles_b;
|
||||
|
||||
|
||||
|
|
@ -20,9 +49,13 @@ int sparkles_init(magic_api * api)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/sparkles.wav",
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/sparkles1.wav",
|
||||
api->data_directory);
|
||||
sparkles_snd = Mix_LoadWAV(fname);
|
||||
sparkles1_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/sparkles2.wav",
|
||||
api->data_directory);
|
||||
sparkles2_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
|
@ -97,7 +130,7 @@ void sparkles_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_sparkles);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_sparkles);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
@ -107,7 +140,13 @@ void sparkles_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
update_rect->w = (x + 8) - update_rect->x;
|
||||
update_rect->h = (y + 8) - update_rect->h;
|
||||
|
||||
api->playsound(sparkles_snd, (x * 255) / canvas->w, 255);
|
||||
if ((rand() % 10) == 0)
|
||||
{
|
||||
if ((rand() % 10) < 5)
|
||||
api->playsound(sparkles1_snd, (x * 255) / canvas->w, 255);
|
||||
else
|
||||
api->playsound(sparkles2_snd, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
}
|
||||
|
||||
// Affect the canvas on click:
|
||||
|
|
@ -128,8 +167,10 @@ void sparkles_release(magic_api * api, int which,
|
|||
// No setup happened:
|
||||
void sparkles_shutdown(magic_api * api)
|
||||
{
|
||||
if (sparkles_snd != NULL)
|
||||
Mix_FreeChunk(sparkles_snd);
|
||||
if (sparkles1_snd != NULL)
|
||||
Mix_FreeChunk(sparkles1_snd);
|
||||
if (sparkles2_snd != NULL)
|
||||
Mix_FreeChunk(sparkles2_snd);
|
||||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
tint.c
|
||||
|
||||
Tint Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -101,7 +130,7 @@ void tint_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_tint);
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_tint);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
waves.c
|
||||
|
||||
Waves Magic Tool Plugin
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -105,6 +134,7 @@ void waves_release(magic_api * api, int which,
|
|||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
api->playsound(waves_snd, 128, 255);
|
||||
}
|
||||
|
||||
// No setup happened:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
.\" tp-magic-config - 2007.08.02
|
||||
.TH TP-MAGIC-CONFIG 1 "02 August 2007" "2007.08.02" "tp-magic-config"
|
||||
.\" tp-magic-config - 2007.08.07
|
||||
.TH TP-MAGIC-CONFIG 1 "07 August 2007" "2007.08.07" "tp-magic-config"
|
||||
.SH NAME
|
||||
tp-magic-config -- Helps creating 'Magic' tool plugins for Tux Paint(1)
|
||||
|
||||
.SH SYNOPSYS
|
||||
.TP 16
|
||||
.B tp-magic-config [\-\-apiversion | \-\-version | \-\-cflags | \-\-pluginprefix | \-\-plugindocprefix | \-\-dataprefix]
|
||||
.B tp-magic-config [\-\-apiversion | \-\-version | \-\-cflags | \-\-pluginprefix | \-\-plugindocprefix | \-\-dataprefix | \-\-localpluginprefix | \-\-localdataprefix]
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fItp-magic-config\fP is a simple shell script that responds with various
|
||||
|
|
@ -29,8 +29,14 @@ compiler where it can find the plugin API header file, "tp_magic_config.h",
|
|||
that plugins must #include.)
|
||||
.TP 8
|
||||
.B \-\-pluginprefix
|
||||
Outputs the directory where the installed copy of \fITux Paint\fP expects
|
||||
Outputs the system directory where the installed copy of \fITux Paint\fP expects
|
||||
to find 'Magic' tool plugins (".so" shared objects).
|
||||
(e.g., "/usr/share/tuxpaint/plugins")
|
||||
.TP 8
|
||||
.B \-\-localpluginprefix
|
||||
Outputs the user directory where the installed copy of \fITux Paint\fP expects
|
||||
to find 'Magic' tool plugins (".so" shared objects).
|
||||
(e.g., "/home/username/.tuxpaint/plugins")
|
||||
.TP 8
|
||||
.B \-\-plugindocprefix
|
||||
Outputs the directory where the installed copy of \fITux Paint\fP expects
|
||||
|
|
@ -39,12 +45,19 @@ to find documentation for 'Magic' tool plugins (".html" and ".txt" files).
|
|||
under the section on "Magic" tools.
|
||||
.TP 8
|
||||
.B \-\-dataprefix
|
||||
Outputs the directory where the installed copy of \fITux Paint\fP keeps its
|
||||
global data files (e.g., "/usr/share/tuxpaint/"). This is the same value that
|
||||
plugins will receive in the "data_directory" string within the
|
||||
"magic_api" structure sent to the plugins' functions.
|
||||
Outputs the system directory where the installed copy of \fITux Paint\fP keeps
|
||||
its global data files (e.g., "/usr/share/tuxpaint/"). This is the same value
|
||||
that plugins installed system-wide will receive in the "data_directory" string
|
||||
within the "magic_api" structure sent to the plugins' functions.
|
||||
.TP 8
|
||||
.B \-\-localdataprefix
|
||||
Outputs the user directory where the installed copy of \fITux Paint\fP
|
||||
expects plugins to install their local data files.
|
||||
(e.g., "/home/username/.tuxpaint/plugins/data"). This is the same value
|
||||
that plugins installed locally will receive in the "data_directory" string
|
||||
within the "magic_api" structure sent to the plugins' functions.
|
||||
|
||||
.SH SHELL EXAMPLES
|
||||
.SH SYSTEM-WIDE SHELL EXAMPLES
|
||||
$ gcc -shared `tp-magic-config --cflags` my_plugin.c -o my_plugin.so
|
||||
.br
|
||||
# cp my_plugin.so `tp-magic-config \-\-pluginprefix`
|
||||
|
|
@ -55,7 +68,18 @@ $ gcc -shared `tp-magic-config --cflags` my_plugin.c -o my_plugin.so
|
|||
.br
|
||||
# cp my_plugin.txt `tp-magic-config \-\-plugindocrefix`
|
||||
|
||||
.SH MAKEFILE EXAMPLE
|
||||
.SH LOCAL SHELL EXAMPLES
|
||||
$ gcc -shared `tp-magic-config --cflags` my_plugin.c -o my_plugin.so
|
||||
.br
|
||||
$ mkdir -p `tp-magic-config \-\-localpluginprefix`
|
||||
.br
|
||||
$ cp my_plugin.so `tp-magic-config \-\-localpluginprefix`
|
||||
.br
|
||||
$ mkdir -p `tp-magic-config \-\-localdataprefix`/images/magic
|
||||
.br
|
||||
$ cp my_plugin_icon.png `tp-magic-config \-\-localdataprefix`/images/magic
|
||||
|
||||
.SH SYSTEM-WIDE MAKEFILE EXAMPLE
|
||||
MAGIC_CFLAGS=$(shell tp-magic-config --cflags)
|
||||
.br
|
||||
MAGIC_PREFIX=$(shell tp-magic-config --pluginprefix)
|
||||
|
|
|
|||
|
|
@ -50,10 +50,18 @@ if [ $# -ne 0 ]; then
|
|||
echo "__DATAPREFIX__"
|
||||
exit
|
||||
fi
|
||||
if [ $1 = "--localdataprefix" ]; then
|
||||
echo "$HOME/.tuxpaint/plugins/data"
|
||||
exit
|
||||
fi
|
||||
if [ $1 = "--pluginprefix" ]; then
|
||||
echo "__PLUGINPREFIX__"
|
||||
exit
|
||||
fi
|
||||
if [ $1 = "--localpluginprefix" ]; then
|
||||
echo "$HOME/.tuxpaint/plugins"
|
||||
exit
|
||||
fi
|
||||
if [ $1 = "--plugindocprefix" ]; then
|
||||
echo "__PLUGINDOCPREFIX__"
|
||||
exit
|
||||
|
|
|
|||
|
|
@ -91,9 +91,10 @@ typedef struct magic_api_t {
|
|||
|
||||
/* Asks Tux Paint to calculate a line between (x1,y1) and (x2,y2);
|
||||
every 'step' iterations, it will call your callback function
|
||||
(which must accept a 'which' integer for which tool is being used,
|
||||
'last' and current ('canvas') SDL_Surfaces, and an (x,y) position) */
|
||||
void (*line)(int, SDL_Surface *, SDL_Surface *, int, int, int, int, int, void (*)(void *, int, SDL_Surface *, SDL_Surface *, int, int));
|
||||
(which must accept a 'magic_api *' Magic API pointer and 'which' integer
|
||||
for which tool is being used, the 'last' and current ('canvas')
|
||||
SDL_Surfaces, and an (x,y) position) */
|
||||
void (*line)(void *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, int, void (*)(void *, int, SDL_Surface *, SDL_Surface *, int, int));
|
||||
|
||||
/* Returns whether the mouse button is down */
|
||||
int (*button_down)(void);
|
||||
|
|
|
|||
131
src/tuxpaint.c
131
src/tuxpaint.c
|
|
@ -22,7 +22,7 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
June 14, 2002 - July 24, 2007
|
||||
June 14, 2002 - August 7, 2007
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
|
@ -880,6 +880,7 @@ typedef struct magic_funcs_s {
|
|||
|
||||
|
||||
typedef struct magic_s {
|
||||
int place;
|
||||
int handle_idx; // Index to magic funcs for each magic tool (shared objs may report more than 1 tool)
|
||||
int idx; // Index to magic tools within shared objects (shared objs may report more than 1 tool)
|
||||
int colors; // Whether magic tool accepts colors
|
||||
|
|
@ -899,7 +900,13 @@ magic_funcs_t magic_funcs[512]; // Pointer to shared objects' functions
|
|||
magic_t magics[512];
|
||||
static int num_magics; // How many magic tools were loaded (note: shared objs may report more than 1 tool)
|
||||
|
||||
magic_api * magic_api_struct; // Pointer to our internal functions; passed to shared object's functions when we call them
|
||||
enum {
|
||||
MAGIC_PLACE_GLOBAL,
|
||||
MAGIC_PLACE_LOCAL,
|
||||
NUM_MAGIC_PLACES
|
||||
};
|
||||
|
||||
magic_api * magic_api_struct[NUM_MAGIC_PLACES]; // Pointer to our internal functions; passed to shared object's functions when we call them
|
||||
|
||||
|
||||
#if !defined(WIN32) && !defined(__APPLE__) && !defined(__BEOS__)
|
||||
|
|
@ -1489,7 +1496,8 @@ int magic_sort(const void * a, const void * b);
|
|||
|
||||
Mix_Chunk * magic_current_snd_ptr;
|
||||
void magic_playsound(Mix_Chunk * snd, int left_right, int up_down);
|
||||
void magic_line_func(int which, SDL_Surface * canvas, SDL_Surface * last,
|
||||
void magic_line_func(void * mapi,
|
||||
int which, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x1, int y1, int x2, int y2, int step,
|
||||
void (*cb)(void *, int, SDL_Surface *, SDL_Surface *,
|
||||
int, int));
|
||||
|
|
@ -2401,7 +2409,7 @@ static void mainloop(void)
|
|||
draw_colors(magics[cur_magic].colors);
|
||||
if (magics[cur_magic].colors)
|
||||
magic_funcs[magics[cur_magic].handle_idx].set_color(
|
||||
magic_api_struct,
|
||||
magic_api_struct[magics[cur_magic].place],
|
||||
color_hexes[cur_color][0],
|
||||
color_hexes[cur_color][1],
|
||||
color_hexes[cur_color][2]);
|
||||
|
|
@ -3027,7 +3035,7 @@ static void mainloop(void)
|
|||
|
||||
if (magics[cur_magic].colors)
|
||||
magic_funcs[magics[cur_magic].handle_idx].set_color(
|
||||
magic_api_struct,
|
||||
magic_api_struct[magics[cur_magic].place],
|
||||
color_hexes[cur_color][0],
|
||||
color_hexes[cur_color][1],
|
||||
color_hexes[cur_color][2]);
|
||||
|
|
@ -3100,7 +3108,7 @@ static void mainloop(void)
|
|||
do_render_cur_text(0);
|
||||
else if (cur_tool == TOOL_MAGIC)
|
||||
magic_funcs[magics[cur_magic].handle_idx].set_color(
|
||||
magic_api_struct,
|
||||
magic_api_struct[magics[cur_magic].place],
|
||||
color_hexes[cur_color][0],
|
||||
color_hexes[cur_color][1],
|
||||
color_hexes[cur_color][2]);
|
||||
|
|
@ -3231,7 +3239,7 @@ static void mainloop(void)
|
|||
|
||||
reset_touched();
|
||||
|
||||
magic_funcs[magics[cur_magic].handle_idx].click(magic_api_struct,
|
||||
magic_funcs[magics[cur_magic].handle_idx].click(magic_api_struct[magics[cur_magic].place],
|
||||
magics[cur_magic].idx,
|
||||
canvas, last,
|
||||
old_x, old_y,
|
||||
|
|
@ -3579,7 +3587,7 @@ static void mainloop(void)
|
|||
update_rect.w = 0;
|
||||
update_rect.h = 0;
|
||||
|
||||
magic_funcs[magics[cur_magic].handle_idx].release(magic_api_struct,
|
||||
magic_funcs[magics[cur_magic].handle_idx].release(magic_api_struct[magics[cur_magic].place],
|
||||
magics[cur_magic].idx,
|
||||
canvas, last,
|
||||
old_x, old_y,
|
||||
|
|
@ -3815,7 +3823,7 @@ static void mainloop(void)
|
|||
update_rect.w = 0;
|
||||
update_rect.h = 0;
|
||||
|
||||
magic_funcs[magics[cur_magic].handle_idx].drag(magic_api_struct,
|
||||
magic_funcs[magics[cur_magic].handle_idx].drag(magic_api_struct[magics[cur_magic].place],
|
||||
magics[cur_magic].idx,
|
||||
canvas, last,
|
||||
old_x, old_y,
|
||||
|
|
@ -8179,7 +8187,11 @@ static void draw_brushes(void)
|
|||
|
||||
if (brush < num_brushes)
|
||||
{
|
||||
if (brushes_directional[brush])
|
||||
src.x = (img_brushes[brush]->w / abs(brushes_frames[brush])) / 3;
|
||||
else
|
||||
src.x = 0;
|
||||
|
||||
src.y = brushes_directional[brush] ? (img_brushes[brush]->h / 3) : 0;
|
||||
|
||||
src.w = (img_brushes[brush]->w / abs(brushes_frames[brush])) /
|
||||
|
|
@ -11667,7 +11679,7 @@ static void cleanup(void)
|
|||
#endif
|
||||
|
||||
for (i = 0; i < num_plugin_files; i++)
|
||||
magic_funcs[i].shutdown(magic_api_struct);
|
||||
magic_funcs[i].shutdown(magic_api_struct[magics[cur_magic].place]);
|
||||
|
||||
free_cursor(&cursor_hand);
|
||||
free_cursor(&cursor_arrow);
|
||||
|
|
@ -16478,9 +16490,11 @@ float pick_best_scape(unsigned int orig_w, unsigned int orig_h,
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
void load_magic_plugins(void)
|
||||
{
|
||||
int res, n, i;
|
||||
int res, n, i, plc;
|
||||
char * place;
|
||||
int err;
|
||||
DIR *d;
|
||||
struct dirent *f;
|
||||
|
|
@ -16491,40 +16505,56 @@ void load_magic_plugins(void)
|
|||
num_plugin_files = 0;
|
||||
num_magics = 0;
|
||||
|
||||
for (plc = 0; plc < NUM_MAGIC_PLACES; plc++)
|
||||
{
|
||||
if (plc == MAGIC_PLACE_GLOBAL)
|
||||
place = strdup(MAGIC_PREFIX);
|
||||
else if (plc == MAGIC_PLACE_LOCAL)
|
||||
place = get_fname("plugins/", DIR_DATA);
|
||||
else
|
||||
continue; // Huh?
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("\n");
|
||||
printf("Loading magic plug-ins from %s\n", MAGIC_PREFIX);
|
||||
printf("Loading magic plug-ins from %s\n", place);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
/* Set magic API hooks: */
|
||||
/* Gather list of files (for sorting): */
|
||||
|
||||
magic_api_struct = (magic_api *) malloc(sizeof(magic_api));
|
||||
magic_api_struct->tp_version = strdup(VER_VERSION);
|
||||
magic_api_struct->data_directory = strdup(DATA_PREFIX);
|
||||
magic_api_struct->update_progress_bar = update_progress_bar;
|
||||
magic_api_struct->sRGB_to_linear = magic_sRGB_to_linear;
|
||||
magic_api_struct->linear_to_sRGB = magic_linear_to_sRGB;
|
||||
magic_api_struct->in_circle = in_circle_rad;
|
||||
magic_api_struct->getpixel = getpixels[canvas->format->BytesPerPixel];
|
||||
magic_api_struct->putpixel = putpixels[canvas->format->BytesPerPixel];
|
||||
magic_api_struct->line = magic_line_func;
|
||||
magic_api_struct->playsound = magic_playsound;
|
||||
magic_api_struct->special_notify = special_notify;
|
||||
magic_api_struct->button_down = magic_button_down;
|
||||
magic_api_struct->rgbtohsv = rgbtohsv;
|
||||
magic_api_struct->hsvtorgb = hsvtorgb;
|
||||
magic_api_struct->canvas_w = canvas->w;
|
||||
magic_api_struct->canvas_h = canvas->h;
|
||||
magic_api_struct->scale = magic_scale;
|
||||
magic_api_struct->touched = magic_touched;
|
||||
|
||||
|
||||
d = opendir(MAGIC_PREFIX);
|
||||
d = opendir(place);
|
||||
|
||||
if (d != NULL)
|
||||
{
|
||||
/* Gather list of files (for sorting): */
|
||||
/* Set magic API hooks: */
|
||||
|
||||
magic_api_struct[plc] = (magic_api *) malloc(sizeof(magic_api));
|
||||
magic_api_struct[plc]->tp_version = strdup(VER_VERSION);
|
||||
|
||||
if (plc == MAGIC_PLACE_GLOBAL)
|
||||
magic_api_struct[plc]->data_directory = strdup(DATA_PREFIX);
|
||||
else if (plc == MAGIC_PLACE_LOCAL)
|
||||
magic_api_struct[plc]->data_directory = get_fname("plugins/data/", DIR_DATA);
|
||||
else
|
||||
magic_api_struct[plc]->data_directory = strdup("./");
|
||||
|
||||
magic_api_struct[plc]->update_progress_bar = update_progress_bar;
|
||||
magic_api_struct[plc]->sRGB_to_linear = magic_sRGB_to_linear;
|
||||
magic_api_struct[plc]->linear_to_sRGB = magic_linear_to_sRGB;
|
||||
magic_api_struct[plc]->in_circle = in_circle_rad;
|
||||
magic_api_struct[plc]->getpixel = getpixels[canvas->format->BytesPerPixel];
|
||||
magic_api_struct[plc]->putpixel = putpixels[canvas->format->BytesPerPixel];
|
||||
magic_api_struct[plc]->line = magic_line_func;
|
||||
magic_api_struct[plc]->playsound = magic_playsound;
|
||||
magic_api_struct[plc]->special_notify = special_notify;
|
||||
magic_api_struct[plc]->button_down = magic_button_down;
|
||||
magic_api_struct[plc]->rgbtohsv = rgbtohsv;
|
||||
magic_api_struct[plc]->hsvtorgb = hsvtorgb;
|
||||
magic_api_struct[plc]->canvas_w = canvas->w;
|
||||
magic_api_struct[plc]->canvas_h = canvas->h;
|
||||
magic_api_struct[plc]->scale = magic_scale;
|
||||
magic_api_struct[plc]->touched = magic_touched;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
|
|
@ -16534,7 +16564,7 @@ void load_magic_plugins(void)
|
|||
{
|
||||
if (f->d_type == DT_REG)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s%s", MAGIC_PREFIX, f->d_name);
|
||||
snprintf(fname, sizeof(fname), "%s%s", place, f->d_name);
|
||||
|
||||
/* Get just the name of the object (e.g., "negative"), w/o filename
|
||||
extension: */
|
||||
|
|
@ -16726,13 +16756,13 @@ void load_magic_plugins(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
res = magic_funcs[num_plugin_files].init(magic_api_struct);
|
||||
res = magic_funcs[num_plugin_files].init(magic_api_struct[plc]);
|
||||
|
||||
if (res != 0)
|
||||
n = magic_funcs[num_plugin_files].get_tool_count(magic_api_struct);
|
||||
n = magic_funcs[num_plugin_files].get_tool_count(magic_api_struct[plc]);
|
||||
else
|
||||
{
|
||||
magic_funcs[num_plugin_files].shutdown(magic_api_struct);
|
||||
magic_funcs[num_plugin_files].shutdown(magic_api_struct[plc]);
|
||||
n = 0;
|
||||
}
|
||||
|
||||
|
|
@ -16748,12 +16778,13 @@ void load_magic_plugins(void)
|
|||
for (i = 0; i < n; i++)
|
||||
{
|
||||
magics[num_magics].idx = i;
|
||||
magics[num_magics].place = plc;
|
||||
magics[num_magics].handle_idx = num_plugin_files;
|
||||
magics[num_magics].name = magic_funcs[num_plugin_files].get_name(magic_api_struct, i);
|
||||
magics[num_magics].tip = magic_funcs[num_plugin_files].get_description(magic_api_struct, i);
|
||||
magics[num_magics].colors = magic_funcs[num_plugin_files].requires_colors(magic_api_struct, i);
|
||||
magics[num_magics].name = magic_funcs[num_plugin_files].get_name(magic_api_struct[plc], i);
|
||||
magics[num_magics].tip = magic_funcs[num_plugin_files].get_description(magic_api_struct[plc], i);
|
||||
magics[num_magics].colors = magic_funcs[num_plugin_files].requires_colors(magic_api_struct[plc], i);
|
||||
|
||||
magics[num_magics].img_icon = magic_funcs[num_plugin_files].get_icon(magic_api_struct, i);
|
||||
magics[num_magics].img_icon = magic_funcs[num_plugin_files].get_icon(magic_api_struct[plc], i);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("-- %s\n", magics[num_magics].name);
|
||||
|
|
@ -16778,6 +16809,7 @@ void load_magic_plugins(void)
|
|||
|
||||
closedir(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qsort(magics, num_magics, sizeof(magic_t), magic_sort);
|
||||
|
|
@ -16804,7 +16836,8 @@ void update_progress_bar(void)
|
|||
show_progress_bar(screen);
|
||||
}
|
||||
|
||||
void magic_line_func(int which, SDL_Surface * canvas, SDL_Surface * last,
|
||||
void magic_line_func(void * mapi,
|
||||
int which, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x1, int y1, int x2, int y2, int step,
|
||||
void (*cb)(void *, int, SDL_Surface *, SDL_Surface *,
|
||||
int, int))
|
||||
|
|
@ -16848,7 +16881,7 @@ void magic_line_func(int which, SDL_Surface * canvas, SDL_Surface * last,
|
|||
{
|
||||
cnt = (cnt + 1) % step;
|
||||
if (cnt == 0)
|
||||
cb((void *) magic_api_struct, which, canvas, last, x1, y);
|
||||
cb((void *) mapi, which, canvas, last, x1, y);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -16857,7 +16890,7 @@ void magic_line_func(int which, SDL_Surface * canvas, SDL_Surface * last,
|
|||
{
|
||||
cnt = (cnt + 1) % step;
|
||||
if (cnt == 0)
|
||||
cb((void *) magic_api_struct, which, canvas, last, x1, y);
|
||||
cb((void *) mapi, which, canvas, last, x1, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -16872,7 +16905,7 @@ void magic_line_func(int which, SDL_Surface * canvas, SDL_Surface * last,
|
|||
{
|
||||
cnt = (cnt + 1) % step;
|
||||
if (cnt == 0)
|
||||
cb((void *) magic_api_struct, which, canvas, last, x1, y);
|
||||
cb((void *) mapi, which, canvas, last, x1, y);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -16881,7 +16914,7 @@ void magic_line_func(int which, SDL_Surface * canvas, SDL_Surface * last,
|
|||
{
|
||||
cnt = (cnt + 1) % step;
|
||||
if (cnt == 0)
|
||||
cb((void *) magic_api_struct, which, canvas, last, x1, y);
|
||||
cb((void *) mapi, which, canvas, last, x1, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue