1 /*****************************************************************************
2 * puzzle_pce.h : Puzzle game filter - pieces functions
3 *****************************************************************************
4 * Copyright (C) 2013 Vianney Boyer
7 * Author: Vianney Boyer <vlcvboyer -at- gmail -dot- com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #ifndef VLC_LIB_PUZZLE_PCE_H
28 #define VLC_LIB_PUZZLE_PCE_H 1
30 #include <vlc_common.h>
31 #include <vlc_filter.h>
33 #include "puzzle_bezier.h"
34 #include "puzzle_lib.h"
37 #define PIECE_TYPE_NBR (4*2*(1+SHAPES_QTY))
39 #define puzzle_SHAPE_TOP 1
40 #define puzzle_SHAPE_LEFT 2
41 #define puzzle_SHAPE_RIGHT 4
42 #define puzzle_SHAPE_BTM 8
44 /*****************************************************************************
46 *****************************************************************************/
49 uint8_t i_type
; /* 0 = fill ; 1 = offset */
54 int32_t i_section_nbr
;
55 row_section_t
*ps_row_section
;
60 int32_t i_first_row_offset
;
61 piece_shape_row_t
*ps_piece_shape_row
;
65 int32_t i_original_x
, i_original_y
;
66 int32_t i_actual_x
, i_actual_y
;
67 int32_t i_width
, i_lines
;
71 int32_t i_original_row
, i_original_col
;
73 int32_t i_top_shape
, i_btm_shape
, i_right_shape
, i_left_shape
;
75 piece_in_plane_t
*ps_piece_in_plane
;
80 int8_t i_actual_angle
; /* 0 = 0°, 1 = 90°... rotation center = top-left corner */
81 int32_t i_actual_mirror
; /* +1 = without mirror ; -1 = with mirror */
82 int32_t i_step_x_x
, i_step_x_y
, i_step_y_y
, i_step_y_x
;
83 int32_t i_ORx
, i_OTy
, i_OLx
, i_OBy
; /* location of original piece's edges */
84 int32_t i_TLx
, i_TLy
, i_TRx
, i_TRy
, i_BLx
, i_BLy
, i_BRx
, i_BRy
; /* location of grabed piece's corners */
85 int32_t i_max_x
, i_min_x
, i_max_y
, i_min_y
, i_center_x
, i_center_y
;
90 int puzzle_bake_pieces_shapes ( filter_t
* );
91 void puzzle_free_ps_pieces_shapes ( filter_t
* );
93 int puzzle_find_piece( filter_t
*p_filter
, int32_t i_x
, int32_t i_y
, int32_t i_except
);
94 void puzzle_calculate_corners( filter_t
*, int32_t i_piece
);
95 void puzzle_rotate_pce( filter_t
*p_filter
, int32_t i_piece
, int8_t i_rotate_mirror
, int32_t i_center_x
, int32_t i_center_y
, bool b_avoid_mirror
);
96 void puzzle_move_group( filter_t
*p_filter
, int32_t i_piece
, int32_t i_dx
, int32_t i_dy
);
98 void puzzle_drw_basic_pce_in_plane( filter_t
*p_filter
, picture_t
*p_pic_in
, picture_t
*p_pic_out
, uint8_t i_plane
, piece_t
*ps_piece
);
99 void puzzle_drw_adv_pce_in_plane( filter_t
*p_filter
, picture_t
*p_pic_in
, picture_t
*p_pic_out
, uint8_t i_plane
, piece_t
*ps_piece
);
100 void puzzle_drw_complex_pce_in_plane( filter_t
*p_filter
, picture_t
*p_pic_in
, picture_t
*p_pic_out
, uint8_t i_plane
, piece_t
*ps_piece
, uint32_t i_pce
);
101 void puzzle_draw_pieces( filter_t
*p_filter
, picture_t
*p_pic_in
, picture_t
*p_pic_out
);
102 int32_t puzzle_diagonal_limit( filter_t
*p_filter
, int32_t i_y
, bool b_left
, uint8_t i_plane
);
104 int puzzle_generate_sect_border( filter_t
*p_filter
, piece_shape_t
*ps_piece_shape
, uint8_t i_plane
, uint8_t i_border
);
105 int puzzle_generate_sect_bezier( filter_t
*p_filter
, piece_shape_t
*ps_piece_shape
, uint8_t i_pts_nbr
, point_t
*ps_pt
, uint8_t i_plane
, uint8_t i_border
);
106 void puzzle_get_min_bezier(float *f_min_curve_x
, float *f_min_curve_y
, float f_x_ratio
, float f_y_ratio
, point_t
*ps_pt
, uint8_t i_pts_nbr
);
107 int puzzle_generate_shape_lines( filter_t
*p_filter
, piece_shape_t
*ps_piece_shape
, int32_t i_min_y
, int32_t i_nb_y
, float f_x_ratio
, float f_y_ratio
, point_t
*ps_pt
, uint8_t i_pts_nbr
, uint8_t i_border
, uint8_t i_plane
);
108 int puzzle_detect_curve( filter_t
*p_filter
, int32_t i_y
, float f_x_ratio
, float f_y_ratio
, point_t
*ps_pt
, uint8_t i_pts_nbr
, uint8_t i_border
, uint8_t i_plane
, int32_t *pi_sects
);
109 int puzzle_generate_sectLeft2Right( filter_t
*p_filter
, piece_shape_t
*ps_piece_shape
, piece_shape_t
*ps_left_piece_shape
, uint8_t i_plane
);
110 int puzzle_generate_sectTop2Btm( filter_t
*p_filter
, piece_shape_t
*ps_piece_shape
, piece_shape_t
*ps_top_piece_shape
, uint8_t i_plane
);