Brushes can include directional variations. (Implements RFE #1522694)

New brush: Angle Lines (directional)
This commit is contained in:
William Kendrick 2006-09-04 09:58:57 +00:00
parent 609a8d5104
commit 1f5665437e
6 changed files with 350 additions and 215 deletions

View file

@ -0,0 +1 @@
directional

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -68,14 +68,22 @@ $Id$
* Round erasers added. * Round erasers added.
* Brushes may be animated. * Brushes may be animated. (Implements RFE #1522694)
(Create an image (W*N) x H in size (where N is number of frames), (Create an image (W*N) x H in size (where N is number of frames),
then create a ".dat" file for the brush containing "frames=N". then create a ".dat" file for the brush containing "frames=N".
* Brushes can include directional variations. (Implements RFE #1522694)
(Create an image (W*3) x (H*3) in size, then create a ".dat" file
for the brush containing the line: "directional". Each of the 9
sectors corresponds to 8 different directions, and center.)
* New Brushes: * New Brushes:
------------ ------------
* Vines (animated) * Vines (animated)
* Angle Lines (directional)
* New Starter Images: * New Starter Images:
------------------- -------------------
* Shipwreck * Shipwreck

View file

@ -146,7 +146,7 @@ Brushes
Animated Brushes Animated Brushes
As of Tux Paint version 0.9.16, you may now create animated brushes. As of Tux Paint version 0.9.16, you may now create animated brushes.
As the brush is drawn, each frame of the animation is displayed. As the brush is used, each frame of the animation is drawn.
Lay each frame out across a wide PNG image. For example, if your Lay each frame out across a wide PNG image. For example, if your
brush is 30x30 and you have 5 frames, the image should be 150x30. brush is 30x30 and you have 5 frames, the image should be 150x30.
@ -154,293 +154,323 @@ Brushes
Add a line containing the line "frames=N" to the brush's data file, Add a line containing the line "frames=N" to the brush's data file,
where N is the number of frames in the brush. where N is the number of frames in the brush.
Place the brush image PNGs (and any data text files) in the "brushes" Directional Brushes
directory.
Note: If your new brushes all come out as solid squares or rectangles, As of Tux Paint version 0.9.16, you may now create directional
it's because you forgot to use alpha transparency! See the documentation brushes. As the brush is used, different shapes are drawn, depending
file "PNG.txt" for more information and tips. on the direction the brush is going.
The directional shapes are divided into a 3x3 square in a PNG image.
For example, if your brush is 30x30, the image should be 90x90, and
each of the direction's shapes placed in a 3x3 grid. The center
region is used for no motion. The top right is used for motion
that's both up, and to the right. And so on.
Add a line containing the line "directional" to the brush's data
file.
Animated Directional Brushes
You may mix both animated and directional features into one brush.
Use both options ("frames=N" and "directional"), in separate lines
in the brush's "".dat" file.
Lay the brush out so that each 3x3 set of directional shapes are
laid out across a wide PNG image. For example, if the brush is 30x30
and there are 5 frames, it would be 450x90. (The leftmost 150x90
pixels of the image represent the 9 direction shapes for the first
frame, for example.)
Place the brush image PNGs (and any data text files) in the "brushes"
directory.
Note: If your new brushes all come out as solid squares or rectangles,
it's because you forgot to use alpha transparency! See the
documentation file "PNG.txt" for more information and tips.
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Stamps Stamps
All stamp-related files go in the "stamps" directory. It's useful to All stamp-related files go in the "stamps" directory. It's useful to
create subdirectories and sub-subdirectories there to organize the create subdirectories and sub-subdirectories there to organize the
stamps. (For example, you can have a "holidays" folder with "halloween" stamps. (For example, you can have a "holidays" folder with
and "christmas" sub-folders.) "halloween" and "christmas" sub-folders.)
Images Images
Rubber Stamps in Tux Paint can be made up of a number of separate Rubber Stamps in Tux Paint can be made up of a number of separate
files. The one file that is required is, of course, the picture files. The one file that is required is, of course, the picture
itself. itself.
The Stamps used by Tux Paint are PNG pictures. They can be full-color The Stamps used by Tux Paint are PNG pictures. They can be
or greyscale. The alpha (transparency) of the PNG is used to determine full-color or greyscale. The alpha (transparency) of the PNG is used
the actual shape of the picture (otherwise you'll stamp a large to determine the actual shape of the picture (otherwise you'll stamp
rectangle on your drawings). a large rectangle on your drawings).
The PNGs can be any size, but in practice, a 100 pixels wide by The PNGs can be any size, but in practice, a 100 pixels wide by
100 pixels tall (100 x 100) is quite large for Tux Paint. 100 pixels tall (100 x 100) is quite large for Tux Paint.
Note: If your new stamps all have solid rectangular-shaped outlines of Note: If your new stamps all have solid rectangular-shaped outlines
a solid color (e.g., white or black), it's because you forgot to use of a solid color (e.g., white or black), it's because you forgot to
alpha transparency! See the documentation file "PNG.txt" for more use alpha transparency! See the documentation file "PNG.txt" for
information and tips. more information and tips.
Advanced Users: The Advanced Stamps HOWTO describes, in detail, how to Advanced Users: The Advanced Stamps HOWTO describes, in detail, how
make images which will scale perfectly when used as stamps in to make images which will scale perfectly when used as stamps in
Tux Paint. Tux Paint.
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Description Text Description Text
Text (".TXT") files with the same name as the PNG. (e.g., Text (".TXT") files with the same name as the PNG. (e.g.,
"picture.png"'s description is stored in "picture.txt" in the same "picture.png"'s description is stored in "picture.txt" in the same
directory.) directory.)
The first line of the text file will be used as the US English The first line of the text file will be used as the US English
description of the stamp's image. It must be encoded in UTF-8. description of the stamp's image. It must be encoded in UTF-8.
Language Support Language Support
Additional lines can be added to the text file to provide Additional lines can be added to the text file to provide
translations of the description, to be displayed when Tux Paint is translations of the description, to be displayed when Tux Paint is
running in a different locale (like French or Spanish). running in a different locale (like French or Spanish).
The beginning of the line should correspond to the language code of The beginning of the line should correspond to the language code
the language in question (e.g., "fr" for French, and "zh_tw" for of the language in question (e.g., "fr" for French, and "zh_tw"
Traditional Chinese), followed by ".utf8=" and the translated for Traditional Chinese), followed by ".utf8=" and the translated
description (encoded in UTF-8). description (encoded in UTF-8).
There are scripts in the "po" directory for converting the text There are scripts in the "po" directory for converting the text
files to PO format (and back) for easy translation to different files to PO format (and back) for easy translation to different
languages. Therefore you should never add or change translations in languages. Therefore you should never add or change translations
the .txt files directly. in the .txt files directly.
If no translation is available for the language Tux Paint is If no translation is available for the language Tux Paint is
currently running in, the US English text is used. currently running in, the US English text is used.
Windows Users Windows Users
Use NotePad or WordPad to edit/create these files. Be sure to save Use NotePad or WordPad to edit/create these files. Be sure to save
them as Plain Text, and make sure they have ".txt" at the end of the them as Plain Text, and make sure they have ".txt" at the end of
filename... the filename...
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Sound Effects Sound Effects
WAVE (".WAV") files with the same name as the PNG. (e.g., WAVE (".WAV") files with the same name as the PNG. (e.g.,
"picture.png"'s sound effect is the sound "picture.wav" in the same "picture.png"'s sound effect is the sound "picture.wav" in the same
directory.) directory.)
Language Support Language Support
For sounds for different locales (e.g., if the sound is someone For sounds for different locales (e.g., if the sound is someone
saying a word, and you want translated versions of the word said), saying a word, and you want translated versions of the word said),
also create WAV files with the locale's label in the filename, in also create WAV files with the locale's label in the filename, in
the form: "STAMP_LOCALE.wav" the form: "STAMP_LOCALE.wav"
"picture.png"'s sound effect, when Tux Paint is run in Spanish mode, "picture.png"'s sound effect, when Tux Paint is run in Spanish
would be "picture_es.wav". In French mode, "picture_fr.wav". And so mode, would be "picture_es.wav". In French mode, "picture_fr.wav".
on... And so on...
If no localized sound effect can be loaded, Tux Paint will attempt If no localized sound effect can be loaded, Tux Paint will attempt
to load the 'default' sound file. (e.g., "picture.wav") to load the 'default' sound file. (e.g., "picture.wav")
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Stamp Options Stamp Options
Aside from a graphical shape, a textual description, and a sound Aside from a graphical shape, a textual description, and a sound
effect, stamps can also be given other attributes. To do this, you effect, stamps can also be given other attributes. To do this, you
need to create a 'data file' for the stamp. need to create a 'data file' for the stamp.
A stamp data file is simply a text file containing the options. A stamp data file is simply a text file containing the options.
The file has the same name as the PNG image, but a ".dat" extension. The file has the same name as the PNG image, but a ".dat" extension.
(e.g., "picture.png"'s data file is the text file "picture.dat" in the (e.g., "picture.png"'s data file is the text file "picture.dat" in
same directory.) the same directory.)
Colored Stamps Colored Stamps
Stamps can be made to be either "colorable" or "tintable." Stamps can be made to be either "colorable" or "tintable."
Colorable Colorable
"Colorable" stamps they work much like brushes - you pick the "Colorable" stamps they work much like brushes - you pick the
stamp to get the shape, and then pick the color you want it to be. stamp to get the shape, and then pick the color you want it to
(Symbol stamps, like the mathematical and musical ones, are an be. (Symbol stamps, like the mathematical and musical ones, are
example.) an example.)
Nothing about the original image is used except the transparency Nothing about the original image is used except the transparency
(from "alpha" channel). The color of the stamp comes out solid. (from "alpha" channel). The color of the stamp comes out solid.
Add a line containing the word "colorable" to the stamp's data Add a line containing the word "colorable" to the stamp's data
file. file.
Tinted Tinted
"Tinted" stamps are similar to "colorable" ones, except the "Tinted" stamps are similar to "colorable" ones, except the
details of the original image are kept. (To put it technically, details of the original image are kept. (To put it technically,
the original image is used, but its hue is changed, based on the the original image is used, but its hue is changed, based on the
currently-selected color.) currently-selected color.)
Add a line containing the word "tintable" to the stamp's data Add a line containing the word "tintable" to the stamp's data
file. file.
Tinting Options: Tinting Options:
Depending on the contents of your stamp, you might want to have Depending on the contents of your stamp, you might want to
Tux Paint use one of a numer of methods when tinting it. Add one have Tux Paint use one of a numer of methods when tinting it.
of the following lines to the stamp's data file: Add one of the following lines to the stamp's data file:
"tinter=normal" (default) "tinter=normal" (default)
This is the normal tinting mode. This is the normal tinting mode.
"tinter=anyhue" "tinter=anyhue"
This is ???. This is ???.
"tinter=narrow" "tinter=narrow"
This is ???. This is ???.
"tinter=vector" "tinter=vector"
This is ???. This is ???.
Unalterable Stamps Unalterable Stamps
By default, a stamp can be flipped upside down, shown as a mirror By default, a stamp can be flipped upside down, shown as a mirror
image, or both. This is done using the control buttons below the image, or both. This is done using the control buttons below the
stamp selector, at the lower right side of the screen in Tux Paint. stamp selector, at the lower right side of the screen in
Tux Paint.
Sometimes, it doesn't make sense for a stamp to be flippable or Sometimes, it doesn't make sense for a stamp to be flippable or
mirrored; for example, stamps of letters or numbers. Sometimes mirrored; for example, stamps of letters or numbers. Sometimes
stamps are symmetrical, so letting the user flip or mirror them stamps are symmetrical, so letting the user flip or mirror them
isn't useful. isn't useful.
To make a stamp un-flippable, add the option "noflip" to the stamp's To make a stamp un-flippable, add the option "noflip" to the
data file. stamp's data file.
To keep a stamp from being mirrored, add a line containing the word To keep a stamp from being mirrored, add a line containing the
"nomirror" to the stamp's data file. word "nomirror" to the stamp's data file.
Initial Stamp Size Initial Stamp Size
By default, Tux Paint assumes that your stamp is sized appropriately By default, Tux Paint assumes that your stamp is sized
for unscaled display on a 608x472 canvas. This is the original appropriately for unscaled display on a 608x472 canvas. This is
Tux Paint canvas size, provided by a 640x480 screen. Tux Paint will the original Tux Paint canvas size, provided by a 640x480 screen.
then adjust the stamp according to the current canvas size and, if Tux Paint will then adjust the stamp according to the current
enabled, the user's stamp size controls. canvas size and, if enabled, the user's stamp size controls.
If your stamp would be too big or too small, you can specify a scale If your stamp would be too big or too small, you can specify a
factor. If your stamp would be 2.5 times as wide (or tall) as it scale factor. If your stamp would be 2.5 times as wide (or tall)
should be, add the option "scale 40%" or "scale 5/2" or "scale 2.5" as it should be, add the option "scale 40%" or "scale 5/2" or
or "scale 2:5" to your image. You may include an "=" if you wish, as "scale 2.5" or "scale 2:5" to your image. You may include an "="
in "scale=40%". if you wish, as in "scale=40%".
Windows Users Windows Users
You can use NotePad or WordPad to create these file. Be sure to save You can use NotePad or WordPad to create these file. Be sure to
it as Plain Text, and make sure the filename has ".dat" at the end, save it as Plain Text, and make sure the filename has ".dat" at
and not ".txt"... the end, and not ".txt"...
Pre-Mirrored Images Pre-Mirrored Images
In some cases, you may wish to provide a pre-drawn version of a In some cases, you may wish to provide a pre-drawn version of a
stamp's mirror-image. For example, imagine a picture of a fire truck stamp's mirror-image. For example, imagine a picture of a fire truck
with the words "Fire Department" written across the side. You probably with the words "Fire Department" written across the side. You
do not want that text to appear backwards when the image is flipped! probably do not want that text to appear backwards when the image is
flipped!
To create a mirrored version of a stamp that you want Tux Paint to To create a mirrored version of a stamp that you want Tux Paint to
use, rather than mirroring one on its own, simply create a second use, rather than mirroring one on its own, simply create a second
".png" graphics file with the same name, except with the string ".png" graphics file with the same name, except with the string
"_mirror" before the filename extension. "_mirror" before the filename extension.
For example, for the stamp "truck.png" you would create another file For example, for the stamp "truck.png" you would create another file
named "truck_mirror.png", which will be used when the stamp is named "truck_mirror.png", which will be used when the stamp is
mirrored (rather than using a backwards version of 'truck.png'). mirrored (rather than using a backwards version of 'truck.png').
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Fonts Fonts
The fonts used by Tux Paint are TrueType Fonts (TTF). The fonts used by Tux Paint are TrueType Fonts (TTF).
Simply place them in the "fonts" directory. Tux Paint will load the font Simply place them in the "fonts" directory. Tux Paint will load the
and provide four different sizes in the 'Letters' selector when using font and provide four different sizes in the 'Letters' selector when
the 'Text' tool. using the 'Text' tool.
-------------------------------------------------------------------------- --------------------------------------------------------------------------
'Starters' 'Starters'
'Starter' images appear in the 'Open' dialog, along with pictures you've 'Starter' images appear in the 'Open' dialog, along with pictures
created. They have a green button background, instead of blue. you've created. They have a green button background, instead of blue.
Unlike your saved pictures, however, when you select and open a Unlike your saved pictures, however, when you select and open a
'starter,' you're actually creating a new drawing. Instead of being 'starter,' you're actually creating a new drawing. Instead of being
blank, though, the new drawing contains the contents of the 'starter.' blank, though, the new drawing contains the contents of the 'starter.'
Additionally, as you edit your new picture, the contents of the original Additionally, as you edit your new picture, the contents of the
'starter' affect it. original 'starter' affect it.
Coloring-Book Style Coloring-Book Style
The most basic kind of 'starter' is similar to a picture in a coloring The most basic kind of 'starter' is similar to a picture in a
book. It's an outline of a shape which you can then color in and add coloring book. It's an outline of a shape which you can then color
details to. In Tux Paint, as you draw, type text, or stamp stamps, the in and add details to. In Tux Paint, as you draw, type text, or
outline remains 'above' what you draw. You can erase the parts of the stamp stamps, the outline remains 'above' what you draw. You can
drawing you made, but you can't erase the outline. erase the parts of the drawing you made, but you can't erase the
outline.
To create this kind of 'starter' image, simply draw an outlined To create this kind of 'starter' image, simply draw an outlined
picture in a paint program, make the rest of the graphic transparent picture in a paint program, make the rest of the graphic transparent
(that will come out as white in Tux Paint), and save it as a PNG (that will come out as white in Tux Paint), and save it as a PNG
format file. format file.
Scene-Style Scene-Style
Along with the 'coloring-book' style overlay, you can also provide a Along with the 'coloring-book' style overlay, you can also provide a
separate background image as part of a 'starter' picture. The overlay separate background image as part of a 'starter' picture. The
acts the same: it can't be drawn over, erased, or affected by 'Magic' overlay acts the same: it can't be drawn over, erased, or affected
tools. However, the background can be! by 'Magic' tools. However, the background can be!
When the 'Eraser' tool is used on a picture based on this kind of When the 'Eraser' tool is used on a picture based on this kind of
'starter' image, rather than turning the canvas white, it returns that 'starter' image, rather than turning the canvas white, it returns
part of the canvas to the original background picture. that part of the canvas to the original background picture.
By creating both an overlay and a background, you can create a By creating both an overlay and a background, you can create a
'starter' which simulates depth. Imagine a background that shows the 'starter' which simulates depth. Imagine a background that shows the
ocean, and an overlay that's a picture of a reef. You can then draw ocean, and an overlay that's a picture of a reef. You can then draw
(or stamp) fish in the picture. They'll appear in the ocean, but never (or stamp) fish in the picture. They'll appear in the ocean, but
'in front of' the reef. never 'in front of' the reef.
To create this kind of 'starter' picture, simply create an overlay To create this kind of 'starter' picture, simply create an overlay
(with alpha transparency) as described above, and save it as a PNG. (with alpha transparency) as described above, and save it as a PNG.
Then create another image (without transparency), and save it with the Then create another image (without transparency), and save it with
same filename, but with "-back" appended to the name. (e.g., the same filename, but with "-back" appended to the name. (e.g.,
"reef-back.png" would be the background ocean picture that corresponds "reef-back.png" would be the background ocean picture that
to the "reef.png" overlay, or foreground.) corresponds to the "reef.png" overlay, or foreground.)
The 'starter' images should be the same size as Tux Paint's canvas. In The 'starter' images should be the same size as Tux Paint's canvas. In
the default 640x480 mode, that is 448x376 pixels. If you're using the default 640x480 mode, that is 448x376 pixels. If you're using
800x600 mode, it should be 608x496. (It should be 192 pixels less wide, 800x600 mode, it should be 608x496. (It should be 192 pixels less
and 104 pixels less tall than the resolution.) wide, and 104 pixels less tall than the resolution.)
Place them in the "starters" directory. When the 'Open' dialog is Place them in the "starters" directory. When the 'Open' dialog is
accessed in Tux Paint, the 'starter' images will appear at the beginning accessed in Tux Paint, the 'starter' images will appear at the
of the list with a green background. beginning of the list with a green background.
Note: 'Starters' can't be saved over from within Tux Paint, since Note: 'Starters' can't be saved over from within Tux Paint, since
loading a 'starter' is really like creating a new image. (Instead of loading a 'starter' is really like creating a new image. (Instead of
being blank, though there's already something there to work with.) The being blank, though there's already something there to work with.) The
'Save' command simply creates a new picture, like it would if the 'New' 'Save' command simply creates a new picture, like it would if the
command had been used. 'New' command had been used.
Note: 'Starters' are 'attached' to saved pictures, via a small text file Note: 'Starters' are 'attached' to saved pictures, via a small text
that has the same name as the saved file, but with ".dat" as the file that has the same name as the saved file, but with ".dat" as the
extension. This allows the overlay and background, if any, to continue extension. This allows the overlay and background, if any, to continue
to affect the drawing even after Tux Paint has been quit, or another to affect the drawing even after Tux Paint has been quit, or another
picture loaded or started. (In other words, if you base a drawing on a picture loaded or started. (In other words, if you base a drawing on a
'starter' image, it will always be affected by it.) 'starter' image, it will always be affected by it.)

View file

@ -219,8 +219,8 @@ effect.</p>
<h4>Animated Brushes</h4> <h4>Animated Brushes</h4>
<blockquote> <blockquote>
<p>As of Tux&nbsp;Paint version 0.9.16, you may now create animated <p>As of Tux&nbsp;Paint version 0.9.16, you may now create animated
brushes. As the brush is drawn, each frame of the animation is brushes. As the brush is used, each frame of the animation is
displayed.</p> drawn.</p>
<p>Lay each frame out across a wide PNG image. For example, <p>Lay each frame out across a wide PNG image. For example,
if your brush is 30x30 and you have 5 frames, the image should if your brush is 30x30 and you have 5 frames, the image should
@ -230,6 +230,35 @@ effect.</p>
to the brush's data file, where <i>N</i> is the number of frames to the brush's data file, where <i>N</i> is the number of frames
in the brush.</p> in the brush.</p>
</blockquote> </blockquote>
<h4>Directional Brushes</h4>
<blockquote>
<p>As of Tux&nbsp;Paint version 0.9.16, you may now create directional
brushes. As the brush is used, different shapes are drawn, depending
on the direction the brush is going.</p>
<p>The directional shapes are divided into a 3x3 square in a PNG image.
For example, if your brush is 30x30, the image should be 90x90, and
each of the direction's shapes placed in a 3x3 grid. The center
region is used for no motion. The top right is used for motion that's
both up, and to the right. And so on.</p>
<p>Add a line containing the line "<code><b>directional</b></code>"
to the brush's data file.</p>
</blockquote>
<h4>Animated Directional Brushes</h4>
<blockquote>
<p>You may mix both animated and directional features into one
brush. Use both options ("<code><b>frames=<i>N</i></b></code>" and
"<code><b>directional</b></code>"), in separate lines in the
brush's "<code>".dat</code>" file.</p>
<p>Lay the brush out so that each 3x3 set of directional shapes are
laid out across a wide PNG image. For example, if the brush is 30x30
and there are 5 frames, it would be 450x90. (The leftmost 150x90 pixels
of the image represent the 9 direction shapes for the first frame,
for example.)</p>
</blockquote> </blockquote>
<p>Place the brush image PNGs (and any data text files) in the <p>Place the brush image PNGs (and any data text files) in the

View file

@ -971,13 +971,26 @@ static SDL_Surface *img_color_btn_off;
static int colors_are_selectable; static int colors_are_selectable;
enum {
BRUSH_DIRECTION_RIGHT,
BRUSH_DIRECTION_DOWN_RIGHT,
BRUSH_DIRECTION_DOWN,
BRUSH_DIRECTION_DOWN_LEFT,
BRUSH_DIRECTION_LEFT,
BRUSH_DIRECTION_UP_LEFT,
BRUSH_DIRECTION_UP,
BRUSH_DIRECTION_UP_RIGHT,
BRUSH_DIRECTION_NONE
};
static SDL_Surface *img_cur_brush; static SDL_Surface *img_cur_brush;
int img_cur_brush_w, img_cur_brush_h, img_cur_brush_frames; int img_cur_brush_frame_w, img_cur_brush_w, img_cur_brush_h,
img_cur_brush_frames, img_cur_brush_directional;
static int brush_counter, rainbow_color, brush_frame; static int brush_counter, rainbow_color, brush_frame;
#define NUM_ERASERS 12 /* How many sizes of erasers #define NUM_ERASERS 12 /* How many sizes of erasers
(from ERASER_MIN to _MAX as squares, then again (from ERASER_MIN to _MAX as squares, then again
from ERASER_MIN to _MAX as circles) */ from ERASER_MIN to _MAX as circles) */
#define ERASER_MIN 13 #define ERASER_MIN 13
#define ERASER_MAX 128 #define ERASER_MAX 128
@ -1039,7 +1052,7 @@ typedef struct dirent2
static void mainloop(void); static void mainloop(void);
static void brush_draw(int x1, int y1, int x2, int y2, int update); static void brush_draw(int x1, int y1, int x2, int y2, int update);
static void blit_brush(int x, int y); static void blit_brush(int x, int y, int direction);
static void magic_draw(int x1, int y1, int x2, int y2, int button_down); static void magic_draw(int x1, int y1, int x2, int y2, int button_down);
static void blit_magic(int x, int y, int button_down); static void blit_magic(int x, int y, int button_down);
static void stamp_draw(int x, int y); static void stamp_draw(int x, int y);
@ -3393,12 +3406,14 @@ static void draw_blinking_cursor(void)
TTF_FontHeight(getfonthandle(cur_font))); TTF_FontHeight(getfonthandle(cur_font)));
} }
/* Draw using the current brush: */ /* Draw using the current brush: */
static void brush_draw(int x1, int y1, int x2, int y2, int update) static void brush_draw(int x1, int y1, int x2, int y2, int update)
{ {
int dx, dy, y, w, h; int dx, dy, y, frame_w, w, h;
int orig_x1, orig_y1, orig_x2, orig_y2, tmp; int orig_x1, orig_y1, orig_x2, orig_y2, tmp;
int direction, r;
float m, b; float m, b;
orig_x1 = x1; orig_x1 = x1;
@ -3408,9 +3423,10 @@ static void brush_draw(int x1, int y1, int x2, int y2, int update)
orig_y2 = y2; orig_y2 = y2;
w = img_brushes[cur_brush]->w / brushes_frames[cur_brush]; frame_w = img_brushes[cur_brush]->w / brushes_frames[cur_brush];
w = frame_w / (brushes_directional[cur_brush] ? 3: 1);
h = img_brushes[cur_brush]->h / (brushes_directional[cur_brush] ? 3 : 1); h = img_brushes[cur_brush]->h / (brushes_directional[cur_brush] ? 3 : 1);
x1 = x1 - (w >> 1); x1 = x1 - (w >> 1);
y1 = y1 - (h >> 1); y1 = y1 - (h >> 1);
@ -3418,6 +3434,18 @@ static void brush_draw(int x1, int y1, int x2, int y2, int update)
y2 = y2 - (h >> 1); y2 = y2 - (h >> 1);
direction = BRUSH_DIRECTION_NONE;
if (brushes_directional[cur_brush])
{
r = rotation(x1, y1, x2, y2) + 22;
if (r < 0)
r = r + 360;
if (x1 != x2 || y1 != y2)
direction = (r / 45);
}
dx = x2 - x1; dx = x2 - x1;
dy = y2 - y1; dy = y2 - y1;
@ -3445,7 +3473,7 @@ static void brush_draw(int x1, int y1, int x2, int y2, int update)
} }
for (y = y1; y <= y2; y++) for (y = y1; y <= y2; y++)
blit_brush(x1, y); blit_brush(x1, y, direction);
x1 = x1 + dx; x1 = x1 + dx;
} }
@ -3460,7 +3488,7 @@ static void brush_draw(int x1, int y1, int x2, int y2, int update)
} }
for (y = y1; y <= y2; y++) for (y = y1; y <= y2; y++)
blit_brush(x1, y); blit_brush(x1, y, direction);
} }
if (orig_x1 > orig_x2) if (orig_x1 > orig_x2)
@ -3501,7 +3529,7 @@ void reset_brush_counter(void)
/* Draw the current brush in the current color: */ /* Draw the current brush in the current color: */
static void blit_brush(int x, int y) static void blit_brush(int x, int y, int direction)
{ {
SDL_Rect src, dest; SDL_Rect src, dest;
@ -3518,8 +3546,52 @@ static void blit_brush(int x, int y)
dest.x = x; dest.x = x;
dest.y = y; dest.y = y;
src.x = brush_frame * img_cur_brush_w; if (img_cur_brush_directional)
src.y = 0; {
if (direction == BRUSH_DIRECTION_UP_LEFT ||
direction == BRUSH_DIRECTION_UP ||
direction == BRUSH_DIRECTION_UP_RIGHT)
{
src.y = 0;
}
else if (direction == BRUSH_DIRECTION_LEFT ||
direction == BRUSH_DIRECTION_NONE ||
direction == BRUSH_DIRECTION_RIGHT)
{
src.y = img_cur_brush_h;
}
else if (direction == BRUSH_DIRECTION_DOWN_LEFT ||
direction == BRUSH_DIRECTION_DOWN ||
direction == BRUSH_DIRECTION_DOWN_RIGHT)
{
src.y = img_cur_brush_h << 1;
}
if (direction == BRUSH_DIRECTION_UP_LEFT ||
direction == BRUSH_DIRECTION_LEFT ||
direction == BRUSH_DIRECTION_DOWN_LEFT)
{
src.x = brush_frame * img_cur_brush_frame_w;
}
else if (direction == BRUSH_DIRECTION_UP ||
direction == BRUSH_DIRECTION_NONE ||
direction == BRUSH_DIRECTION_DOWN)
{
src.x = brush_frame * img_cur_brush_frame_w + img_cur_brush_w;
}
else if (direction == BRUSH_DIRECTION_UP_RIGHT ||
direction == BRUSH_DIRECTION_RIGHT ||
direction == BRUSH_DIRECTION_DOWN_RIGHT)
{
src.x = brush_frame * img_cur_brush_frame_w + (img_cur_brush_w << 1);
}
}
else
{
src.x = brush_frame * img_cur_brush_w;
src.y = 0;
}
src.w = img_cur_brush_w; src.w = img_cur_brush_w;
src.h = img_cur_brush_h; src.h = img_cur_brush_h;
@ -5206,7 +5278,7 @@ static void loadbrush_callback(SDL_Surface * screen,
brushes_frames[num_brushes] = brushes_frames[num_brushes] =
atoi(strstr(buf, "frames=") + 7); atoi(strstr(buf, "frames=") + 7);
} }
else if (strstr(buf, "directional=yes") != NULL) else if (strstr(buf, "directional") != NULL)
{ {
brushes_directional[num_brushes] = 1; brushes_directional[num_brushes] = 1;
} }
@ -7494,23 +7566,15 @@ static void draw_brushes(void)
if (brush < num_brushes) if (brush < num_brushes)
{ {
dest.x = ((i % 2) * 48) + (WINDOW_WIDTH - 96) +
((48 - (img_brushes[brush]->w / brushes_frames[brush])) >> 1);
/* FIXME: Shouldn't that be ->h??? */
dest.y =
((i / 2) * 48) + 40 +
((48 - (img_brushes[brush]->h /
(brushes_directional[brush] ? 3 : 1))) >> 1) +
off_y;
src.x = 0; src.x = 0;
src.y = 0; src.y = brushes_directional[brush] ? (img_brushes[brush]->h / 3) : 0;
src.w = img_brushes[brush]->w / brushes_frames[brush]; src.w = img_brushes[brush]->w / brushes_frames[brush];
src.h = (img_brushes[brush]->h / (brushes_directional[brush] ? 3 : 1)); src.h = (img_brushes[brush]->h / (brushes_directional[brush] ? 3 : 1));
dest.x = ((i % 2) * 48) + (WINDOW_WIDTH - 96) + ((48 - src.w) >> 1);
dest.y = ((i / 2) * 48) + 40 + ((48 - src.h) >> 1) + off_y;
SDL_BlitSurface(img_brushes[brush], &src, screen, &dest); SDL_BlitSurface(img_brushes[brush], &src, screen, &dest);
} }
} }
@ -8578,9 +8642,12 @@ static void render_brush(void)
SDL_UnlockSurface(img_cur_brush); SDL_UnlockSurface(img_cur_brush);
SDL_UnlockSurface(img_brushes[cur_brush]); SDL_UnlockSurface(img_brushes[cur_brush]);
img_cur_brush_w = img_cur_brush->w / brushes_frames[cur_brush]; img_cur_brush_frame_w = img_cur_brush->w / brushes_frames[cur_brush];
img_cur_brush_w = img_cur_brush_frame_w /
(brushes_directional[cur_brush] ? 3 : 1);
img_cur_brush_h = img_cur_brush->h / (brushes_directional[cur_brush] ? 3 : 1); img_cur_brush_h = img_cur_brush->h / (brushes_directional[cur_brush] ? 3 : 1);
img_cur_brush_frames = brushes_frames[cur_brush]; img_cur_brush_frames = brushes_frames[cur_brush];
img_cur_brush_directional = brushes_directional[cur_brush];
brush_counter = 0; brush_counter = 0;
} }