GrafX2 2.9.3227
The ultimate 256-color painting program
brush.h File Reference

Actions on the brush. More...

#include "struct.h"
+ Include dependency graph for brush.h:
+ This graph shows which files directly or indirectly include this file:

Functions

void Capture_brush (short start_x, short start_y, short end_x, short end_y, short clear)
 Gets the brush from the picture. More...
 
void Rotate_90_deg (void)
 Rotates the brush to the right. More...
 
void Stretch_brush (short x1, short y1, short x2, short y2)
 Stretch the brush to fit the given rectangle. More...
 
void Stretch_brush_preview (short x1, short y1, short x2, short y2)
 Stretch the brush to fit the given rectangle. More...
 
void Rotate_brush (float angle)
 Rotates the brush to the right from the given angle. More...
 
void Rotate_brush_preview (float angle)
 Stretch the brush to fit the given rectangle. More...
 
void Distort_brush_preview (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4)
 Remap the brush palette to the nearest color in the picture one. More...
 
void Distort_brush (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4)
 Replace the brush by a distorted version of itself. More...
 
void Remap_brush (void)
 
void Get_colors_from_brush (void)
 Get color indexes used by the brush. More...
 
void Outline_brush (void)
 Outline the brush, add 1 foreground-colored pixel on the edges. More...
 
void Nibble_brush (void)
 Nibble the brush, remove 1 pixel on the edges and make it transparent (ie filled with back color). More...
 
void Capture_brush_with_lasso (int vertices, short *points, short clear)
 Get brush from picture according to a freehand form. More...
 
byte Realloc_brush (word new_brush_width, word new_brush_height, byte *new_brush, byte **old_brush)
 Allocates memory for a brush size change. More...
 
void Brush_set_palette (T_Palette *palette)
 Sets brush's original palette and color mapping. More...
 
void Begin_brush_rotation (void)
 
void End_brush_rotation (void)
 

Detailed Description

Actions on the brush.

Function Documentation

◆ Capture_brush()

void Capture_brush ( short  start_x,
short  start_y,
short  end_x,
short  end_y,
short  clear 
)

Gets the brush from the picture.

Parameters
start_xleft edge coordinate in the picture
start_yupper edge coordinate in the picture
end_xright edge coordinate in the picture
end_ybottom edge coordinate in the picture
clearIf 1, the area is also cleared from the picture.

References Back_color, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_palette, Brush_width, Copy_image_to_brush(), T_Document::image_height, T_Document::image_width, Main, NULL, T_Document::palette, Pixel_in_current_screen_with_preview, Realloc_brush(), Remap_brush(), Tilemap_draw(), T_Document::tilemap_mode, Tiling_offset_X, Tiling_offset_Y, and Update_part_of_screen().

Referenced by Brush_0_5(), and Init_program().

◆ Rotate_90_deg()

◆ Stretch_brush()

void Stretch_brush ( short  x1,
short  y1,
short  x2,
short  y2 
)

◆ Stretch_brush_preview()

void Stretch_brush_preview ( short  x1,
short  y1,
short  x2,
short  y2 
)

Stretch the brush to fit the given rectangle.

Uses fast approximation for the preview while drawing the rectangle on screen.

References Back_color, Brush_height, Brush_width, Limit_left, Limit_top, Limit_visible_bottom, Limit_visible_right, Max(), Min(), Pixel_preview, Read_pixel_from_brush(), and Update_part_of_screen().

Referenced by Stretch_brush_0_7(), and Stretch_brush_1_7().

◆ Rotate_brush()

◆ Rotate_brush_preview()

void Rotate_brush_preview ( float  angle)

Stretch the brush to fit the given rectangle.

Uses fast approximation for the preview while changing the angle.

References Brush_height, Brush_rotate_buffer, Brush_rotate_height, Brush_rotate_width, Brush_rotation_center_X, Brush_rotation_center_Y, Brush_width, Draw_quad_texture_preview(), Max(), Min(), Transform_point(), and Update_part_of_screen().

Referenced by Rotate_brush_0_5(), and Rotate_brush_1_5().

◆ Distort_brush_preview()

void Distort_brush_preview ( short  x1,
short  y1,
short  x2,
short  y2,
short  x3,
short  y3,
short  x4,
short  y4 
)

Remap the brush palette to the nearest color in the picture one.

Used when switching to the spare page.

Distort the brush on the screen.

Remap the brush palette to the nearest color in the picture one.

References Brush, Brush_height, Brush_width, Distort_source, Draw_brush_linear_distort(), Pixel_figure_preview(), and Pixel_for_distort.

Referenced by Distort_brush_1_0(), and Distort_brush_1_9().

◆ Distort_brush()

void Distort_brush ( short  x1,
short  y1,
short  x2,
short  y2,
short  x3,
short  y3,
short  x4,
short  y4 
)

◆ Remap_brush()

◆ Get_colors_from_brush()

◆ Outline_brush()

void Outline_brush ( void  )

Outline the brush, add 1 foreground-colored pixel on the edges.

Edges are detected considering the backcolor as transparent.

References Back_color, Brush, Brush_colormap, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_palette, Brush_original_pixels, Brush_width, Copy_part_of_image_to_another(), Error, Fore_color, Main, NULL, T_Document::palette, Pixel_in_brush(), Realloc_brush(), and SWAP_PBYTES.

Referenced by Button_Brush_FX(), and Main_handler().

◆ Nibble_brush()

void Nibble_brush ( void  )

Nibble the brush, remove 1 pixel on the edges and make it transparent (ie filled with back color).

Edges are detected considering the backcolor as transparent.

References Back_color, Brush, Brush_colormap, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_palette, Brush_original_pixels, Brush_width, Copy_part_of_image_to_another(), Error, Main, NULL, T_Document::palette, Pixel_in_brush(), Realloc_brush(), and SWAP_PBYTES.

Referenced by Button_Brush_FX(), and Main_handler().

◆ Capture_brush_with_lasso()

void Capture_brush_with_lasso ( int  vertices,
short *  points,
short  clear 
)

◆ Realloc_brush()

byte Realloc_brush ( word  new_brush_width,
word  new_brush_height,
byte new_brush,
byte **  old_brush 
)

Allocates memory for a brush size change.

This function can return the old brush pixels which can then be used by the caller to fill the new brush. Data is not automatically copied or converted from the old brush to the new one here.

Parameters
new_brush_widthnew width of the brush
new_brush_heightnew height of the brush
new_brushOptionally, you can provide an already allocated new brush - otherwise, this function performs the allocation.
old_brushIf the caller passes NULL, this function will free the old pixel data. If the caller provides the address of a (free) byte pointer, the function will make it point to the original pixel data, in this case it will be the caller's responsibility to free() it (after transferring pixels to Brush, usually).
Returns
0 on success, non-zero when running out of memory.

References Back_color, Brush, Brush_height, Brush_original_back_color, Brush_original_pixels, Brush_width, Error, MAX_PAINTBRUSH_SIZE, NULL, Smear_brush, Smear_brush_height, and Smear_brush_width.

Referenced by Button_Sieve_menu(), Button_Text(), Capture_brush(), Capture_brush_with_lasso(), Distort_brush(), Load_image(), Nibble_brush(), Outline_brush(), Restore_brush(), Rotate_90_deg(), Rotate_brush(), and Stretch_brush().

◆ Brush_set_palette()

void Brush_set_palette ( T_Palette palette)

Sets brush's original palette and color mapping.

◆ Begin_brush_rotation()

◆ End_brush_rotation()

void End_brush_rotation ( void  )