MBAF Object
History Key
- New content
Removed content
Recent Versions
Choose two versions to compare, or click the link to view it.
Introduction
The MBAF object is the high level object which can be binded to the symbol in the MadSwatter. We provide API to change the following properties against it.
- Location(x,y)
- Size(X scale,Y scale)
- Rotation( degree)
- text inside it
- text format fo the text inside it
- Color
An MBAF object can be either a coord_t or a shape_t. The MBAF object layer will call appropriate low level function to change these properties in the SVG level. In this way, programmer can use the same interface to operate all elements without knowing the details of the SVG elements.
Location
void mb_obj_set_pos(mb_obj_t *obj, CO_AIX x, CO_AIX y);
This function will change the location of the object. If it is a coord_t, we can change its matrix to implement the relocation. We assume that every group in the system is created at (0,0). Therefore, we can use an translation matrix to relocate the object to any position of the screen.
If the object is a shape_t, we will relocate it in the shape level. Each shape has different implementation of the relocation. For a text shape, this is easy since each text shape has (x,y) already. However, the (x,y) of a tedxt shape is pointed to the base point of the text string, which is usually in the middle of the glyphs. It is descent pixels higher than the baseline of the glyphs.
scale
void mb_obj_set_scalex(mb_obj_t obj, int scalex); void mb_obj_set_scaley(mb_obj_t obj, int scaley);
The scale is only available for the group only. If we change the sacle of text or other elements, it will be ignored.
rotation
void mb_obj_set_rotation(mb_obj_tmb_obj_set_rotation(mb_ob\j_t *obj, int degree);
text
void mb_obj_set_text(mb_obj_t obj, const char text); void mb_obj_get_text(mb_obj_t obj, const char text);
If this is a group, we will search for the first text shape inside it. If we have multiple text shapes inside one group, we need to create symbol for them individually. If the object is a text shape, we will change the text of it.
text format
void mb_obj_set_textstyle(mb_obj_t obj, mb_textstyle_t style); void mb_obj_get_textstyle(mb_obj_t *obj, mb_textstyle_t **styles);
If this is a coord_t, we wills earch for the first text shape inside it. If it is a text shape, we will apply to the shape directly. If it is other shape, this call will be ignored.
color
void mb_obj_set_color(mb_obj_t *obj, int color);
Set the color of elements.
If it is a group, we will apply the style to the group. This will become the default color value. Please remember that this won't change the color of elements, which has its own color setting. This only change the elements that use the default color only.
If it is a shpe, we will override the color setting of it.