chore: rename zoom_x/y paramters and local variables to scale_x/y

This commit is contained in:
Gabor Kiss-Vamosi 2023-10-31 20:19:12 +01:00
parent a5a58e39d2
commit 16302e9c7b
22 changed files with 127 additions and 131 deletions

View File

@ -962,7 +962,7 @@ void shop_create(lv_obj_t * parent)
lv_obj_set_width(chart3, LV_PCT(95));
lv_obj_set_height(chart3, LV_VER_RES - 70);
lv_obj_set_style_max_height(chart3, 300, 0);
// lv_chart_set_zoom_x(chart3, 512);
// lv_chart_set_scale_x(chart3, 512);
lv_obj_set_grid_dsc_array(panel1, grid1_col_dsc, grid1_row_dsc);
lv_obj_set_grid_cell(title, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 0, 1);

View File

@ -180,8 +180,8 @@ Zoom
----
The chart can be zoomed independently in x and y directions with
:cpp:expr:`lv_chart_set_zoom_x(chart, factor)` and
:cpp:expr:`lv_chart_set_zoom_y(chart, factor)`. If ``factor`` is 256 there is no
:cpp:expr:`lv_chart_set_scale_x(chart, factor)` and
:cpp:expr:`lv_chart_set_scale_y(chart, factor)`. If ``factor`` is 256 there is no
zoom. 512 means double zoom, etc. Fractional values are also possible
but < 256 value is not allowed.

View File

@ -71,7 +71,7 @@ void lv_example_chart_3(void)
lv_obj_refresh_ext_draw_size(chart);
/*Zoom in a little in X*/
// lv_chart_set_zoom_x(chart, 800);
// lv_chart_set_scale_x(chart, 800);
/*Add two data series*/
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);

View File

@ -70,7 +70,7 @@ chart.add_event(event_cb, lv.EVENT.ALL, None)
chart.refresh_ext_draw_size()
# Zoom in a little in X
#chart.set_zoom_x(800)
#chart.set_scale_x(800)
# Add two data series
ser1 = chart.add_series(lv.palette_main(lv.PALETTE.RED), lv.chart.AXIS.PRIMARY_Y)

View File

@ -39,7 +39,7 @@ void lv_example_chart_6(void)
lv_chart_set_next_value(chart, ser, lv_rand(10, 90));
}
// lv_chart_set_zoom_x(chart, 500);
// lv_chart_set_scale_x(chart, 500);
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "Click on a point");

View File

