1 /* vim:expandtab:ts=2 sw=2: 2 */ 3 /* Grafx2 - The Ultimate 256-color bitmap paint program 4 5 Copyright owned by various GrafX2 authors, see COPYRIGHT.txt for details. 6 7 Grafx2 is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public License 9 as published by the Free Software Foundation; version 2 10 of the License. 11 12 Grafx2 is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Grafx2; if not, see <http://www.gnu.org/licenses/> 19 */ 20 21 ////////////////////////////////////////////////////////////////////////////// 22 ///@file graph.h 23 /// Graphic functions that target the screen and/or image. 24 ////////////////////////////////////////////////////////////////////////////// 25 26 #ifndef GRAPH_H__ 27 #define GRAPH_H__ 28 29 void Shade_list_to_lookup_tables(word * list, short step, byte mode, byte * table_inc, 30 byte * table_dec 31 ); 32 33 void Transform_point(short x, short y, 34 float cos_a, float sin_a, short * rx, short * ry); 35 36 int Init_mode_video(int width, int height, int fullscreen,int pixel_ratio); 37 38 byte No_effect(word x,word y,byte color); 39 byte Effect_shade(word x,word y,byte color); 40 byte Effect_quick_shade(word x,word y,byte color); 41 byte Effect_tiling(word x,word y,byte color); 42 byte Effect_smooth(word x,word y,byte color); 43 byte Effect_layer_copy(word x,word y,byte color); 44 45 void Display_foreback(void); 46 47 48 void Display_pixel(word x,word y,byte color); 49 50 void Display_paintbrush(short x,short y,byte color); 51 void Draw_paintbrush(short x,short y,byte color); 52 void Hide_paintbrush(short x,short y); 53 54 void Resize_image(word chosen_width,word chosen_height); 55 56 void Fill_general(byte fill_color); 57 void Replace(byte New_color); 58 59 void Pixel_figure_preview (word x_pos,word y_pos,byte color); 60 void Pixel_figure_preview_auto(word x_pos,word y_pos); 61 void Pixel_figure_preview_xor(word x_pos,word y_pos,byte color); 62 void Pixel_figure_preview_xorback(word x_pos,word y_pos,byte color); 63 void Pixel_figure_in_brush(word x_pos,word y_pos,byte color); 64 65 void Draw_empty_circle_general(short center_x,short center_y,long sqradius,byte color); 66 67 void Draw_empty_circle_permanent(short center_x,short center_y,long sqradius,byte color); 68 void Draw_empty_circle_preview (short center_x,short center_y,long sqradius,byte color); 69 void Hide_empty_circle_preview (short center_x,short center_y,long sqradius); 70 void Draw_empty_circle_general(short center_x,short center_y,long sqradius,byte color); 71 void Draw_filled_circle (short center_x,short center_y,long sqradius,byte color); 72 73 int Circle_squared_diameter(int diameter); 74 75 void Draw_empty_ellipse_permanent(short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color); 76 void Draw_empty_ellipse_preview (short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color); 77 void Hide_empty_ellipse_preview (short center_x,short center_y,short horizontal_radius,short vertical_radius); 78 void Draw_filled_ellipse (short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color); 79 80 void Draw_empty_inscribed_ellipse_permanent(short x1,short y1,short x2, short y2,byte color); 81 void Draw_empty_inscribed_ellipse_preview(short x1,short y1,short x2,short y2,byte color); 82 void Hide_empty_inscribed_ellipse_preview(short x1,short y1,short x2,short y2); 83 void Draw_filled_inscribed_ellipse(short x1,short y1,short x2,short y2,byte color); 84 85 void Clamp_coordinates_regular_angle(short ax, short ay, short* bx, short* by); 86 void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte color); 87 void Draw_line_permanent (short start_x,short start_y,short end_x,short end_y,byte color); 88 void Draw_line_preview (short start_x,short start_y,short end_x,short end_y,byte color); 89 void Draw_line_preview_xor(short start_x,short start_y,short end_x,short end_y,byte color); 90 void Draw_line_preview_xorback(short start_x,short start_y,short end_x,short end_y,byte color); 91 void Hide_line_preview (short start_x,short start_y,short end_x,short end_y); 92 93 void Draw_empty_rectangle(short start_x,short start_y,short end_x,short end_y,byte color); 94 void Draw_filled_rectangle(short start_x,short start_y,short end_x,short end_y,byte color); 95 96 void Draw_curve_permanent(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, byte color); 97 void Draw_curve_preview (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, byte color); 98 void Hide_curve_preview (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, byte color); 99 100 void Airbrush(short clicked_button); 101 102 void Gradient_basic (long index,short x_pos,short y_pos); 103 void Gradient_dithered (long index,short x_pos,short y_pos); 104 void Gradient_extra_dithered(long index,short x_pos,short y_pos); 105 void Degrade_aleatoire (long index,short x_pos,short y_pos); 106 107 void Draw_grad_circle (short center_x,short center_y,long sqradius,short spot_x,short spot_y); 108 void Draw_grad_ellipse(short center_x,short center_y,short horizontal_radius,short vertical_radius,short spot_x,short spot_y); 109 void Draw_grad_inscribed_ellipse(short x1, short y1, short x2, short y2, short spot_x, short spot_y); 110 void Draw_grad_rectangle(short rax,short ray,short rbx,short rby,short vax,short vay, short vbx, short vby); 111 112 void Polyfill_general(int vertices, short * points, int color); 113 void Polyfill(int vertices, short * points, int color); 114 115 /// Remap the spare page according to the main page's palette 116 void Remap_spare(void); 117 118 /// 119 /// All the figure-drawing functions work by calling this function for each 120 /// pixel to draw. Before calling these functions, you should assign 121 /// ::Pixel_figure depending on what you where you want to draw: 122 /// - ::Pixel_figure_preview : On screen. 123 /// - ::Pixel_figure_preview_xor : On screen, XORing the color. 124 /// - ::Pixel_figure_permanent : On screen and in the image. 125 /// - ::Pixel_figure_clear_preview : On screen, reverting to the image's pixels. 126 void Set_Pixel_figure(Func_pixel func); 127 128 void Update_part_of_screen(short x, short y, short width, short height); 129 130 void Redraw_grid(short x, short y, unsigned short w, unsigned short h); 131 132 void Pixel_in_spare(word x,word y, byte color); 133 void Pixel_in_current_layer(word x,word y, byte color); 134 void Pixel_in_layer(int layer, word x,word y, byte color); 135 byte Read_pixel_from_current_screen (word x,word y); 136 byte Read_pixel_from_current_layer(word x,word y); 137 byte Read_pixel_from_layer(int layer, word x,word y); 138 139 140 /// Paint a single pixel in image only. 141 #define Pixel_in_current_screen(x,y,c) Pixel_in_current_screen_with_opt_preview(x,y,c,0) 142 143 /// Paint a single pixel in image AND on screen. 144 #define Pixel_in_current_screen_with_preview(x,y,c) Pixel_in_current_screen_with_opt_preview(x,y,c,1) 145 146 /// Paint a single pixel in image AND optionnaly on screen. 147 extern Func_pixel_opt_preview Pixel_in_current_screen_with_opt_preview; 148 149 /// Update the pixel functions according to the current Image_mode. 150 /// Sets ::Pixel_in_current_screen and ::Pixel_in_current_screen_with_preview 151 /// through ::Pixel_in_current_screen_with_opt_preview 152 void Update_pixel_renderer(void); 153 154 void Update_color_hgr_pixel(word x, word y, int preview); 155 void Update_color_dhgr_pixel(word x, word y, int preview); 156 157 #endif 158