SWF Shape Record (swf_shape_record)
SWF Structure Info
SWF Structure:
/* if f_shape_record_type = 0 & f_end_of_shape = 0 then that's the end of the list of shape records */
struct swf_shape_record_end {
unsigned f_shape_record_type : 1;
unsigned f_end_of_shape : 5;
};
/* f_shape_record_type = 0 & at least one of the following five bits is not zero then change style, fill and position setup */
struct swf_shape_record_setup {
unsigned f_shape_record_type : 1;
if(f_tag == DefineShape) {
unsigned f_shape_reserved : 1; /* always zero */
}
else {
unsigned f_shape_has_new_styles : 1;
}
unsigned f_shape_has_line_style : 1;
unsigned f_shape_has_fill_style1 : 1;
unsigned f_shape_has_fill_style0 : 1;
unsigned f_shape_has_move_to : 1;
if(f_shape_has_move_to) {
unsigned f_shape_move_size : 5;
signed twips f_shape_move_x : f_shape_move_size;
signed twips f_shape_move_y : f_shape_move_size;
}
if(f_shape_has_fill_style0) {
unsigned f_shape_fill_style0 : f_fill_bits_count;
}
if(f_shape_has_fill_style1) {
unsigned f_shape_fill_style1 : f_fill_bits_count;
}
if(f_shape_has_line_style) {
unsigned f_shape_line_style : f_line_bits_count;
}
if(f_shape_has_new_styles) {
swf_styles f_styles;
}
};
/* f_shape_record_type = 1 -- edge record */
struct swf_shape_record_edge {
unsigned f_shape_record_type : 1;
unsigned f_shape_edge_type : 1;
unsigned f_shape_coord_size : 4;
f_shape_coord_real_size = f_shape_coord_size + 2;
if(f_shape_edge_type == 0) {
signed twips f_shape_control_delta_x : f_shape_coord_real_size;
signed twips f_shape_control_delta_y : f_shape_coord_real_size;
signed twips f_shape_anchor_delta_x : f_shape_coord_real_size;
signed twips f_shape_anchor_delta_y : f_shape_coord_real_size;
}
else {
unsigned f_shape_line_has_x_and_y : 1;
if(f_shape_line_has_x_and_y == 1) {
signed twips f_shape_delta_x : f_shape_coord_real_size;
signed twips f_shape_delta_y : f_shape_coord_real_size;
}
else {
unsigned f_shape_line_has_x_or_y : 1;
if(f_shape_line_has_x_or_y == 0) {
signed twips f_shape_delta_x : f_shape_coord_real_size;
}
else {
signed twips f_shape_delta_y : f_shape_coord_real_size;
}
}
}
};
union swf_shape_record {
swf_shape_record_end f_shape_end;
swf_shape_record_setup f_shape_setup;
swf_shape_record_edge f_shape_edge;
};
The shape records are typed. Depending on that type, the contents vary. The following defines one structure for each type. The shape record is a union of these structures.
It is important to note that the f_shape_move_x and f_shape_move_y are not deltas from the current point, but a position from the current shape origin. All the other positions are defined as deltas from the previous position, including the anchors which are deltas from the control point position!
The control point defines how much the curve is curved. Please, see The geometry in SWF for more information.