tp-magic-config man moved to (1)

Magic tool documentation now split into separate files, and referenced
(as a directory) from README, so that users can find docs to any additional
tools (ones not included by default with Tux Paint) that are installed.
Added new --datadir option, to separate path to brushes/stamps/etc. from that of saved files.
Improved docs on where savedir default is.
Made sure --help, man tuxpaint, and OPTIONS docs all covered all command-line options.
Noted SDL_Pango makes locale-specific fonts unnecessary.
Added "--plugindocprefix" option to tp-magic-config, for where docs should go.
Improved plugin API documentation.
Improved layout of man pages a little.
This commit is contained in:
William Kendrick 2007-08-02 21:04:42 +00:00
parent ace762e890
commit adf56ef7e9
66 changed files with 1809 additions and 592 deletions

View file

@ -6,7 +6,7 @@
bill@newbreedsoftware.com
http://www.tuxpaint.org/
July 5, 2007 - July 31, 2007
July 5, 2007 - August 2, 2007
--------------------------------------------------------------------------
@ -98,7 +98,7 @@ Interfaces
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.
header files) for building a plugin. (See "Compiling", 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
@ -553,29 +553,86 @@ Compiling
shared object file (".so") based on your 'Magic' tool plugin's C
source code.
Additionally, use the "tp-magic-config --cflags" command, supplied as
part of Tux Paint, to provide additional command-line flags to your C
compiler that will help it build your plugin.
Use the "tp-magic-config --cflags" command, supplied as part of
Tux Paint -- or in some cases, as part of a "Tux Paint 'Magic' Tool
Plugin Development package" -- to provide additional command-line
flags to your C compiler that will help it build your plugin.
As a stand-alone command, using the GNU C Compiler and BASH shell, for
example:
Command-Line Example
$ gcc -shared `tp-magic-config --cflags` my_plugin.c -o my_plugin.so
As a stand-alone command, using the GNU C Compiler and BASH shell,
for example:
Note: The characters around the "tp-magic-config" command are a
grave/backtick/backquote ("`"), and not an apostrophe/single-quote
("'"). They tell the shell to execute the command within (in this
case, "tp-magic-config ..."), and use its output as an argument to the
command being executed (in this case, "gcc ...").
$ gcc -shared `tp-magic-config --cflags` my_plugin.c -o
my_plugin.so
A snippet from a more generalized Makefile might look like this:
Note: The characters around the "tp-magic-config" command are a
grave/backtick/backquote ("`"), and not an apostrophe/single-quote
("'"). They tell the shell to execute the command within (in this
case, "tp-magic-config ..."), and use its output as an argument to
the command being executed (in this case, "gcc ...").
+----------------------------------------------------+
| CFLAGS=-Wall -O2 $(shell tp-magic-config --cflags) |
| |
| my_plugin.so: my_plugin.c |
| $(CC) -shared $(CFLAGS) -o $@ $< |
+----------------------------------------------------+
Makefile Example
A snippet from a Makefile to compile a Tux Paint "Magic" tool plugin
might look like this:
+------------------------------------------------------+
| CFLAGS=-Wall -O2 $(shell tp-magic-config --cflags) |
| |
| my_plugin.so: my_plugin.c |
| gcc -shared $(CFLAGS) -o my_plugin.so my_plugin.c |
+------------------------------------------------------+
The first line sets up Makefile variable ("CFLAGS") that contains
flags for the compiler. "-Wall" asks for all compiler warnings to be
shown. "-O2" asks for level 2 optimization.
"($shell tp-magic-config --cflags)" runs "tp-magic-config" to
retrieve additional compiler flags that "Magic" tool plugins
require. (The "$(shell ...)" directive is similar to the ` ("grave")
character in the BASH shell examples, above.)
The next line defines a Makefile target, "my_plugin.so", and states
that it depends on the C source file "my_plugin.c". (Any time the C
file changes, "make" will know to recompile it and produce an
updated ".so" file. If the C file hadn't changed, it won't bother
recompiling.)
The last line defines the command "make" should run when it
determines that it needs to (re)compile the ".so" file. Here, we're
using "gcc", with "-shared and "$(CFLAGS)" command-line arguments,
like above. "-o my_plugin.so" tells the C compiler that the output
file should be "my_plugin.so". The last argument is the C file to
compile, in this case "my_plugin.c".
Note: Commands listed below a Makefile target should be intented
using a single tab character.
Advanced Makefile
An even more generalized Makefile might look like this:
+----------------------------------------------------+
| CFLAGS=-Wall -O2 $(shell tp-magic-config --cflags) |
| |
| my_plugin_1.so: my_plugin_1.c |
| $(CC) -shared $(CFLAGS) -o $@ $< |
| |
| my_plugin_2.so: my_plugin_2.c |
| $(CC) -shared $(CFLAGS) -o $@ $< |
+----------------------------------------------------+
As before, there are lines that define the command "make" should run
when it determines that it needs to (re)compile the ".so" file(s).
However, more general terms are used...
"$(CC)" gets expanded to your default C compiler (e.g., "gcc").
"-shared and "$(CFLAGS)" are command-line arguments to the compiler,
like above. "-o $@" tells the C compiler what the output file should
be; "make" replaces "$@" with the name of the target, in this case
"my_plugin_1.so" or "my_plugin_2.so". And finally, the last argument
is the C file to compile; "make" replaces it with the target's
dependency, in this case "my_plugin_1.c" or "my_plugin_2.c".
Windows
@ -591,54 +648,108 @@ Installing
Linux and other Unix-like Platforms
Use the "tp-magic-config --pluginprefix" command, supplied as part of
Tux Paint, to determine where the plugin shared object (".so") files
should be installed. The value returned by this command will be the
global location where the installed version of Tux Paint looks for
plugins (e.g., "").
Use the "tp-magic-config" command-line tool, supplied as part of
Tux Paint -- or in some cases, as part of a "Tux Paint 'Magic' Tool
Plugin Development package" -- to determine where your plugins' files
should go.
As stand-alone commands, using the BASH shell, for example:
Shared Object
# cp my_plugin.so `tp-magic-config --pluginprefix`
# chmod 644 `tp-magic-config --pluginprefix`/my_plugin.so
Use "tp-magic-config --pluginprefix" to determine where the plugin
shared object (".so") files should be installed. The value returned
by this command will be the global location where the installed copy
of Tux Paint looks for plugins (e.g., "/usr/lib/tuxpaint/plugins").
Additionally, use the "tp-magic-config --dataprefix" command, supplied
as part of Tux Paint, to determine where data files (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
"data_directory" string stored within the "magic_api" structure that
your plugin's functions receive.
As stand-alone commands, using the BASH shell, for example:
Note: Tux Paint's default Magic tool plugins install their data within
"magic" subdirectories of Tux Paint's "images" and "sounds" data
directories (e.g., "/usr/share/tuxpaint/images/magic/"). You are
encouraged to do the same.
# cp my_plugin.so `tp-magic-config --pluginprefix`
# chmod 644 `tp-magic-config --pluginprefix`/my_plugin.so
As stand-alone commands, using the BASH shell, for example:
Note: See the note above regarding the "`" (grave) character.
# cp my_plugin_icon.png `tp-magic-config --dataprefix`/images/magic/
# chmod 644 `tp-magic-config
--dataprefix`/images/magic/my_plugin_icon.png
Documentation
Use the "tp-magic-config --plugindocprefix" command to determine
where documentation for your "Magic" tools should go. The value
returned by this command will be the location where the
documentation to the installed copy of Tux Paint is stored. The main
documentation includes a link to a folder where "Magic" tools'
documentation is expected to be installed
(e.g., "/usr/share/doc/tuxpaint/magic-docs").
Note: It's best to include both HTML and plain-text versions of your
documentation. An "html" subdirectory exists within the "magic-docs"
directory, and is where the HTML versions should go.
As stand-alone commands, using the BASH shell, for example:
# cp my_plugin.html `tp-magic-config --plugindocprefix`/html
# cp my_plugin.txt `tp-magic-config --plugindocprefix`
Note: See the note above regarding the "`" (grave) character.
Icons, Sounds and other Data Files
Use the "tp-magic-config --dataprefix" command, supplied as part of
Tux Paint, to determine where data files (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 "data_directory" string
stored within the "magic_api" structure that your plugin's functions
receive.
Note: Tux Paint's default Magic tool plugins install their data
within "magic" subdirectories of Tux Paint's "images" and "sounds"
data directories (e.g., "/usr/share/tuxpaint/images/magic/"). You
are encouraged to do the same.
As stand-alone commands, using the BASH shell, for example:
# cp my_plugin_icon.png `tp-magic-config
--dataprefix`/images/magic/
# chmod 644 `tp-magic-config
--dataprefix`/images/magic/my_plugin_icon.png
Note: See the note above regarding the "`" (grave) character.
Putting it Together in a Makefile
A snippet from a more generalized Makefile might look like this:
+------------------------------------------------------+
| PLUGINPREFIX=$(shell tp-magic-config --pluginprefix) |
| DATAPREFIX=$(shell tp-magic-config --dataprefix) |
| |
| install: |
| mkdir -p $(PLUGINPREFIX) |
| cp *.so $(PLUGINPREFIX)/ |
| chmod 644 $(PLUGINPREFIX)/*.so |
| mkdir -p $(DATAPREFIX)/images/magic |
| cp *.png $(DATAPREFIX)/images/magic/ |
| chmod 644 $(DATAPREFIX)/images/magic/*.png |
+------------------------------------------------------+
+------------------------------------------------------------+
| PLUGINPREFIX=$(shell tp-magic-config --pluginprefix) |
| PLUGINDOCPREFIX=$(shell tp-magic-config --plugindocprefix) |
| DATAPREFIX=$(shell tp-magic-config --dataprefix) |
| |
| install: |
| # |
| # Install plugin |
| mkdir -p $(PLUGINPREFIX) |
| cp *.so $(PLUGINPREFIX)/ |
| chmod 644 $(PLUGINPREFIX)/*.so |
| # |
| # Install icons |
| mkdir -p $(DATAPREFIX)/images/magic |
| cp icons/*.png $(DATAPREFIX)/images/magic/ |
| chmod 644 $(DATAPREFIX)/images/magic/*.png |
| # |
| # Install sound effects |
| mkdir -p $(DATAPREFIX)/sounds/magic |
| cp sounds/*.ogg $(DATAPREFIX)/sounds/magic/ |
| chmod 644 $(DATAPREFIX)/sounds/magic/*.ogg |
| # |
| # Install docs |
| mkdir -p $(PLUGINDOCPREFIX)/html |
| cp docs/*.html $(PLUGINDOCPREFIX)/html/ |
| cp docs/*.txt $(PLUGINDOCPREFIX)/ |
| chmod 644 $(PLUGINDOCPREFIX)/html/*.html |
| chmod 644 $(PLUGINDOCPREFIX)/*.txt |
+------------------------------------------------------------+
The first two lines set up Makefile variables that contain the paths
returned by the "tp-magic-config" command-line tool.
The first three lines set up Makefile variables that contain the
paths returned by the "tp-magic-config" command-line tool. (The
"$(shell ...)" directive is similar to the ` ("grave") character in
the BASH shell examples, above.)
Below that is an "install" target in the Makefile. (Invoked by, for
example, "$ sudo make install" or "# make install".)
@ -648,7 +759,9 @@ Installing
into it, and invokes "chmod" to make sure they are readable.
It then does a similar series of commands to install icon files
(".png" images) into a subdirectory within Tux Paint's data
(".png" images) and sound effects (".ogg" files) into subdirectories
within Tux Paint's data directory, and to install documentation
(".html" and ".txt" files) within Tux Paint's documentation
directory.
Windows
@ -696,7 +809,10 @@ Creating plugins with multiple effects
for (i = 0; i < NUM_TOOLS; i++)
{
snprintf(fname, sizeof(fname), "%s/%s",
/* Becomes, for example,
"/usr/share/tuxpaint/sounds/magic/one.ogg" */
snprintf(fname, sizeof(fname), "%s/sounds/magic/%s",
api->data_prefix, my_plugin_snd_filenames[i];
my_plugin_snds[i] = Mix_LoadWAV(fname);
@ -705,6 +821,11 @@ Creating plugins with multiple effects
* Similarly, do the same to free them later (such as freeing sound
effects during your "shutdown()").
int i;
for (i = 0; i < NUM_TOOLS; i++)
Mix_FreeChunk(my_plugin_snds[i]);
* Use "which" values sent to your functions as an index into those
arrays (e.g., for playing the appropriate sound effect for a tool).
@ -787,6 +908,8 @@ Glossary
* 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)
* 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.
* green: See "RGBA"
@ -807,6 +930,8 @@ 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
* 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
@ -816,9 +941,10 @@ Glossary
* Mix_LoadWAV(): An SDL_mixer function that loads a sound file (WAV,
Ogg Vorbis, etc.) and returns it as a "Mix_Chunk *".
* namespace: TBD
* Ogg Vorbis: TBD
* OGG: See "Ogg Vorbis"
* Ogg Vorbis: TBD (See also: "WAV")
* Plugin: TBD
* PNG: TBD
* PNG: TBD (See also the "png(5) man page)
* pointer: See "C pointer"
* red: See "RGBA"
* release: The action of releasing a button on a mouse.
@ -827,19 +953,21 @@ Glossary
* saturation: See "HSV"
* SDL: See "Simple DirectMedia Layer"
* SDL_FreeSurface(): An libSDL function that frees (deallocates) memory
allocated for an SDL surface ("SDL_Surface *").
allocated for an SDL surface ("SDL_Surface *"). (See also the
"SDL_FreeSurface(3)" man page)
* SDL_GetRGB(): A libSDL function that, given a Uint32 pixel value
(e.g., one returned from the Tux Paint's Magic tool API helper
function "getpixel()"), the format of the surface the pixel was taken
from, and pointers to three Uint8 variables, will place the Red, Green
and Blue (RGB) values of the pixel into the three Uint8 variables.
(Example: "SDL_GetRGB(getpixel(surf, x, y), surf->format, &r, &g,
&b);".)
&b);".) (See also the "SDL_GetRGB(3)" man page)
* SDL_MapRGB(): A libSDL function that, given the format of a surface
and Uint8 values representing Red, Green and Blue values for a pixel,
returns a Uint32 pixel value that can be placed in the surface (e.g.,
using Tux Paint's Magic tool API helper function "putpixel()").
(Example: "putpixel(surf, x, y, SDL_MapRGB(surf->format, r, g, b));".)
(See also the "SDL_MapRGB(3)" man page)
* SDL_image: A library on top of libSDL that can load various kinds of
image files (e.g., PNG) and return them as an "SDL_Surface *".
* SDL_mixer: A library on top of libSDL that can load various kinds of
@ -848,15 +976,15 @@ Glossary
* SDL_Rect: A C structure defined by libSDL that represents a
rectangular area. It contains elements representing the coordinates of
the top left corner of the rectange (x,y) and the dimensions of the
rectangle (w,h).
rectangle (w,h). (See also the "SDL_Rect(3)" man page)
* SDL_Surface *: (A pointer to) a C structure defined by libSDL that
contains a drawing surface.
contains a drawing surface. (See also the "SDL_Surface(3)" man page)
* Shared Object: A piece of code that's compiled separately from the
main application, and loaded dynamically, at runtime.
* Simple DirectMedia Layer: A programming library that allows programs
portable low level access to a video framebuffer, audio output, mouse,
and keyboard.
* snprintf(): TBD
and keyboard. (See also: http://www.libsdl.org/)
* snprintf(): TBD (See also the "snprintf(3)" man page)
* .so: See "Shared Object"
* sRBG: See "RGBA"
* star: "*". A symbol in C that, when used in the declaration of
@ -869,7 +997,7 @@ Glossary
integer that's being pointed to.)
* strdup(): A C function that allocates enough memory to store a copy of
a string, copies the string to it, and returns a "char *" pointer to
the new copy.
the new copy. (See also the "strdup(3)" man page)
* struct: See "C structure"
* The GIMP: An Open Source image manipulation and paint program.
* tp_magic_api.h: A header file that defines Tux Paint's Magic tool API.
@ -877,7 +1005,8 @@ Glossary
* tp-magic-config: A command-line program that provides information
about the installed version of Tux Paint to plugin developers (such as
what C compiler flags they should compile with, and where plugin
shared objects and data files should be installed).
shared objects and data files should be installed). (See also the
"tp-magic-config(3)" man page.)
* Uint32: A 32-bit, unsigned integer (defined by libSDL). In other
words, four bytes that can represent 0 through 4294967295. (Typically
used to hold enough information to store three or four bytes
@ -887,6 +1016,6 @@ Glossary
* unsigned: TBD
* value: See "HSV"
* variable: TBD
* WAV: TBD
* WAV: TBD (See also "Ogg Vorbis")
* (w,h): See "Dimensions"
* (x,y): See "Coordinates"

View file

@ -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 - July 31, 2007</p>
<p>July 5, 2007 - August 2, 2007</p>
</center>
<hr size=2 noshade>
@ -79,7 +79,7 @@ concept.)</p>
<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="#">Glossary</a>
<li><a href="#glossary">Glossary</a>
</ul>
@ -126,7 +126,8 @@ invokes them.</p>
Also, when you run the C compiler to build a plugin, you should use the
command-line tool "<code>tp-magic-config</code>" to get the appropriate
compiler flags (such as where the compiler can find the Tux&nbsp;Paint
plugin header file, as well as SDL's header files) for building a plugin.</p>
plugin header file, as well as SDL's header files) for building a plugin.
(See "<a href="#compiling">Compiling</a>", below.)</p>
<p>The C header file and command-line tool mentioned above are included
with Tux&nbsp;Paint &mdash; or in some cases, as part of a "Tux&nbsp;Paint
@ -711,9 +712,15 @@ also contains some helper macros that you may use.</p>
a shared object file ("<code>.so</code>") based on your 'Magic' tool
plugin's C source code.</p>
<p>Additionally, use the "<code>tp-magic-config&nbsp;--cflags</code>" command,
supplied as part of Tux&nbsp;Paint, to provide additional command-line
flags to your C compiler that will help it build your plugin.</p>
<p>Use the "<code>tp-magic-config&nbsp;--cflags</code>" command,
supplied as part of Tux&nbsp;Paint &mdash; or in some cases, as part of a
"Tux Paint 'Magic' Tool Plugin Development package" &mdash;
to provide additional command-line flags to your C compiler that will help
it build your plugin.</p>
<h4>Command-Line Example</h4>
<blockquote>
<p>As a stand-alone command, using the GNU C Compiler and BASH shell,
for example:</p>
@ -724,7 +731,8 @@ also contains some helper macros that you may use.</p>
</code></p>
</blockquote>
<p><b>Note:</b> The characters around the "<code>tp-magic-config</code>"
<p><a name="grave"><b>Note:</b></a>
The characters around the "<code>tp-magic-config</code>"
command are a grave/backtick/backquote
("<code><b><font size=+1>`</font></b></code>"), and
not an apostrophe/single-quote ("<code><b><font size=+1>'</font></b></code>").
@ -733,17 +741,87 @@ also contains some helper macros that you may use.</p>
as an argument to the command being executed (in this case,
"<code>gcc&nbsp;...</code>").</p>
<p>A snippet from a more generalized Makefile might look like this:</p>
</blockquote>
<h4>Makefile Example</h4>
<blockquote>
<p>A snippet from a Makefile to compile a Tux&nbsp;Paint "Magic" tool
plugin might look like this:</p>
<blockquote><table border=1 cellspacing=0 cellpadding=4><tr><td>
<p><code>
CFLAGS=-Wall -O2 $(shell tp-magic-config --cflags)<br>
<br>
my_plugin.so: my_plugin.c<br>
&nbsp;&nbsp;&nbsp;gcc -shared $(CFLAGS) -o my_plugin.so my_plugin.c
</code></p>
</td></tr></table></blockquote>
<p>The first line sets up Makefile variable ("<code>CFLAGS</code>") that
contains flags for the compiler. "<code>-Wall</code>" asks for all compiler
warnings to be shown. "<code>-O2</code>" asks for level 2 optimization.
"<code>($shell&nbsp;tp-magic-config&nbsp;--cflags)</code>" runs
"<code>tp-magic-config</code>" to retrieve additional compiler flags that
"Magic" tool plugins require. (The "<code>$(shell&nbsp;...)</code>"
directive is similar to the <a href="#grave"><b><font size=+1>`</font></b>
("grave")</a> character in the BASH shell examples, above.)</p>
<p>The next line defines a Makefile target, "<code>my_plugin.so</code>",
and states that it <i>depends&nbsp;on</i> the C source file
"<code>my_plugin.c</code>". (Any time the C file changes, "<code>make</code>"
will know to recompile it and produce an updated "<code>.so</code>" file.
If the C file hadn't changed, it won't bother recompiling.)</p>
<p>The last line defines the command "<code>make</code>" should
run when it determines that it needs to (re)compile the "<code>.so</code>"
file. Here, we're using "<code>gcc</code>", with "<code>-shared</code> and
"<code>$(CFLAGS)</code>" command-line arguments, like above.
"<code>-o&nbsp;my_plugin.so</code>" tells the C compiler that the output file
should be "<code>my_plugin.so</code>". The last argument is the C file to
compile, in this case "<code>my_plugin.c</code>".</p>
<p><b>Note:</b> Commands listed below a Makefile target should be
intented using a single <b>tab</b> character.</p>
</blockquote>
<h4>Advanced Makefile</h4>
<blockquote>
<p>An even more generalized Makefile might look like this:</p>
<blockquote><table border=1 cellspacing=0 cellpadding=4><tr><td>
<p><code>
CFLAGS=-Wall -O2 $(shell tp-magic-config --cflags)<br>
<br>
my_plugin_1.so: my_plugin_1.c<br>
&nbsp;&nbsp;&nbsp;$(CC) -shared $(CFLAGS) -o $@ $&lt;<br>
<br>
my_plugin_2.so: my_plugin_2.c<br>
&nbsp;&nbsp;&nbsp;$(CC) -shared $(CFLAGS) -o $@ $&lt;
</code></p>
</td></tr></table></blockquote>
<p>As before, there are lines that define the command "<code>make</code>"
should run when it determines that it needs to (re)compile the
"<code>.so</code>" file(s). However, more general terms are used...</p>
<p>"<code>$(CC)</code>" gets expanded to your default C compiler (e.g.,
"<code>gcc</code>"). "<code>-shared</code> and "<code>$(CFLAGS)</code>"
are command-line arguments to the compiler, like above.
"<code>-o&nbsp;$@</code>" tells the C compiler what the output file
should be; "<code>make</code>" replaces "<code>$@</code>" with the name
of the target, in this case "<code>my_plugin_1.so</code>" or
"<code>my_plugin_2.so</code>". And finally,
the last argument is the C file to compile; "<code>make</code>" replaces
it with the target's dependency, in this case
"<code>my_plugin_1.c</code>" or "<code>my_plugin_2.c</code>".</p>
</blockquote>
</blockquote>
<h3>Windows</h3>
@ -769,23 +847,70 @@ also contains some helper macros that you may use.</p>
<h3>Linux and other Unix-like Platforms</h3>
<blockquote>
<p>Use the "<code>tp-magic-config&nbsp;--pluginprefix</code>"
command, supplied as part of Tux&nbsp;Paint, to determine where the
plugin shared&nbsp;object ("<code>.so</code>") files should be installed.
The value returned by this command will be the global location where
the installed version of Tux&nbsp;Paint looks for plugins
(e.g., "<code></code>").</p>
<p>Use the "<code>tp-magic-config</code>" command-line tool, supplied as
part of Tux&nbsp;Paint &mdash; or in some cases, as part of a "Tux
Paint 'Magic' Tool Plugin Development package" &mdash; to determine
where your plugins' files should go.</p>
<h4>Shared Object</h4>
<blockquote>
<p>Use "<code>tp-magic-config&nbsp;--pluginprefix</code>"
to determine where the plugin shared&nbsp;object ("<code>.so</code>")
files should be installed. The value returned by this command will be
the global location where the installed copy of Tux&nbsp;Paint looks
for plugins (e.g., "<code>/usr/lib/tuxpaint/plugins</code>").</p>
<p>As stand-alone commands, using the BASH shell, for example:</p>
<blockquote>
<p><code>
# cp my_plugin.so `tp-magic-config --pluginprefix`<br>
# chmod 644 `tp-magic-config --pluginprefix`/my_plugin.so
# chmod 644 `tp-magic-config --pluginprefix`/my_plugin.so<br>
</code></p>
</blockquote>
<p>Additionally, use the "<code>tp-magic-config&nbsp;--dataprefix</code>"
<p><b>Note:</b> See the <a href="#grave">note above regarding the
"<font size=+1><b>`</b></font>" (grave) character</a>.</p>
</blockquote>
<h4>Documentation</h4>
<blockquote>
<p>Use the "<code>tp-magic-config&nbsp;--plugindocprefix</code>"
command to determine where documentation for your "Magic" tools should go.
The value returned by this command will be the location where the
documentation to the installed copy of Tux&nbsp;Paint is stored.
The main documentation includes a link to a folder where "Magic" tools'
documentation is expected to be installed</p>
(e.g., "<code>/usr/share/doc/tuxpaint/magic-docs</code>").</p>
<p><b>Note:</b> It's best to include both HTML and plain-text versions
of your documentation. An "<code>html</code>" subdirectory exists within
the "<code>magic-docs</code>" directory, and is where the HTML versions
should go.</p>
<p>As stand-alone commands, using the BASH shell, for example:</p>
<blockquote>
<p><code>
# cp my_plugin.html `tp-magic-config --plugindocprefix`/html<br>
# cp my_plugin.txt `tp-magic-config --plugindocprefix`
</code></p>
</blockquote>
<p><b>Note:</b> See the <a href="#grave">note above regarding the
"<font size=+1><b>`</b></font>" (grave) character</a>.</p>
</blockquote>
<h4>Icons, Sounds and other Data Files</h4>
<blockquote>
<p>Use the "<code>tp-magic-config&nbsp;--dataprefix</code>"
command, supplied as part of Tux&nbsp;Paint, to determine where data files
(PNG icon, Ogg&nbsp;Vorbis sound effects, etc.) should be installed.
The value returned by this command will be the same as the value of the
@ -807,6 +932,11 @@ also contains some helper macros that you may use.</p>
</code></p>
</blockquote>
<p><b>Note:</b> See the <a href="#grave">note above regarding the
"<font size=+1><b>`</b></font>" (grave) character</a>.</p>
</blockquote>
<h4>Putting it Together in a Makefile</h4>
<blockquote>
@ -816,20 +946,40 @@ also contains some helper macros that you may use.</p>
<blockquote><table border=1 cellspacing=0 cellpadding=4><tr><td>
<p><code>
PLUGINPREFIX=$(shell tp-magic-config --pluginprefix)<br>
PLUGINDOCPREFIX=$(shell tp-magic-config --plugindocprefix)<br>
DATAPREFIX=$(shell tp-magic-config --dataprefix)<br>
<br>
install:<br>
&nbsp;&nbsp;&nbsp;#<br>
&nbsp;&nbsp;&nbsp;# Install plugin<br>
&nbsp;&nbsp;&nbsp;mkdir -p $(PLUGINPREFIX)<br>
&nbsp;&nbsp;&nbsp;cp *.so $(PLUGINPREFIX)/<br>
&nbsp;&nbsp;&nbsp;chmod 644 $(PLUGINPREFIX)/*.so<br>
&nbsp;&nbsp;&nbsp;#<br>
&nbsp;&nbsp;&nbsp;# Install icons<br>
&nbsp;&nbsp;&nbsp;mkdir -p $(DATAPREFIX)/images/magic<br>
&nbsp;&nbsp;&nbsp;cp *.png $(DATAPREFIX)/images/magic/<br>
&nbsp;&nbsp;&nbsp;chmod 644 $(DATAPREFIX)/images/magic/*.png
&nbsp;&nbsp;&nbsp;cp icons/*.png $(DATAPREFIX)/images/magic/<br>
&nbsp;&nbsp;&nbsp;chmod 644 $(DATAPREFIX)/images/magic/*.png<br>
&nbsp;&nbsp;&nbsp;#<br>
&nbsp;&nbsp;&nbsp;# Install sound effects<br>
&nbsp;&nbsp;&nbsp;mkdir -p $(DATAPREFIX)/sounds/magic<br>
&nbsp;&nbsp;&nbsp;cp sounds/*.ogg $(DATAPREFIX)/sounds/magic/<br>
&nbsp;&nbsp;&nbsp;chmod 644 $(DATAPREFIX)/sounds/magic/*.ogg<br>
&nbsp;&nbsp;&nbsp;#<br>
&nbsp;&nbsp;&nbsp;# Install docs<br>
&nbsp;&nbsp;&nbsp;mkdir -p $(PLUGINDOCPREFIX)/html<br>
&nbsp;&nbsp;&nbsp;cp docs/*.html $(PLUGINDOCPREFIX)/html/<br>
&nbsp;&nbsp;&nbsp;cp docs/*.txt $(PLUGINDOCPREFIX)/<br>
&nbsp;&nbsp;&nbsp;chmod 644 $(PLUGINDOCPREFIX)/html/*.html<br>
&nbsp;&nbsp;&nbsp;chmod 644 $(PLUGINDOCPREFIX)/*.txt<br>
</code></p>
</td></tr></table></blockquote>
<p>The first two lines set up Makefile variables that contain the
paths returned by the "<code>tp-magic-config</code>" command-line tool.</p>
<p>The first three lines set up Makefile variables that contain the
paths returned by the "<code>tp-magic-config</code>" command-line tool.
(The "<code>$(shell&nbsp;...)</code>" directive is similar to the
<a href="#grave"><b><font size=+1>`</font></b> ("grave")</a> character
in the BASH shell examples, above.)</p>
<p>Below that is an "<code>install</code>" target in the Makefile.
(Invoked by, for example, "<code>$&nbsp;sudo&nbsp;make&nbsp;install</code>"
@ -841,8 +991,11 @@ also contains some helper macros that you may use.</p>
"<code>chmod</code>" to make sure they are readable.</p>
<p>It then does a similar series of commands to install icon files
("<code>.png</code>"&nbsp;images) into a subdirectory within Tux&nbsp;Paint's
data directory.</p>
("<code>.png</code>"&nbsp;images) and sound effects
("<code>.ogg</code>"&nbsp;files) into subdirectories within Tux&nbsp;Paint's
data directory, and to install documentation
("<code>.html</code>" and "<code>.txt</code>" files) within Tux&nbsp;Paint's
documentation directory.</p>
</blockquote>
</blockquote>
@ -905,7 +1058,9 @@ effects:</p>
<br>
for (i = 0; i &lt; NUM_TOOLS; i++)<br>
{<br>
&nbsp;&nbsp;snprintf(fname, sizeof(fname), "%s/%s",<br>
&nbsp;&nbsp;/* Becomes, for example, "/usr/share/tuxpaint/sounds/magic/one.ogg" */<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;snprintf(fname, sizeof(fname), "%s/sounds/magic/%s",<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;api->data_prefix, my_plugin_snd_filenames[i];<br>
<br>
&nbsp;&nbsp;my_plugin_snds[i] = Mix_LoadWAV(fname);<br>
@ -914,7 +1069,12 @@ effects:</p>
<li>Similarly, do the same to free them later (such as freeing
sound effects during your "<code>shutdown()</code>").<br>
<br>
<blockquote><code>
int i;<br>
<br>
for (i = 0; i &lt; NUM_TOOLS; i++)<br>
&nbsp;&nbsp;Mix_FreeChunk(my_plugin_snds[i]);
</code></blockquote>
<li>Use "<code>which</code>" values sent to your functions as an
index into those arrays (e.g., for playing the appropriate sound effect
@ -960,7 +1120,7 @@ mailing lists:
<hr size=1 noshade>
<h2>Glossary</h2>
<h2><a name="glossary">Glossary</a></h2>
<ul>
<li><b>alpha:</b> See "RGBA"
@ -999,6 +1159,8 @@ mailing lists:
<li><b>format:</b> <i>TBD</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&nbsp;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"
<li><b>-&gt;:</b> See "arrow"
@ -1015,14 +1177,17 @@ 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&nbsp;Paint.
<li><b>make:</b> <i>TBD</i>
<li><b>Makefile:</b> <i>TBD</i>
<li><b>Magic tool</b>: One of a number of effects or drawing tools in Tux&nbsp;Paint, made available via the "Magic" tool button.
<li><b>Mix_Chunk&nbsp;*:</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&nbsp;*</code>").
<li><b>Mix_LoadWAV():</b> An SDL_mixer function that loads a sound file (WAV, Ogg&nbsp;Vorbis, etc.) and returns it as a "<code>Mix_Chunk&nbsp;*</code>".
<li><b>namespace:</b> <i>TBD</i>
<li><b>Ogg&nbsp;Vorbis:</b> <i>TBD</i>
<li><b>OGG</b>: See "Ogg Vorbis"
<li><b>Ogg&nbsp;Vorbis:</b> <i>TBD</i> (See also: "WAV")
<li><b>Plugin</b>: <i>TBD</i>
<li><b>PNG:</b> <i>TBD</i>
<li><b>PNG:</b> <i>TBD</i> (See also the "<code>png(5)</code> <i>man&nbsp;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.
@ -1030,30 +1195,30 @@ mailing lists:
<li><b>RGB:</b> See "RBGA"
<li><b>saturation:</b> See "HSV"
<li><b>SDL:</b> See "Simple DirectMedia Layer"
<li><b>SDL_FreeSurface():</b> An libSDL function that frees (deallocates) memory allocated for an SDL surface ("<code>SDL_Surface&nbsp;*</code>").
<li><b>SDL_GetRGB():</b> A libSDL function that, given a <code>Uint32</code> pixel value (e.g., one returned from the Tux&nbsp;Paint's Magic tool API helper function "<code>getpixel()</code>"), the format of the surface the pixel was taken from, and pointers to three <code>Uint8</code> variables, will place the Red, Green and Blue (RGB) values of the pixel into the three <code>Uint8</code> variables. (Example: "<code>SDL_GetRGB(getpixel(surf,&nbsp;x,&nbsp;y), surf-&gt;format, &amp;r, &amp;g, &amp;b);</code>".)
<li><b>SDL_MapRGB():</b> A libSDL function that, given the format of a surface and <code>Uint8</code> values representing Red, Green and Blue values for a pixel, returns a <code>Uint32</code> pixel value that can be placed in the surface (e.g., using Tux&nbsp;Paint's Magic tool API helper function "<code>putpixel()</code>"). (Example: "<code>putpixel(surf, x, y, SDL_MapRGB(surf-&gt;format, r, g, b));</code>".)
<li><b>SDL_FreeSurface():</b> An libSDL function that frees (deallocates) memory allocated for an SDL surface ("<code>SDL_Surface&nbsp;*</code>"). (See also the "<code>SDL_FreeSurface(3)</code>" <i>man&nbsp;page</i>)
<li><b>SDL_GetRGB():</b> A libSDL function that, given a <code>Uint32</code> pixel value (e.g., one returned from the Tux&nbsp;Paint's Magic tool API helper function "<code>getpixel()</code>"), the format of the surface the pixel was taken from, and pointers to three <code>Uint8</code> variables, will place the Red, Green and Blue (RGB) values of the pixel into the three <code>Uint8</code> variables. (Example: "<code>SDL_GetRGB(getpixel(surf,&nbsp;x,&nbsp;y), surf-&gt;format, &amp;r, &amp;g, &amp;b);</code>".) (See also the "<code>SDL_GetRGB(3)</code>" <i>man&nbsp;page</i>)
<li><b>SDL_MapRGB():</b> A libSDL function that, given the format of a surface and <code>Uint8</code> values representing Red, Green and Blue values for a pixel, returns a <code>Uint32</code> pixel value that can be placed in the surface (e.g., using Tux&nbsp;Paint's Magic tool API helper function "<code>putpixel()</code>"). (Example: "<code>putpixel(surf, x, y, SDL_MapRGB(surf-&gt;format, r, g, b));</code>".) (See also the "<code>SDL_MapRGB(3)</code>" <i>man&nbsp;page</i>)
<li><b>SDL_image:</b> A library on top of libSDL that can load various kinds of image files (e.g., PNG) and return them as an "<code>SDL_Surface&nbsp;*</code>".
<li><b>SDL_mixer:</b> A library on top of libSDL that can load various kinds of sound files (WAV, Ogg&nbsp;Vorbis, etc.) and play back multiple sounds at once (mix them).
<li><b>SDL_Rect:</b> A C structure defined by libSDL that represents a rectangular area. It contains elements representing the coordinates of the top left corner of the rectange (x,y) and the dimensions of the rectangle (w,h).
<li><b>SDL_Surface&nbsp;*:</b> (A pointer to) a C structure defined by libSDL that contains a drawing surface.
<li><b>SDL_Rect:</b> A C structure defined by libSDL that represents a rectangular area. It contains elements representing the coordinates of the top left corner of the rectange (x,y) and the dimensions of the rectangle (w,h). (See also the "<code>SDL_Rect(3)</code>" <i>man&nbsp;page</i>)
<li><b>SDL_Surface&nbsp;*:</b> (A pointer to) a C structure defined by libSDL that contains a drawing surface. (See also the "<code>SDL_Surface(3)</code>" <i>man&nbsp;page</i>)
<li><b>Shared Object:</b> A piece of code that's compiled separately from the main application, and loaded dynamically, at runtime.
<li><b>Simple DirectMedia Layer:</b> A programming library that allows programs portable low level access to a video framebuffer, audio output, mouse, and keyboard.
<li><b>snprintf():</b> <i>TBD</i>
<li><b>Simple DirectMedia Layer:</b> A programming library that allows programs portable low level access to a video framebuffer, audio output, mouse, and keyboard. (See also: <a href="http://www.libsdl.org/">http://www.libsdl.org/</a>)
<li><b>snprintf():</b> <i>TBD</i> (See also the "<code>snprintf(3)</code>" <i>man&nbsp;page</i>)
<li><b>.so:</b> See "Shared Object"
<li><b>sRBG:</b> See "RGBA"
<li><b>star:</b> "<code>*</code>". A symbol in C that, when used in the declaration of variables (e.g., arguments to a function), denotes that the variable is a pointer. (For example, "<code>int&nbsp;*&nbsp;p;</code>" means that "<code>p</code>" is a <i>pointer</i> to an integer.) When used next to a pointer, it 'dereferences' the variable. (For example, later "<code>*p&nbsp;=&nbsp;50;</code>" assigns the value of 50 to the memory that "<code>p</code>" points to; it does not change the value of "<code>p</code>", which is still a pointer to an integer. In essence, it changed the integer that's being pointed to.)
<li><b>strdup():</b> A C function that allocates enough memory to store a copy of a string, copies the string to it, and returns a "<code>char&nbsp;*</code>" pointer to the new copy.
<li><b>strdup():</b> A C function that allocates enough memory to store a copy of a string, copies the string to it, and returns a "<code>char&nbsp;*</code>" pointer to the new copy. (See also the "<code>strdup(3)</code>" <i>man&nbsp;page</i>)
<li><b>struct:</b> See "C structure"
<li><b>The GIMP</b>: An Open&nbsp;Source image manipulation and paint program.
<li><b>tp_magic_api.h:</b> A header file that defines Tux&nbsp;Paint's Magic tool API. Plugins must '#include' it.
<li><b>tp-magic-config:</b> A command-line program that provides information about the installed version of Tux&nbsp;Paint to plugin developers (such as what C compiler flags they should compile with, and where plugin shared objects and data files should be installed).
<li><b>tp-magic-config:</b> A command-line program that provides information about the installed version of Tux&nbsp;Paint to plugin developers (such as what C compiler flags they should compile with, and where plugin shared objects and data files should be installed). (See also the "<code>tp-magic-config(3)</code>" <i>man&nbsp;page</i>.)
<li><b>Uint32:</b> A 32-bit, unsigned integer (defined by libSDL). In other words, four bytes that can represent 0 through 4294967295. (Typically used to hold enough information to store three or four bytes representing a pixel's color; i.e., RBGA value).
<li><b>Uint8:</b> An 8-bit, unsigned integer (defined by libSDL). In other words, a byte that can represent 0 through 255.
<li><b>unsigned:</b> <i>TBD</i>
<li><b>value:</b> See "HSV"
<li><b>variable:</b> <i>TBD</i>
<li><b>WAV:</b> <i>TBD</i>
<li><b>WAV:</b> <i>TBD</i> (See also "Ogg Vorbis")
<li><b>(w,h):</b> See "Dimensions"
<li><b>(x,y):</b> See "Coordinates"
</ul>