@ -186,8 +186,8 @@ void lv_obj_init_draw_image_dsc(lv_obj_t * obj, uint32_t part, lv_draw_image_dsc
if(draw_dsc->opa <= LV_OPA_MIN) return;
draw_dsc->rotation = 0;
draw_dsc->zoom_x = LV_SCALE_NONE;
draw_dsc->zoom_y = LV_SCALE_NONE;
draw_dsc->scale_x = LV_SCALE_NONE;
draw_dsc->scale_y = LV_SCALE_NONE;
draw_dsc->pivot.x = lv_area_get_width(&obj->coords) / 2;
draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2;

View File

@ -1118,10 +1118,10 @@ static void layout_update_core(lv_obj_t * obj)
static void transform_point(const lv_obj_t * obj, lv_point_t * p, bool inv)
{
int32_t angle = lv_obj_get_style_transform_rotation(obj, 0);
int32_t zoom_x = lv_obj_get_style_transform_scale_x_safe(obj, 0);
int32_t zoom_y = lv_obj_get_style_transform_scale_y_safe(obj, 0);
int32_t scale_x = lv_obj_get_style_transform_scale_x_safe(obj, 0);
int32_t scale_y = lv_obj_get_style_transform_scale_y_safe(obj, 0);
if(angle == 0 && zoom_x == LV_SCALE_NONE && zoom_y == LV_SCALE_NONE) return;
if(angle == 0 && scale_x == LV_SCALE_NONE && scale_y == LV_SCALE_NONE) return;
lv_point_t pivot = {
.x = lv_obj_get_style_transform_pivot_x(obj, 0),
@ -1140,9 +1140,9 @@ static void transform_point(const lv_obj_t * obj, lv_point_t * p, bool inv)
if(inv) {
angle = -angle;
zoom_x = (256 * 256) / zoom_x;
zoom_y = (256 * 256) / zoom_y;
scale_x = (256 * 256) / scale_x;
scale_y = (256 * 256) / scale_y;
}
lv_point_transform(p, angle, zoom_x, zoom_y, &pivot, !inv);
lv_point_transform(p, angle, scale_x, scale_y, &pivot, !inv);
}

View File

@ -914,8 +914,8 @@ void refr_obj(lv_layer_t * layer, lv_obj_t * obj)
layer_draw_dsc.rotation = lv_obj_get_style_transform_rotation(obj, 0);
while(layer_draw_dsc.rotation > 3600) layer_draw_dsc.rotation -= 3600;
while(layer_draw_dsc.rotation < 0) layer_draw_dsc.rotation += 3600;
layer_draw_dsc.zoom_x = lv_obj_get_style_transform_scale_x(obj, 0);
layer_draw_dsc.zoom_y = lv_obj_get_style_transform_scale_y(obj, 0);
layer_draw_dsc.scale_x = lv_obj_get_style_transform_scale_x(obj, 0);
layer_draw_dsc.scale_y = lv_obj_get_style_transform_scale_y(obj, 0);
layer_draw_dsc.blend_mode = lv_obj_get_style_blend_mode(obj, 0);
layer_draw_dsc.antialias = disp_refr->antialiasing;
layer_draw_dsc.src = new_layer;

View File

@ -43,8 +43,8 @@ void lv_draw_image_dsc_init(lv_draw_image_dsc_t * dsc)
lv_memzero(dsc, sizeof(lv_draw_image_dsc_t));
dsc->recolor = lv_color_black();
dsc->opa = LV_OPA_COVER;
dsc->zoom_x = LV_SCALE_NONE;
dsc->zoom_y = LV_SCALE_NONE;
dsc->scale_x = LV_SCALE_NONE;
dsc->scale_y = LV_SCALE_NONE;
dsc->antialias = LV_COLOR_DEPTH > 8 ? 1 : 0;
}

View File

@ -44,8 +44,8 @@ typedef struct _lv_draw_image_dsc_t {
int32_t rotation;
int32_t zoom_x;
int32_t zoom_y;
int32_t scale_x;
int32_t scale_y;
lv_point_t pivot;
lv_color_t recolor;

View File

@ -59,11 +59,11 @@ void lv_image_buf_free(lv_image_dsc_t * dsc)
}
}
void _lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle, uint16_t zoom_x,
uint16_t zoom_y,
void _lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle, uint16_t scale_x,
uint16_t scale_y,
const lv_point_t * pivot)
{
if(angle == 0 && zoom_x == LV_SCALE_NONE && zoom_y == LV_SCALE_NONE) {
if(angle == 0 && scale_x == LV_SCALE_NONE && scale_y == LV_SCALE_NONE) {
res->x1 = 0;
res->y1 = 0;
res->x2 = w - 1;
@ -77,10 +77,10 @@ void _lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, i
{0, h - 1},
{w - 1, h - 1},
};
lv_point_transform(&p[0], angle, zoom_x, zoom_y, pivot, true);
lv_point_transform(&p[1], angle, zoom_x, zoom_y, pivot, true);
lv_point_transform(&p[2], angle, zoom_x, zoom_y, pivot, true);
lv_point_transform(&p[3], angle, zoom_x, zoom_y, pivot, true);
lv_point_transform(&p[0], angle, scale_x, scale_y, pivot, true);
lv_point_transform(&p[1], angle, scale_x, scale_y, pivot, true);
lv_point_transform(&p[2], angle, scale_x, scale_y, pivot, true);
lv_point_transform(&p[3], angle, scale_x, scale_y, pivot, true);
res->x1 = LV_MIN4(p[0].x, p[1].x, p[2].x, p[3].x);
res->x2 = LV_MAX4(p[0].x, p[1].x, p[2].x, p[3].x);
res->y1 = LV_MIN4(p[0].y, p[1].y, p[2].y, p[3].y);

View File

@ -112,12 +112,12 @@ void lv_image_buf_free(lv_image_dsc_t * dsc);
* @param w width of the rectangle to transform
* @param h height of the rectangle to transform
* @param angle angle of rotation
* @param zoom_x zoom in x direction, (256 no zoom)
* @param zoom_y zoom in y direction, (256 no zoom)
* @param scale_x zoom in x direction, (256 no zoom)
* @param scale_y zoom in y direction, (256 no zoom)
* @param pivot x,y pivot coordinates of rotation
*/
void _lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle, uint16_t zoom_x,
uint16_t zoom_y,
void _lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle, uint16_t scale_x,
uint16_t scale_y,
const lv_point_t * pivot);
/**********************

View File

@ -72,11 +72,11 @@ void lv_draw_sw_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dr
#if LV_USE_LAYER_DEBUG || LV_USE_PARALLEL_DRAW_DEBUG
lv_area_t area_rot;
lv_area_copy(&area_rot, coords);
if(draw_dsc->rotation || draw_dsc->zoom_x != LV_SCALE_NONE || draw_dsc->zoom_y != LV_SCALE_NONE) {
if(draw_dsc->rotation || draw_dsc->scale_x != LV_SCALE_NONE || draw_dsc->scale_y != LV_SCALE_NONE) {
int32_t w = lv_area_get_width(coords);
int32_t h = lv_area_get_height(coords);
_lv_image_buf_get_transformed_area(&area_rot, w, h, draw_dsc->rotation, draw_dsc->zoom_x, draw_dsc->zoom_y,
_lv_image_buf_get_transformed_area(&area_rot, w, h, draw_dsc->rotation, draw_dsc->scale_x, draw_dsc->scale_y,
&draw_dsc->pivot);
area_rot.x1 += coords->x1;
@ -152,11 +152,11 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_image(lv_draw_unit_t * draw_unit, const lv
{
lv_area_t transformed_area;
lv_area_copy(&transformed_area, coords);
if(draw_dsc->rotation || draw_dsc->zoom_x != LV_SCALE_NONE || draw_dsc->zoom_y != LV_SCALE_NONE) {
if(draw_dsc->rotation || draw_dsc->scale_x != LV_SCALE_NONE || draw_dsc->scale_y != LV_SCALE_NONE) {
int32_t w = lv_area_get_width(coords);
int32_t h = lv_area_get_height(coords);
_lv_image_buf_get_transformed_area(&transformed_area, w, h, draw_dsc->rotation, draw_dsc->zoom_x, draw_dsc->zoom_y,
_lv_image_buf_get_transformed_area(&transformed_area, w, h, draw_dsc->rotation, draw_dsc->scale_x, draw_dsc->scale_y,
&draw_dsc->pivot);
transformed_area.x1 += coords->x1;
@ -222,8 +222,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_image(lv_draw_unit_t * draw_unit, const lv
static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc, const lv_area_t * draw_area,
const lv_image_decoder_dsc_t * src, lv_draw_image_sup_t * sup, const lv_area_t * img_coords)
{
bool transformed = draw_dsc->rotation != 0 || draw_dsc->zoom_x != LV_SCALE_NONE ||
draw_dsc->zoom_y != LV_SCALE_NONE ? true : false;
bool transformed = draw_dsc->rotation != 0 || draw_dsc->scale_x != LV_SCALE_NONE ||
draw_dsc->scale_y != LV_SCALE_NONE ? true : false;
lv_draw_sw_blend_dsc_t blend_dsc;
const uint8_t * src_buf = src->img_data;

View File

@ -94,8 +94,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_cb(lv_draw_unit_t * draw_unit, lv_
lv_draw_image_dsc_t img_dsc;
lv_draw_image_dsc_init(&img_dsc);
img_dsc.rotation = 0;
img_dsc.zoom_x = LV_SCALE_NONE;
img_dsc.zoom_y = LV_SCALE_NONE;
img_dsc.scale_x = LV_SCALE_NONE;
img_dsc.scale_y = LV_SCALE_NONE;
img_dsc.opa = glyph_draw_dsc->opa;
img_dsc.src = glyph_draw_dsc->bitmap;
lv_draw_sw_image(draw_unit, &img_dsc, glyph_draw_dsc->letter_coords);

View File

@ -28,8 +28,8 @@ typedef struct {
int32_t y_out;
int32_t sinma;
int32_t cosma;
int32_t zoom_x;
int32_t zoom_y;
int32_t scale_x;
int32_t scale_y;
int32_t angle;
int32_t pivot_x_256;
int32_t pivot_y_256;
@ -88,8 +88,8 @@ void lv_draw_sw_transform(lv_draw_unit_t * draw_unit, const lv_area_t * dest_are
point_transform_dsc_t tr_dsc;
tr_dsc.angle = -draw_dsc->rotation;
tr_dsc.zoom_x = (256 * 256) / draw_dsc->zoom_x;
tr_dsc.zoom_y = (256 * 256) / draw_dsc->zoom_y;
tr_dsc.scale_x = (256 * 256) / draw_dsc->scale_x;
tr_dsc.scale_y = (256 * 256) / draw_dsc->scale_y;
tr_dsc.pivot = draw_dsc->pivot;
int32_t angle_low = tr_dsc.angle / 10;
@ -584,7 +584,7 @@ static void transform_a8(const uint8_t * src, int32_t src_w, int32_t src_h, int3
static void transform_point_upscaled(point_transform_dsc_t * t, int32_t xin, int32_t yin, int32_t * xout,
int32_t * yout)
{
if(t->angle == 0 && t->zoom_x == LV_SCALE_NONE && t->zoom_y == LV_SCALE_NONE) {
if(t->angle == 0 && t->scale_x == LV_SCALE_NONE && t->scale_y == LV_SCALE_NONE) {
*xout = xin * 256;
*yout = yin * 256;
return;
@ -594,16 +594,16 @@ static void transform_point_upscaled(point_transform_dsc_t * t, int32_t xin, int
yin -= t->pivot.y;
if(t->angle == 0) {
*xout = ((int32_t)(xin * t->zoom_x)) + (t->pivot_x_256);
*yout = ((int32_t)(yin * t->zoom_y)) + (t->pivot_y_256);
*xout = ((int32_t)(xin * t->scale_x)) + (t->pivot_x_256);
*yout = ((int32_t)(yin * t->scale_y)) + (t->pivot_y_256);
}
else if(t->zoom_x == LV_SCALE_NONE && t->zoom_y == LV_SCALE_NONE) {
else if(t->scale_x == LV_SCALE_NONE && t->scale_y == LV_SCALE_NONE) {
*xout = ((t->cosma * xin - t->sinma * yin) >> 2) + (t->pivot_x_256);
*yout = ((t->sinma * xin + t->cosma * yin) >> 2) + (t->pivot_y_256);
}
else {
*xout = (((t->cosma * xin - t->sinma * yin) * t->zoom_x) >> 10) + (t->pivot_x_256);
*yout = (((t->sinma * xin + t->cosma * yin) * t->zoom_y) >> 10) + (t->pivot_y_256);
*xout = (((t->cosma * xin - t->sinma * yin) * t->scale_x) >> 10) + (t->pivot_x_256);
*yout = (((t->sinma * xin + t->cosma * yin) * t->scale_y) >> 10) + (t->pivot_y_256);
}
}

View File

@ -1166,25 +1166,25 @@ static void indev_proc_release(lv_indev_t * indev)
/*Get the transformed vector with this object*/
if(scroll_obj) {
int16_t angle = 0;
int16_t zoom_x = 256;
int16_t zoom_y = 256;
int16_t scale_x = 256;
int16_t scale_y = 256;
lv_point_t pivot = { 0, 0 };
lv_obj_t * parent = scroll_obj;
while(parent) {
angle += lv_obj_get_style_transform_rotation(parent, 0);
int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, 0);
int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, 0);
zoom_x = (zoom_x * zoom_act_x) >> 8;
zoom_y = (zoom_x * zoom_act_y) >> 8;
scale_x = (scale_x * zoom_act_x) >> 8;
scale_y = (scale_x * zoom_act_y) >> 8;
parent = lv_obj_get_parent(parent);
}
if(angle != 0 || zoom_y != LV_SCALE_NONE || zoom_x != LV_SCALE_NONE) {
if(angle != 0 || scale_y != LV_SCALE_NONE || scale_x != LV_SCALE_NONE) {
angle = -angle;
zoom_x = (256 * 256) / zoom_x;
zoom_y = (256 * 256) / zoom_y;
lv_point_transform(&indev->pointer.scroll_throw_vect, angle, zoom_x, zoom_y, &pivot, false);
lv_point_transform(&indev->pointer.scroll_throw_vect_ori, angle, zoom_x, zoom_y, &pivot, false);
scale_x = (256 * 256) / scale_x;
scale_y = (256 * 256) / scale_y;
lv_point_transform(&indev->pointer.scroll_throw_vect, angle, scale_x, scale_y, &pivot, false);
lv_point_transform(&indev->pointer.scroll_throw_vect_ori, angle, scale_x, scale_y, &pivot, false);
}
}

View File

@ -64,24 +64,24 @@ void _lv_indev_scroll_handler(lv_indev_t * indev)
/*Set new position or scroll if the vector is not zero*/
int16_t angle = 0;
int16_t zoom_x = 256;
int16_t zoom_y = 256;
int16_t scale_x = 256;
int16_t scale_y = 256;
lv_obj_t * parent = scroll_obj;
while(parent) {
angle += lv_obj_get_style_transform_rotation(parent, 0);
int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, 0);
int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, 0);
zoom_x = (zoom_x * zoom_act_x) >> 8;
zoom_y = (zoom_y * zoom_act_y) >> 8;
scale_x = (scale_x * zoom_act_x) >> 8;
scale_y = (scale_y * zoom_act_y) >> 8;
parent = lv_obj_get_parent(parent);
}
if(angle != 0 || zoom_x != LV_SCALE_NONE || zoom_y != LV_SCALE_NONE) {
if(angle != 0 || scale_x != LV_SCALE_NONE || scale_y != LV_SCALE_NONE) {
angle = -angle;
zoom_x = (256 * 256) / zoom_x;
zoom_y = (256 * 256) / zoom_y;
scale_x = (256 * 256) / scale_x;
scale_y = (256 * 256) / scale_y;
lv_point_t pivot = { 0, 0 };
lv_point_transform(&indev->pointer.vect, angle, zoom_x, zoom_y, &pivot, false);
lv_point_transform(&indev->pointer.vect, angle, scale_x, scale_y, &pivot, false);
}
@ -293,25 +293,25 @@ static lv_obj_t * find_scroll_obj(lv_indev_t * indev)
while(obj_act) {
/*Get the transformed scroll_sum with this object*/
int16_t angle = 0;
int32_t zoom_x = 256;
int32_t zoom_y = 256;
int32_t scale_x = 256;
int32_t scale_y = 256;
lv_point_t pivot = { 0, 0 };
lv_obj_t * parent = obj_act;
while(parent) {
angle += lv_obj_get_style_transform_rotation(parent, 0);
int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, 0);
int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, 0);
zoom_x = (zoom_x * zoom_act_x) >> 8;
zoom_y = (zoom_y * zoom_act_y) >> 8;
scale_x = (scale_x * zoom_act_x) >> 8;
scale_y = (scale_y * zoom_act_y) >> 8;
parent = lv_obj_get_parent(parent);
}
lv_point_t obj_scroll_sum = indev->pointer.scroll_sum;
if(angle != 0 || zoom_x != LV_SCALE_NONE || zoom_y != LV_SCALE_NONE) {
if(angle != 0 || scale_x != LV_SCALE_NONE || scale_y != LV_SCALE_NONE) {
angle = -angle;
zoom_x = (256 * 256) / zoom_x;
zoom_y = (256 * 256) / zoom_y;
lv_point_transform(&obj_scroll_sum, angle, zoom_x, zoom_y, &pivot, false);
scale_x = (256 * 256) / scale_x;
scale_y = (256 * 256) / scale_y;
lv_point_transform(&obj_scroll_sum, angle, scale_x, scale_y, &pivot, false);
}
if(LV_ABS(obj_scroll_sum.x) > LV_ABS(obj_scroll_sum.y)) {

View File

@ -531,10 +531,10 @@ void lv_area_align(const lv_area_t * base, lv_area_t * to_align, lv_align_t alig
}
#define _LV_TRANSFORM_TRIGO_SHIFT 10
void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom_x, int32_t zoom_y, const lv_point_t * pivot,
void lv_point_transform(lv_point_t * p, int32_t angle, int32_t scale_x, int32_t scale_y, const lv_point_t * pivot,
bool zoom_first)
{
if(angle == 0 && zoom_x == 256 && zoom_y == 256) {
if(angle == 0 && scale_x == 256 && scale_y == 256) {
return;
}
@ -542,8 +542,8 @@ void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom_x, int32_t z
p->y -= pivot->y;
if(angle == 0) {
p->x = (((int32_t)(p->x) * zoom_x) >> 8) + pivot->x;
p->y = (((int32_t)(p->y) * zoom_y) >> 8) + pivot->y;
p->x = (((int32_t)(p->x) * scale_x) >> 8) + pivot->x;
p->y = (((int32_t)(p->y) * scale_y) >> 8) + pivot->y;
return;
}
lv_area_transform_cache_t * cache = &trans_cache;
@ -570,20 +570,20 @@ void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom_x, int32_t z
}
int32_t x = p->x;
int32_t y = p->y;
if(zoom_x == 256 && zoom_y == 256) {
if(scale_x == 256 && scale_y == 256) {
p->x = ((cache->cosma * x - cache->sinma * y) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
p->y = ((cache->sinma * x + cache->cosma * y) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;
}
else {
if(zoom_first) {
x *= zoom_x;
y *= zoom_y;
x *= scale_x;
y *= scale_y;
p->x = (((cache->cosma * x - cache->sinma * y)) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->x;
p->y = (((cache->sinma * x + cache->cosma * y)) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->y;
}
else {
p->x = (((cache->cosma * x - cache->sinma * y) * zoom_x) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->x;
p->y = (((cache->sinma * x + cache->cosma * y) * zoom_y) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->y;
p->x = (((cache->cosma * x - cache->sinma * y) * scale_x) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->x;
p->y = (((cache->sinma * x + cache->cosma * y) * scale_y) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->y;
}
}

View File

@ -264,18 +264,14 @@ bool _lv_area_is_equal(const lv_area_t * a, const lv_area_t * b);
*/
void lv_area_align(const lv_area_t * base, lv_area_t * to_align, lv_align_t align, int32_t ofs_x, int32_t ofs_y);
void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom_x, int32_t zoom_y, const lv_point_t * pivot,
void lv_point_transform(lv_point_t * p, int32_t angle, int32_t scale_x, int32_t scale_y, const lv_point_t * pivot,
bool zoom_first);
/**********************
* MACROS
**********************/
#if LV_USE_LARGE_COORD
#define _LV_COORD_TYPE_SHIFT (29U)
#else
#define _LV_COORD_TYPE_SHIFT (13U)
#endif
#define _LV_COORD_TYPE_MASK (3 << _LV_COORD_TYPE_SHIFT)
#define _LV_COORD_TYPE(x) ((x) & _LV_COORD_TYPE_MASK) /*Extract type specifiers*/

View File

@ -27,7 +27,7 @@ static void lv_image_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
static void lv_image_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
static void lv_image_event(const lv_obj_class_t * class_p, lv_event_t * e);
static void draw_image(lv_event_t * e);
static void scale_update(lv_obj_t * obj, int32_t zoom_x, int32_t zoom_y);
static void scale_update(lv_obj_t * obj, int32_t scale_x, int32_t scale_y);
#if LV_USE_OBJ_PROPERTY
static const lv_property_ops_t properties[] = {
@ -199,7 +199,7 @@ void lv_image_set_src(lv_obj_t * obj, const void * src)
lv_obj_refresh_self_size(obj);
/*Provide enough room for the rotated corners*/
if(img->rotation || img->zoom_x != LV_SCALE_NONE || img->zoom_y != LV_SCALE_NONE) lv_obj_refresh_ext_draw_size(obj);
if(img->rotation || img->scale_x != LV_SCALE_NONE || img->scale_y != LV_SCALE_NONE) lv_obj_refresh_ext_draw_size(obj);
lv_obj_invalidate(obj);
}
@ -244,7 +244,7 @@ void lv_image_set_rotation(lv_obj_t * obj, int32_t angle)
lv_area_t a;
lv_point_t pivot_px;
lv_image_get_pivot(obj, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom_x, img->zoom_y, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@ -260,7 +260,7 @@ void lv_image_set_rotation(lv_obj_t * obj, int32_t angle)
lv_obj_refresh_ext_draw_size(obj);
lv_display_enable_invalidation(disp, true);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom_x, img->zoom_y, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@ -286,7 +286,7 @@ void lv_image_set_pivot(lv_obj_t * obj, int32_t x, int32_t y)
lv_area_t a;
lv_point_t pivot_px;
lv_image_get_pivot(obj, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom_x, img->zoom_y, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@ -304,7 +304,7 @@ void lv_image_set_pivot(lv_obj_t * obj, int32_t x, int32_t y)
lv_display_enable_invalidation(disp, true);
lv_image_get_pivot(obj, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom_x, img->zoom_y, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@ -315,7 +315,7 @@ void lv_image_set_pivot(lv_obj_t * obj, int32_t x, int32_t y)
void lv_image_set_scale(lv_obj_t * obj, uint32_t zoom)
{
lv_image_t * img = (lv_image_t *)obj;
if(zoom == img->zoom_x && zoom == img->zoom_y) return;
if(zoom == img->scale_x && zoom == img->scale_y) return;
if(zoom == 0) zoom = 1;
@ -325,21 +325,21 @@ void lv_image_set_scale(lv_obj_t * obj, uint32_t zoom)
void lv_image_set_scale_x(lv_obj_t * obj, uint32_t zoom)
{
lv_image_t * img = (lv_image_t *)obj;
if(zoom == img->zoom_x) return;
if(zoom == img->scale_x) return;
if(zoom == 0) zoom = 1;
scale_update(obj, zoom, img->zoom_y);
scale_update(obj, zoom, img->scale_y);
}
void lv_image_set_scale_y(lv_obj_t * obj, uint32_t zoom)
{
lv_image_t * img = (lv_image_t *)obj;
if(zoom == img->zoom_y) return;
if(zoom == img->scale_y) return;
if(zoom == 0) zoom = 1;
scale_update(obj, img->zoom_y, zoom);
scale_update(obj, img->scale_y, zoom);
}
void lv_image_set_antialias(lv_obj_t * obj, bool antialias)
@ -417,7 +417,7 @@ int32_t lv_image_get_scale(lv_obj_t * obj)
lv_image_t * img = (lv_image_t *)obj;
return img->zoom_x;
return img->scale_x;
}
int32_t lv_image_get_scale_x(lv_obj_t * obj)
@ -426,7 +426,7 @@ int32_t lv_image_get_scale_x(lv_obj_t * obj)
lv_image_t * img = (lv_image_t *)obj;
return img->zoom_x;
return img->scale_x;
}
int32_t lv_image_get_scale_y(lv_obj_t * obj)
@ -435,7 +435,7 @@ int32_t lv_image_get_scale_y(lv_obj_t * obj)
lv_image_t * img = (lv_image_t *)obj;
return img->zoom_y;
return img->scale_y;
}
bool lv_image_get_antialias(lv_obj_t * obj)
@ -471,8 +471,8 @@ static void lv_image_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
img->w = lv_obj_get_width(obj);
img->h = lv_obj_get_height(obj);
img->rotation = 0;
img->zoom_x = LV_SCALE_NONE;
img->zoom_y = LV_SCALE_NONE;
img->scale_x = LV_SCALE_NONE;
img->scale_y = LV_SCALE_NONE;
img->antialias = LV_COLOR_DEPTH > 8 ? 1 : 0;
img->offset.x = 0;
img->offset.y = 0;
@ -507,7 +507,7 @@ static lv_point_t lv_image_get_transformed_size(lv_obj_t * obj)
lv_point_t pivot_px;
lv_image_get_pivot(obj, &pivot_px);
_lv_image_buf_get_transformed_area(&area_transform, img->w, img->h,
img->rotation, img->zoom_x, img->zoom_y, &pivot_px);
img->rotation, img->scale_x, img->scale_y, &pivot_px);
return (lv_point_t) {
lv_area_get_width(&area_transform), lv_area_get_height(&area_transform)
@ -547,11 +547,11 @@ static void lv_image_event(const lv_obj_class_t * class_p, lv_event_t * e)
int32_t * s = lv_event_get_param(e);
/*If the image has angle provide enough room for the rotated corners*/
if(img->rotation || img->zoom_x != LV_SCALE_NONE || img->zoom_y != LV_SCALE_NONE) {
if(img->rotation || img->scale_x != LV_SCALE_NONE || img->scale_y != LV_SCALE_NONE) {
lv_area_t a;
int32_t w = lv_obj_get_width(obj);
int32_t h = lv_obj_get_height(obj);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom_x, img->zoom_y, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px);
*s = LV_MAX(*s, -a.x1);
*s = LV_MAX(*s, -a.y1);
*s = LV_MAX(*s, a.x2 - w);
@ -564,13 +564,13 @@ static void lv_image_event(const lv_obj_class_t * class_p, lv_event_t * e)
/*If the object is exactly image sized (not cropped, not mosaic) and transformed
*perform hit test on its transformed area*/
if(img->w == lv_obj_get_width(obj) && img->h == lv_obj_get_height(obj) &&
(img->zoom_x != LV_SCALE_NONE || img->zoom_y != LV_SCALE_NONE ||
(img->scale_x != LV_SCALE_NONE || img->scale_y != LV_SCALE_NONE ||
img->rotation != 0 || img->pivot.x != img->w / 2 || img->pivot.y != img->h / 2)) {
int32_t w = lv_obj_get_width(obj);
int32_t h = lv_obj_get_height(obj);
lv_area_t coords;
_lv_image_buf_get_transformed_area(&coords, w, h, img->rotation, img->zoom_x, img->zoom_y, &pivot_px);
_lv_image_buf_get_transformed_area(&coords, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px);
coords.x1 += obj->coords.x1;
coords.y1 += obj->coords.y1;
coords.x2 += obj->coords.x1;
@ -630,7 +630,7 @@ static void draw_image(lv_event_t * e)
}
const lv_area_t * clip_area = lv_event_get_param(e);
if(img->zoom_x == LV_SCALE_NONE && img->zoom_y == LV_SCALE_NONE) {
if(img->scale_x == LV_SCALE_NONE && img->scale_y == LV_SCALE_NONE) {
if(_lv_area_is_in(clip_area, &obj->coords, 0) == false) {
info->res = LV_COVER_RES_NOT_COVER;
return;
@ -640,7 +640,7 @@ static void draw_image(lv_event_t * e)
lv_area_t a;
lv_point_t pivot_px;
lv_image_get_pivot(obj, &pivot_px);
_lv_image_buf_get_transformed_area(&a, lv_obj_get_width(obj), lv_obj_get_height(obj), 0, img->zoom_x, img->zoom_y,
_lv_image_buf_get_transformed_area(&a, lv_obj_get_width(obj), lv_obj_get_height(obj), 0, img->scale_x, img->scale_y,
&pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
@ -678,7 +678,7 @@ static void draw_image(lv_event_t * e)
}
else {
_lv_image_buf_get_transformed_area(&bg_coords, obj_w, obj_h,
img->rotation, img->zoom_x, img->zoom_y, &bg_pivot);
img->rotation, img->scale_x, img->scale_y, &bg_pivot);
/*Modify the coordinates to draw the background for the rotated and scaled coordinates*/
bg_coords.x1 += obj->coords.x1;
@ -698,7 +698,7 @@ static void draw_image(lv_event_t * e)
if(code == LV_EVENT_DRAW_MAIN) {
if(img->h == 0 || img->w == 0) return;
if(img->zoom_x == 0 || img->zoom_y == 0) return;
if(img->scale_x == 0 || img->scale_y == 0) return;
lv_layer_t * layer = lv_event_get_layer(e);
@ -728,8 +728,8 @@ static void draw_image(lv_event_t * e)
lv_draw_image_dsc_init(&img_dsc);
lv_obj_init_draw_image_dsc(obj, LV_PART_MAIN, &img_dsc);
img_dsc.zoom_x = img->zoom_x;
img_dsc.zoom_y = img->zoom_y;
img_dsc.scale_x = img->scale_x;
img_dsc.scale_y = img->scale_y;
img_dsc.rotation = img->rotation;
img_dsc.pivot.x = pivot_px.x;
img_dsc.pivot.y = pivot_px.y;
@ -783,13 +783,13 @@ static void draw_image(lv_event_t * e)
}
}
static void scale_update(lv_obj_t * obj, int32_t zoom_x, int32_t zoom_y)
static void scale_update(lv_obj_t * obj, int32_t scale_x, int32_t scale_y)
{
lv_image_t * img = (lv_image_t *)obj;
if(img->obj_size_mode == LV_IMAGE_SIZE_MODE_REAL) {
img->zoom_x = zoom_x;
img->zoom_y = zoom_y;
img->scale_x = scale_x;
img->scale_y = scale_y;
lv_obj_invalidate_area(obj, &obj->coords);
return;
}
@ -800,15 +800,15 @@ static void scale_update(lv_obj_t * obj, int32_t zoom_x, int32_t zoom_y)
lv_area_t a;
lv_point_t pivot_px;
lv_image_get_pivot(obj, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom_x, img->zoom_y, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px);
a.x1 += obj->coords.x1 - 1;
a.y1 += obj->coords.y1 - 1;
a.x2 += obj->coords.x1 + 1;
a.y2 += obj->coords.y1 + 1;
lv_obj_invalidate_area(obj, &a);
img->zoom_x = zoom_x;
img->zoom_y = zoom_y;
img->scale_x = scale_x;
img->scale_y = scale_y;
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
@ -817,7 +817,7 @@ static void scale_update(lv_obj_t * obj, int32_t zoom_x, int32_t zoom_y)
lv_obj_refresh_ext_draw_size(obj);
lv_display_enable_invalidation(disp, true);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom_x, img->zoom_y, &pivot_px);
_lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->scale_x, img->scale_y, &pivot_px);
a.x1 += obj->coords.x1 - 1;
a.y1 += obj->coords.y1 - 1;
a.x2 += obj->coords.x1 + 1;

View File

@ -44,8 +44,8 @@ typedef struct {
int32_t w; /*Width of the image (Handled by the library)*/
int32_t h; /*Height of the image (Handled by the library)*/
uint32_t rotation; /*rotation angle of the image*/
uint32_t zoom_x; /*256 means no zoom, 512 double size, 128 half size*/
uint32_t zoom_y; /*256 means no zoom, 512 double size, 128 half size*/
uint32_t scale_x; /*256 means no zoom, 512 double size, 128 half size*/
uint32_t scale_y; /*256 means no zoom, 512 double size, 128 half size*/
lv_point_t pivot; /*rotation center of the image*/
uint8_t src_type : 2; /*See: lv_image_src_t*/
uint8_t cf : 5; /*Color format from `lv_color_format_t`*/

View File

@ -823,22 +823,22 @@ static void set_y_anim(void * obj, int32_t v)
static void transform_vect_recursive(lv_obj_t * roller, lv_point_t * vect)
{
int16_t angle = 0;
int32_t zoom_x = 256;
int32_t zoom_y = 256;
int32_t scale_x = 256;
int32_t scale_y = 256;
lv_obj_t * parent = roller;
while(parent) {
angle += lv_obj_get_style_transform_rotation(parent, 0);
int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, 0);
int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, 0);
zoom_x = (zoom_y * zoom_act_x) >> 8;
zoom_y = (zoom_y * zoom_act_y) >> 8;
scale_x = (scale_y * zoom_act_x) >> 8;
scale_y = (scale_y * zoom_act_y) >> 8;
parent = lv_obj_get_parent(parent);
}
lv_point_t pivot = { 0, 0 };
zoom_x = 256 * 256 / zoom_x;
zoom_y = 256 * 256 / zoom_y;
lv_point_transform(vect, -angle, zoom_x, zoom_y, &pivot, false);
scale_x = 256 * 256 / scale_x;
scale_y = 256 * 256 / scale_y;
lv_point_transform(vect, -angle, scale_x, scale_y, &pivot, false);
}
#endif