diff --git a/demos/transform/lv_demo_transform.c b/demos/transform/lv_demo_transform.c
index 156995259..915673db6 100644
--- a/demos/transform/lv_demo_transform.c
+++ b/demos/transform/lv_demo_transform.c
@@ -155,7 +155,8 @@ static void slider_event_cb(lv_event_t * e)
{
lv_obj_t * slider = lv_event_get_target(e);
int32_t v = lv_slider_get_value(slider);
- lv_obj_set_style_transform_scale(card_to_transform, v, 0);
+ lv_obj_set_style_transform_scale_x(card_to_transform, v, 0);
+ lv_obj_set_style_transform_scale_y(card_to_transform, v, 0);
}
#endif
diff --git a/docs/overview/style-props.md b/docs/overview/style-props.md
index d1a674bbc..07eb68022 100644
--- a/docs/overview/style-props.md
+++ b/docs/overview/style-props.md
@@ -120,8 +120,17 @@ Move the object with this value in Y direction. Applied after layouts, aligns an
Ext. draw No
-### transform_scale
-Zoom an objects. The value 256 (or `LV_SCALE_NONE`) means normal size, 128 half size, 512 double size, and so on
+### transform_scale_x
+Zoom an objects horizontally. The value 256 (or `LV_SCALE_NONE`) means normal size, 128 half size, 512 double size, and so on
+
+- Default 0
+- Inherited No
+- Layout Yes
+- Ext. draw Yes
+
+
+### transform_scale_y
+Zoom an objects vertically. The value 256 (or `LV_SCALE_NONE`) means normal size, 128 half size, 512 double size, and so on
- Default 0
- Inherited No
diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py
index ea689a55d..017056321 100755
--- a/scripts/style_api_gen.py
+++ b/scripts/style_api_gen.py
@@ -58,9 +58,13 @@ props = [
'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 1, 'ext_draw': 0,
'dsc': "Move the object with this value in Y direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height." },
-{'name': 'TRANSFORM_SCALE',
+{'name': 'TRANSFORM_SCALE_X',
'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 1, 'ext_draw': 1,
- 'dsc': "Zoom an objects. The value 256 (or `LV_SCALE_NONE`) means normal size, 128 half size, 512 double size, and so on" },
+ 'dsc': "Zoom an objects horizontally. The value 256 (or `LV_SCALE_NONE`) means normal size, 128 half size, 512 double size, and so on" },
+
+{'name': 'TRANSFORM_SCALE_Y',
+ 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 1, 'ext_draw': 1,
+ 'dsc': "Zoom an objects vertically. The value 256 (or `LV_SCALE_NONE`) means normal size, 128 half size, 512 double size, and so on" },
{'name': 'TRANSFORM_ROTATION',
'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 1, 'ext_draw': 1,
diff --git a/src/core/lv_obj_draw.c b/src/core/lv_obj_draw.c
index 2acb735c6..3d3a5265d 100644
--- a/src/core/lv_obj_draw.c
+++ b/src/core/lv_obj_draw.c
@@ -187,7 +187,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 = LV_SCALE_NONE;
+ draw_dsc->zoom_x = LV_SCALE_NONE;
+ draw_dsc->zoom_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;
diff --git a/src/core/lv_obj_pos.c b/src/core/lv_obj_pos.c
index 770159ee2..a69ce74b5 100644
--- a/src/core/lv_obj_pos.c
+++ b/src/core/lv_obj_pos.c
@@ -1118,9 +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)
{
lv_coord_t angle = lv_obj_get_style_transform_rotation(obj, 0);
- lv_coord_t zoom = lv_obj_get_style_transform_scale_safe(obj, 0);
+ lv_coord_t zoom_x = lv_obj_get_style_transform_scale_x_safe(obj, 0);
+ lv_coord_t zoom_y = lv_obj_get_style_transform_scale_y_safe(obj, 0);
- if(angle == 0 && zoom == LV_SCALE_NONE) return;
+ if(angle == 0 && zoom_x == LV_SCALE_NONE && zoom_y == LV_SCALE_NONE) return;
lv_point_t pivot = {
.x = lv_obj_get_style_transform_pivot_x(obj, 0),
@@ -1139,8 +1140,9 @@ static void transform_point(const lv_obj_t * obj, lv_point_t * p, bool inv)
if(inv) {
angle = -angle;
- zoom = (256 * 256) / zoom;
+ zoom_x = (256 * 256) / zoom_x;
+ zoom_y = (256 * 256) / zoom_y;
}
- lv_point_transform(p, angle, zoom, &pivot);
+ lv_point_transform(p, angle, zoom_x, zoom_y, &pivot, !inv);
}
diff --git a/src/core/lv_obj_style.c b/src/core/lv_obj_style.c
index e3213db6e..75ea049ad 100644
--- a/src/core/lv_obj_style.c
+++ b/src/core/lv_obj_style.c
@@ -319,7 +319,8 @@ static inline lv_style_value_t lv_style_prop_get_default_inlined(lv_style_prop_t
const lv_color_t black = LV_COLOR_MAKE(0x00, 0x00, 0x00);
const lv_color_t white = LV_COLOR_MAKE(0xff, 0xff, 0xff);
switch(prop) {
- case LV_STYLE_TRANSFORM_SCALE:
+ case LV_STYLE_TRANSFORM_SCALE_X:
+ case LV_STYLE_TRANSFORM_SCALE_Y:
return (lv_style_value_t) {
.num = LV_SCALE_NONE
};
@@ -606,8 +607,6 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
else if(lv_style_get_prop(style, LV_STYLE_MIN_HEIGHT, &v)) layout_diff = true;
else if(lv_style_get_prop(style, LV_STYLE_MAX_HEIGHT, &v)) layout_diff = true;
else if(lv_style_get_prop(style, LV_STYLE_BORDER_WIDTH, &v)) layout_diff = true;
- else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_ROTATION, &v)) layout_diff = true;
- else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_SCALE, &v)) layout_diff = true;
if(layout_diff) {
return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
@@ -617,7 +616,8 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_HEIGHT, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_ROTATION, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
- else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_SCALE, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
+ else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_SCALE_X, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
+ else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_SCALE_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_OUTLINE_OPA, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_OUTLINE_PAD, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_OUTLINE_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
@@ -1043,7 +1043,8 @@ static void trans_anim_ready_cb(lv_anim_t * a)
static lv_layer_type_t calculate_layer_type(lv_obj_t * obj)
{
if(lv_obj_get_style_transform_rotation(obj, 0) != 0) return LV_LAYER_TYPE_TRANSFORM;
- if(lv_obj_get_style_transform_scale(obj, 0) != 256) return LV_LAYER_TYPE_TRANSFORM;
+ if(lv_obj_get_style_transform_scale_x(obj, 0) != 256) return LV_LAYER_TYPE_TRANSFORM;
+ if(lv_obj_get_style_transform_scale_y(obj, 0) != 256) return LV_LAYER_TYPE_TRANSFORM;
if(lv_obj_get_style_opa_layered(obj, 0) != LV_OPA_COVER) return LV_LAYER_TYPE_SIMPLE;
if(lv_obj_get_style_blend_mode(obj, 0) != LV_BLEND_MODE_NORMAL) return LV_LAYER_TYPE_SIMPLE;
return LV_LAYER_TYPE_NONE;
diff --git a/src/core/lv_obj_style.h b/src/core/lv_obj_style.h
index 1aba04da7..1e74d952e 100644
--- a/src/core/lv_obj_style.h
+++ b/src/core/lv_obj_style.h
@@ -279,6 +279,13 @@ static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, lv_coord_t widt
lv_obj_set_style_height(obj, height, selector);
}
+static inline void lv_obj_set_style_transform_scale(struct _lv_obj_t * obj, lv_coord_t value,
+ lv_style_selector_t selector)
+{
+ lv_obj_set_style_transform_scale_x(obj, value, selector);
+ lv_obj_set_style_transform_scale_y(obj, value, selector);
+}
+
static inline lv_coord_t lv_obj_get_style_space_left(const struct _lv_obj_t * obj, uint32_t part)
{
lv_coord_t padding = lv_obj_get_style_pad_left(obj, part);
@@ -313,9 +320,15 @@ static inline lv_coord_t lv_obj_get_style_space_bottom(const struct _lv_obj_t *
lv_text_align_t lv_obj_calculate_style_text_align(const struct _lv_obj_t * obj, lv_part_t part, const char * txt);
-static inline lv_coord_t lv_obj_get_style_transform_scale_safe(const struct _lv_obj_t * obj, uint32_t part)
+static inline lv_coord_t lv_obj_get_style_transform_scale_x_safe(const struct _lv_obj_t * obj, uint32_t part)
{
- int16_t zoom = lv_obj_get_style_transform_scale(obj, part);
+ int16_t zoom = lv_obj_get_style_transform_scale_x(obj, part);
+ return zoom != 0 ? zoom : 1;
+}
+
+static inline lv_coord_t lv_obj_get_style_transform_scale_y_safe(const struct _lv_obj_t * obj, uint32_t part)
+{
+ int16_t zoom = lv_obj_get_style_transform_scale_y(obj, part);
return zoom != 0 ? zoom : 1;
}
diff --git a/src/core/lv_obj_style_gen.c b/src/core/lv_obj_style_gen.c
index bec9dbc19..4cfc9b874 100644
--- a/src/core/lv_obj_style_gen.c
+++ b/src/core/lv_obj_style_gen.c
@@ -114,12 +114,20 @@ void lv_obj_set_style_translate_y(struct _lv_obj_t * obj, lv_coord_t value, lv_s
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSLATE_Y, v, selector);
}
-void lv_obj_set_style_transform_scale(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
+void lv_obj_set_style_transform_scale_x(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
{
lv_style_value_t v = {
.num = (int32_t)value
};
- lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_SCALE, v, selector);
+ lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_SCALE_X, v, selector);
+}
+
+void lv_obj_set_style_transform_scale_y(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
+{
+ lv_style_value_t v = {
+ .num = (int32_t)value
+ };
+ lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_SCALE_Y, v, selector);
}
void lv_obj_set_style_transform_rotation(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
diff --git a/src/core/lv_obj_style_gen.h b/src/core/lv_obj_style_gen.h
index 513408f92..ab46221b0 100644
--- a/src/core/lv_obj_style_gen.h
+++ b/src/core/lv_obj_style_gen.h
@@ -92,9 +92,15 @@ static inline lv_coord_t lv_obj_get_style_translate_y(const struct _lv_obj_t * o
return (lv_coord_t)v.num;
}
-static inline lv_coord_t lv_obj_get_style_transform_scale(const struct _lv_obj_t * obj, uint32_t part)
+static inline lv_coord_t lv_obj_get_style_transform_scale_x(const struct _lv_obj_t * obj, uint32_t part)
{
- lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_SCALE);
+ lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_SCALE_X);
+ return (lv_coord_t)v.num;
+}
+
+static inline lv_coord_t lv_obj_get_style_transform_scale_y(const struct _lv_obj_t * obj, uint32_t part)
+{
+ lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_SCALE_Y);
return (lv_coord_t)v.num;
}
@@ -718,7 +724,8 @@ void lv_obj_set_style_transform_width(struct _lv_obj_t * obj, lv_coord_t value,
void lv_obj_set_style_transform_height(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
void lv_obj_set_style_translate_x(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
void lv_obj_set_style_translate_y(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
-void lv_obj_set_style_transform_scale(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
+void lv_obj_set_style_transform_scale_x(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
+void lv_obj_set_style_transform_scale_y(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
void lv_obj_set_style_transform_rotation(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
void lv_obj_set_style_transform_pivot_x(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
void lv_obj_set_style_transform_pivot_y(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
diff --git a/src/core/lv_refr.c b/src/core/lv_refr.c
index c18e386e5..dbbc7af0a 100644
--- a/src/core/lv_refr.c
+++ b/src/core/lv_refr.c
@@ -911,7 +911,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 = lv_obj_get_style_transform_scale(obj, 0);
+ 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.blend_mode = lv_obj_get_style_blend_mode(obj, 0);
layer_draw_dsc.antialias = disp_refr->antialiasing;
layer_draw_dsc.src = new_layer;
diff --git a/src/draw/lv_draw_image.c b/src/draw/lv_draw_image.c
index d7051ab5b..d02d48366 100644
--- a/src/draw/lv_draw_image.c
+++ b/src/draw/lv_draw_image.c
@@ -43,7 +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 = LV_SCALE_NONE;
+ dsc->zoom_x = LV_SCALE_NONE;
+ dsc->zoom_y = LV_SCALE_NONE;
dsc->antialias = LV_COLOR_DEPTH > 8 ? 1 : 0;
}
diff --git a/src/draw/lv_draw_image.h b/src/draw/lv_draw_image.h
index 07fca0942..22869d532 100644
--- a/src/draw/lv_draw_image.h
+++ b/src/draw/lv_draw_image.h
@@ -44,7 +44,8 @@ typedef struct _lv_draw_image_dsc_t {
lv_coord_t rotation;
- lv_coord_t zoom;
+ lv_coord_t zoom_x;
+ lv_coord_t zoom_y;
lv_point_t pivot;
lv_color_t recolor;
diff --git a/src/draw/lv_image_buf.c b/src/draw/lv_image_buf.c
index 1d66af93f..f060726bd 100644
--- a/src/draw/lv_image_buf.c
+++ b/src/draw/lv_image_buf.c
@@ -59,10 +59,11 @@ void lv_image_buf_free(lv_image_dsc_t * dsc)
}
}
-void _lv_image_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, lv_coord_t angle, uint16_t zoom,
+void _lv_image_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, lv_coord_t angle, uint16_t zoom_x,
+ uint16_t zoom_y,
const lv_point_t * pivot)
{
- if(angle == 0 && zoom == LV_SCALE_NONE) {
+ if(angle == 0 && zoom_x == LV_SCALE_NONE && zoom_y == LV_SCALE_NONE) {
res->x1 = 0;
res->y1 = 0;
res->x2 = w - 1;
@@ -76,10 +77,10 @@ void _lv_image_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_
{0, h - 1},
{w - 1, h - 1},
};
- lv_point_transform(&p[0], angle, zoom, pivot);
- lv_point_transform(&p[1], angle, zoom, pivot);
- lv_point_transform(&p[2], angle, zoom, pivot);
- lv_point_transform(&p[3], angle, zoom, pivot);
+ 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);
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);
diff --git a/src/draw/lv_image_buf.h b/src/draw/lv_image_buf.h
index e38be06e6..b0ab1b813 100644
--- a/src/draw/lv_image_buf.h
+++ b/src/draw/lv_image_buf.h
@@ -115,7 +115,8 @@ void lv_image_buf_free(lv_image_dsc_t * dsc);
* @param zoom zoom, (256 no zoom)
* @param pivot x,y pivot coordinates of rotation
*/
-void _lv_image_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, lv_coord_t angle, uint16_t zoom,
+void _lv_image_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, lv_coord_t angle, uint16_t zoom_x,
+ uint16_t zoom_y,
const lv_point_t * pivot);
/**********************
diff --git a/src/draw/sw/lv_draw_sw_img.c b/src/draw/sw/lv_draw_sw_img.c
index b28274f9f..304ab176f 100644
--- a/src/draw/sw/lv_draw_sw_img.c
+++ b/src/draw/sw/lv_draw_sw_img.c
@@ -151,11 +151,12 @@ 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 != LV_SCALE_NONE) {
+ if(draw_dsc->rotation || draw_dsc->zoom_x != LV_SCALE_NONE || draw_dsc->zoom_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, &draw_dsc->pivot);
+ _lv_image_buf_get_transformed_area(&transformed_area, w, h, draw_dsc->rotation, draw_dsc->zoom_x, draw_dsc->zoom_y,
+ &draw_dsc->pivot);
transformed_area.x1 += coords->x1;
transformed_area.y1 += coords->y1;
@@ -220,7 +221,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 != LV_SCALE_NONE ? true : false;
+ bool transformed = draw_dsc->rotation != 0 || draw_dsc->zoom_x != LV_SCALE_NONE ||
+ draw_dsc->zoom_y != LV_SCALE_NONE ? true : false;
lv_draw_sw_blend_dsc_t blend_dsc;
const uint8_t * src_buf = src->img_data;
diff --git a/src/draw/sw/lv_draw_sw_letter.c b/src/draw/sw/lv_draw_sw_letter.c
index 4f99ea222..dd4962837 100644
--- a/src/draw/sw/lv_draw_sw_letter.c
+++ b/src/draw/sw/lv_draw_sw_letter.c
@@ -94,7 +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 = LV_SCALE_NONE;
+ img_dsc.zoom_x = LV_SCALE_NONE;
+ img_dsc.zoom_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);
diff --git a/src/draw/sw/lv_draw_sw_transform.c b/src/draw/sw/lv_draw_sw_transform.c
index 8a9639099..4c0eaebc5 100644
--- a/src/draw/sw/lv_draw_sw_transform.c
+++ b/src/draw/sw/lv_draw_sw_transform.c
@@ -28,7 +28,8 @@ typedef struct {
int32_t y_out;
int32_t sinma;
int32_t cosma;
- int32_t zoom;
+ int32_t zoom_x;
+ int32_t zoom_y;
int32_t angle;
int32_t pivot_x_256;
int32_t pivot_y_256;
@@ -87,7 +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 = (256 * 256) / draw_dsc->zoom;
+ tr_dsc.zoom_x = (256 * 256) / draw_dsc->zoom_x;
+ tr_dsc.zoom_y = (256 * 256) / draw_dsc->zoom_y;
tr_dsc.pivot = draw_dsc->pivot;
int32_t angle_low = tr_dsc.angle / 10;
@@ -581,7 +583,7 @@ static void transform_a8(const uint8_t * src, lv_coord_t src_w, lv_coord_t src_h
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 == LV_SCALE_NONE) {
+ if(t->angle == 0 && t->zoom_x == LV_SCALE_NONE && t->zoom_y == LV_SCALE_NONE) {
*xout = xin * 256;
*yout = yin * 256;
return;
@@ -591,16 +593,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)) + (t->pivot_x_256);
- *yout = ((int32_t)(yin * t->zoom)) + (t->pivot_y_256);
+ *xout = ((int32_t)(xin * t->zoom_x)) + (t->pivot_x_256);
+ *yout = ((int32_t)(yin * t->zoom_y)) + (t->pivot_y_256);
}
- else if(t->zoom == LV_SCALE_NONE) {
+ else if(t->zoom_x == LV_SCALE_NONE && t->zoom_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) >> 10) + (t->pivot_x_256);
- *yout = (((t->sinma * xin + t->cosma * yin) * t->zoom) >> 10) + (t->pivot_y_256);
+ *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);
}
}
diff --git a/src/indev/lv_indev.c b/src/indev/lv_indev.c
index 8c4bd4597..f7e2ed222 100644
--- a/src/indev/lv_indev.c
+++ b/src/indev/lv_indev.c
@@ -1166,21 +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 = 256;
+ int16_t zoom_x = 256;
+ int16_t zoom_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 = lv_obj_get_style_transform_scale_safe(parent, 0);
- zoom = (zoom * zoom_act) >> 8;
+ 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;
parent = lv_obj_get_parent(parent);
}
- if(angle != 0 || zoom != LV_SCALE_NONE) {
+ if(angle != 0 || zoom_y != LV_SCALE_NONE || zoom_x != LV_SCALE_NONE) {
angle = -angle;
- zoom = (256 * 256) / zoom;
- lv_point_transform(&indev->pointer.scroll_throw_vect, angle, zoom, &pivot);
- lv_point_transform(&indev->pointer.scroll_throw_vect_ori, angle, zoom, &pivot);
+ 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);
}
}
diff --git a/src/indev/lv_indev_scroll.c b/src/indev/lv_indev_scroll.c
index c1d7206b7..c4480a541 100644
--- a/src/indev/lv_indev_scroll.c
+++ b/src/indev/lv_indev_scroll.c
@@ -64,20 +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 = 256;
+ int16_t zoom_x = 256;
+ int16_t zoom_y = 256;
lv_obj_t * parent = scroll_obj;
while(parent) {
angle += lv_obj_get_style_transform_rotation(parent, 0);
- int32_t zoom_act = lv_obj_get_style_transform_scale_safe(parent, 0);
- zoom = (zoom * zoom_act) >> 8;
+ 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;
parent = lv_obj_get_parent(parent);
}
- if(angle != 0 || zoom != LV_SCALE_NONE) {
+ if(angle != 0 || zoom_x != LV_SCALE_NONE || zoom_y != LV_SCALE_NONE) {
angle = -angle;
- zoom = (256 * 256) / zoom;
+ zoom_x = (256 * 256) / zoom_x;
+ zoom_y = (256 * 256) / zoom_y;
lv_point_t pivot = { 0, 0 };
- lv_point_transform(&indev->pointer.vect, angle, zoom, &pivot);
+ lv_point_transform(&indev->pointer.vect, angle, zoom_x, zoom_y, &pivot, false);
}
@@ -289,21 +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 = 256;
+ int32_t zoom_x = 256;
+ int32_t zoom_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 = lv_obj_get_style_transform_scale_safe(parent, 0);
- zoom = (zoom * zoom_act) >> 8;
+ 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;
parent = lv_obj_get_parent(parent);
}
lv_point_t obj_scroll_sum = indev->pointer.scroll_sum;
- if(angle != 0 || zoom != LV_SCALE_NONE) {
+ if(angle != 0 || zoom_x != LV_SCALE_NONE || zoom_y != LV_SCALE_NONE) {
angle = -angle;
- zoom = (256 * 256) / zoom;
- lv_point_transform(&obj_scroll_sum, angle, zoom, &pivot);
+ 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);
}
if(LV_ABS(obj_scroll_sum.x) > LV_ABS(obj_scroll_sum.y)) {
diff --git a/src/misc/lv_area.c b/src/misc/lv_area.c
index fb715ba27..3cbd05eb3 100644
--- a/src/misc/lv_area.c
+++ b/src/misc/lv_area.c
@@ -531,9 +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, const lv_point_t * pivot)
+void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom_x, int32_t zoom_y, const lv_point_t * pivot,
+ bool zoom_first)
{
- if(angle == 0 && zoom == 256) {
+ if(angle == 0 && zoom_x == 256 && zoom_y == 256) {
return;
}
@@ -541,8 +542,8 @@ void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom, const lv_po
p->y -= pivot->y;
if(angle == 0) {
- p->x = (((int32_t)(p->x) * zoom) >> 8) + pivot->x;
- p->y = (((int32_t)(p->y) * zoom) >> 8) + pivot->y;
+ p->x = (((int32_t)(p->x) * zoom_x) >> 8) + pivot->x;
+ p->y = (((int32_t)(p->y) * zoom_y) >> 8) + pivot->y;
return;
}
lv_area_transform_cache_t * cache = &trans_cache;
@@ -569,13 +570,22 @@ void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom, const lv_po
}
int32_t x = p->x;
int32_t y = p->y;
- if(zoom == 256) {
+ if(zoom_x == 256 && zoom_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 {
- p->x = (((cache->cosma * x - cache->sinma * y) * zoom) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->x;
- p->y = (((cache->sinma * x + cache->cosma * y) * zoom) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->y;
+ if(zoom_first) {
+ x *= zoom_x;
+ y *= zoom_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;
+ }
+
}
}
diff --git a/src/misc/lv_area.h b/src/misc/lv_area.h
index 0ed24cabc..0206fab33 100644
--- a/src/misc/lv_area.h
+++ b/src/misc/lv_area.h
@@ -264,7 +264,8 @@ 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, lv_coord_t ofs_x, lv_coord_t ofs_y);
-void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom, const lv_point_t * pivot);
+void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom_x, int32_t zoom_y, const lv_point_t * pivot,
+ bool zoom_first);
/**********************
* MACROS
diff --git a/src/misc/lv_style.c b/src/misc/lv_style.c
index 2041fb763..37faf24b0 100644
--- a/src/misc/lv_style.c
+++ b/src/misc/lv_style.c
@@ -48,7 +48,8 @@ const uint8_t _lv_style_builtin_prop_flag_lookup_table[_LV_STYLE_NUM_BUILT_IN_PR
[LV_STYLE_TRANSFORM_HEIGHT] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM,
[LV_STYLE_TRANSLATE_X] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE | LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE,
[LV_STYLE_TRANSLATE_Y] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE | LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE,
- [LV_STYLE_TRANSFORM_SCALE] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM,
+ [LV_STYLE_TRANSFORM_SCALE_X] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM,
+ [LV_STYLE_TRANSFORM_SCALE_Y] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM,
[LV_STYLE_TRANSFORM_ROTATION] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM,
[LV_STYLE_PAD_TOP] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYOUT_UPDATE,
@@ -345,7 +346,8 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)
const lv_color_t black = LV_COLOR_MAKE(0x00, 0x00, 0x00);
const lv_color_t white = LV_COLOR_MAKE(0xff, 0xff, 0xff);
switch(prop) {
- case LV_STYLE_TRANSFORM_SCALE:
+ case LV_STYLE_TRANSFORM_SCALE_X:
+ case LV_STYLE_TRANSFORM_SCALE_Y:
return (lv_style_value_t) {
.num = LV_SCALE_NONE
};
diff --git a/src/misc/lv_style.h b/src/misc/lv_style.h
index 840c895da..adede6005 100644
--- a/src/misc/lv_style.h
+++ b/src/misc/lv_style.h
@@ -296,25 +296,26 @@ enum _lv_style_prop_t {
LV_STYLE_TEXT_OPA = 89,
LV_STYLE_TEXT_FONT = 90,
- LV_STYLE_TEXT_LETTER_SPACE = 92,
- LV_STYLE_TEXT_LINE_SPACE = 93,
- LV_STYLE_TEXT_DECOR = 94,
- LV_STYLE_TEXT_ALIGN = 95,
+ LV_STYLE_TEXT_LETTER_SPACE = 91,
+ LV_STYLE_TEXT_LINE_SPACE = 92,
+ LV_STYLE_TEXT_DECOR = 93,
+ LV_STYLE_TEXT_ALIGN = 94,
- LV_STYLE_OPA = 96,
- LV_STYLE_OPA_LAYERED = 97,
- LV_STYLE_COLOR_FILTER_DSC = 98,
- LV_STYLE_COLOR_FILTER_OPA = 99,
- LV_STYLE_ANIM = 100,
- LV_STYLE_ANIM_TIME = 101,
- LV_STYLE_ANIM_SPEED = 102,
- LV_STYLE_TRANSITION = 103,
- LV_STYLE_BLEND_MODE = 104,
- LV_STYLE_TRANSFORM_WIDTH = 105,
- LV_STYLE_TRANSFORM_HEIGHT = 106,
- LV_STYLE_TRANSLATE_X = 107,
- LV_STYLE_TRANSLATE_Y = 108,
- LV_STYLE_TRANSFORM_SCALE = 109,
+ LV_STYLE_OPA = 95,
+ LV_STYLE_OPA_LAYERED = 96,
+ LV_STYLE_COLOR_FILTER_DSC = 97,
+ LV_STYLE_COLOR_FILTER_OPA = 98,
+ LV_STYLE_ANIM = 99,
+ LV_STYLE_ANIM_TIME = 100,
+ LV_STYLE_ANIM_SPEED = 101,
+ LV_STYLE_TRANSITION = 102,
+ LV_STYLE_BLEND_MODE = 103,
+ LV_STYLE_TRANSFORM_WIDTH = 104,
+ LV_STYLE_TRANSFORM_HEIGHT = 105,
+ LV_STYLE_TRANSLATE_X = 106,
+ LV_STYLE_TRANSLATE_Y = 107,
+ LV_STYLE_TRANSFORM_SCALE_X = 108,
+ LV_STYLE_TRANSFORM_SCALE_Y = 109,
LV_STYLE_TRANSFORM_ROTATION = 110,
LV_STYLE_TRANSFORM_PIVOT_X = 111,
LV_STYLE_TRANSFORM_PIVOT_Y = 112,
@@ -605,6 +606,12 @@ static inline void lv_style_set_pad_gap(lv_style_t * style, lv_coord_t value)
lv_style_set_pad_column(style, value);
}
+static inline void lv_style_set_transform_scale(lv_style_t * style, lv_coord_t value)
+{
+ lv_style_set_transform_scale_x(style, value);
+ lv_style_set_transform_scale_y(style, value);
+}
+
/**
* @brief Check if the style property has a specified behavioral flag.
*
diff --git a/src/misc/lv_style_gen.c b/src/misc/lv_style_gen.c
index 6cd1c1e3b..dfe23c5e7 100644
--- a/src/misc/lv_style_gen.c
+++ b/src/misc/lv_style_gen.c
@@ -140,15 +140,25 @@ void lv_style_set_translate_y(lv_style_t * style, lv_coord_t value)
const lv_style_prop_t _lv_style_const_prop_id_TRANSLATE_Y = LV_STYLE_TRANSLATE_Y;
-void lv_style_set_transform_scale(lv_style_t * style, lv_coord_t value)
+void lv_style_set_transform_scale_x(lv_style_t * style, lv_coord_t value)
{
lv_style_value_t v = {
.num = (int32_t)value
};
- lv_style_set_prop(style, LV_STYLE_TRANSFORM_SCALE, v);
+ lv_style_set_prop(style, LV_STYLE_TRANSFORM_SCALE_X, v);
}
-const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SCALE = LV_STYLE_TRANSFORM_SCALE;
+const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SCALE_X = LV_STYLE_TRANSFORM_SCALE_X;
+
+void lv_style_set_transform_scale_y(lv_style_t * style, lv_coord_t value)
+{
+ lv_style_value_t v = {
+ .num = (int32_t)value
+ };
+ lv_style_set_prop(style, LV_STYLE_TRANSFORM_SCALE_Y, v);
+}
+
+const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SCALE_Y = LV_STYLE_TRANSFORM_SCALE_Y;
void lv_style_set_transform_rotation(lv_style_t * style, lv_coord_t value)
{
diff --git a/src/misc/lv_style_gen.h b/src/misc/lv_style_gen.h
index 0bbe4b30a..d8d56917f 100644
--- a/src/misc/lv_style_gen.h
+++ b/src/misc/lv_style_gen.h
@@ -36,8 +36,10 @@ void lv_style_set_translate_x(lv_style_t * style, lv_coord_t value);
extern const lv_style_prop_t _lv_style_const_prop_id_TRANSLATE_X;
void lv_style_set_translate_y(lv_style_t * style, lv_coord_t value);
extern const lv_style_prop_t _lv_style_const_prop_id_TRANSLATE_Y;
-void lv_style_set_transform_scale(lv_style_t * style, lv_coord_t value);
-extern const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SCALE;
+void lv_style_set_transform_scale_x(lv_style_t * style, lv_coord_t value);
+extern const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SCALE_X;
+void lv_style_set_transform_scale_y(lv_style_t * style, lv_coord_t value);
+extern const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SCALE_Y;
void lv_style_set_transform_rotation(lv_style_t * style, lv_coord_t value);
extern const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_ROTATION;
void lv_style_set_transform_pivot_x(lv_style_t * style, lv_coord_t value);
@@ -284,9 +286,14 @@ extern const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_ROW_SPAN;
.prop_ptr = &_lv_style_const_prop_id_TRANSLATE_Y, .value = { .num = (int32_t)val } \
}
-#define LV_STYLE_CONST_TRANSFORM_SCALE(val) \
+#define LV_STYLE_CONST_TRANSFORM_SCALE_X(val) \
{ \
- .prop_ptr = &_lv_style_const_prop_id_TRANSFORM_SCALE, .value = { .num = (int32_t)val } \
+ .prop_ptr = &_lv_style_const_prop_id_TRANSFORM_SCALE_X, .value = { .num = (int32_t)val } \
+ }
+
+#define LV_STYLE_CONST_TRANSFORM_SCALE_Y(val) \
+ { \
+ .prop_ptr = &_lv_style_const_prop_id_TRANSFORM_SCALE_Y, .value = { .num = (int32_t)val } \
}
#define LV_STYLE_CONST_TRANSFORM_ROTATION(val) \
diff --git a/src/themes/default/lv_theme_default.c b/src/themes/default/lv_theme_default.c
index 338c09200..816a52b2e 100644
--- a/src/themes/default/lv_theme_default.c
+++ b/src/themes/default/lv_theme_default.c
@@ -219,7 +219,8 @@ static void style_init(struct _my_theme_t * theme)
LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR,
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT,
LV_STYLE_TRANSLATE_Y, LV_STYLE_TRANSLATE_X,
- LV_STYLE_TRANSFORM_SCALE, LV_STYLE_TRANSFORM_ROTATION,
+ LV_STYLE_TRANSFORM_ROTATION,
+ LV_STYLE_TRANSFORM_SCALE_X, LV_STYLE_TRANSFORM_SCALE_Y,
LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_DSC,
0
};
diff --git a/src/widgets/image/lv_image.c b/src/widgets/image/lv_image.c
index d24b3203f..e33999a37 100644
--- a/src/widgets/image/lv_image.c
+++ b/src/widgets/image/lv_image.c
@@ -192,7 +192,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, &pivot_px);
+ _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom, img->zoom, &pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -208,7 +208,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, &pivot_px);
+ _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom, img->zoom, &pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -234,7 +234,7 @@ void lv_image_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_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, &pivot_px);
+ _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom, img->zoom, &pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -252,7 +252,7 @@ void lv_image_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_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, &pivot_px);
+ _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom, img->zoom, &pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -279,7 +279,7 @@ void lv_image_set_scale(lv_obj_t * obj, uint32_t zoom)
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, &pivot_px);
+ _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom, img->zoom, &pivot_px);
a.x1 += obj->coords.x1 - 1;
a.y1 += obj->coords.y1 - 1;
a.x2 += obj->coords.x1 + 1;
@@ -295,7 +295,7 @@ void lv_image_set_scale(lv_obj_t * obj, uint32_t zoom)
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, &pivot_px);
+ _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom, img->zoom, &pivot_px);
a.x1 += obj->coords.x1 - 1;
a.y1 += obj->coords.y1 - 1;
a.x2 += obj->coords.x1 + 1;
@@ -449,7 +449,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, &pivot_px);
+ img->rotation, img->zoom, img->zoom, &pivot_px);
return (lv_point_t) {
lv_area_get_width(&area_transform), lv_area_get_height(&area_transform)
@@ -493,7 +493,7 @@ static void lv_image_event(const lv_obj_class_t * class_p, lv_event_t * e)
lv_area_t a;
lv_coord_t w = lv_obj_get_width(obj);
lv_coord_t h = lv_obj_get_height(obj);
- _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom, &pivot_px);
+ _lv_image_buf_get_transformed_area(&a, w, h, img->rotation, img->zoom, img->zoom, &pivot_px);
*s = LV_MAX(*s, -a.x1);
*s = LV_MAX(*s, -a.y1);
*s = LV_MAX(*s, a.x2 - w);
@@ -511,7 +511,7 @@ static void lv_image_event(const lv_obj_class_t * class_p, lv_event_t * e)
lv_coord_t w = lv_obj_get_width(obj);
lv_coord_t h = lv_obj_get_height(obj);
lv_area_t coords;
- _lv_image_buf_get_transformed_area(&coords, w, h, img->rotation, img->zoom, &pivot_px);
+ _lv_image_buf_get_transformed_area(&coords, w, h, img->rotation, img->zoom, img->zoom, &pivot_px);
coords.x1 += obj->coords.x1;
coords.y1 += obj->coords.y1;
coords.x2 += obj->coords.x1;
@@ -581,7 +581,8 @@ 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, &pivot_px);
+ _lv_image_buf_get_transformed_area(&a, lv_obj_get_width(obj), lv_obj_get_height(obj), 0, img->zoom, img->zoom,
+ &pivot_px);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -618,7 +619,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, &bg_pivot);
+ img->rotation, img->zoom, img->zoom, &bg_pivot);
/*Modify the coordinates to draw the background for the rotated and scaled coordinates*/
bg_coords.x1 += obj->coords.x1;
@@ -668,7 +669,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 = img->zoom;
+ img_dsc.zoom_x = img->zoom;
+ img_dsc.zoom_y = img->zoom;
img_dsc.rotation = img->rotation;
img_dsc.pivot.x = pivot_px.x;
img_dsc.pivot.y = pivot_px.y;
diff --git a/src/widgets/image/lv_image.h b/src/widgets/image/lv_image.h
index 26c8fdedd..713f287fc 100644
--- a/src/widgets/image/lv_image.h
+++ b/src/widgets/image/lv_image.h
@@ -44,7 +44,7 @@ typedef struct {
lv_coord_t w; /*Width of the image (Handled by the library)*/
lv_coord_t h; /*Height of the image (Handled by the library)*/
uint32_t rotation; /*rotation angle of the image*/
- uint32_t zoom; /*256 means no zoom, 512 double size, 128 half size*/
+ uint32_t zoom; /*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`*/
diff --git a/src/widgets/roller/lv_roller.c b/src/widgets/roller/lv_roller.c
index a0fd60082..0e67710ce 100644
--- a/src/widgets/roller/lv_roller.c
+++ b/src/widgets/roller/lv_roller.c
@@ -823,17 +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 = 256;
+ int32_t zoom_x = 256;
+ int32_t zoom_y = 256;
lv_obj_t * parent = roller;
while(parent) {
angle += lv_obj_get_style_transform_rotation(parent, 0);
- int32_t zoom_act = lv_obj_get_style_transform_scale_safe(parent, 0);
- zoom = (zoom * zoom_act) >> 8;
+ 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;
parent = lv_obj_get_parent(parent);
}
lv_point_t pivot = { 0, 0 };
- lv_point_transform(vect, -angle, 256 * 256 / zoom, &pivot);
+ zoom_x = 256 * 256 / zoom_x;
+ zoom_y = 256 * 256 / zoom_y;
+ lv_point_transform(vect, -angle, zoom_x, zoom_y, &pivot, false);
}
#endif
diff --git a/src/widgets/scale/lv_scale.c b/src/widgets/scale/lv_scale.c
index 5e861853f..60cf64bb7 100644
--- a/src/widgets/scale/lv_scale.c
+++ b/src/widgets/scale/lv_scale.c
@@ -543,7 +543,7 @@ static void scale_draw_indicator(lv_obj_t * obj, lv_event_t * event)
lv_point_t point;
point.x = center_point.x + radius_text;
point.y = center_point.y;
- lv_point_transform(&point, angle_upscale, LV_SCALE_NONE, ¢er_point);
+ lv_point_transform(&point, angle_upscale, LV_SCALE_NONE, LV_SCALE_NONE, ¢er_point, false);
scale_get_label_coords(obj, &label_dsc, &point, &label_coords);
lv_draw_label(layer, &label_dsc, &label_coords);
@@ -907,11 +907,11 @@ static void scale_get_tick_points(lv_obj_t * obj, const uint32_t tick_idx, bool
tick_point_a->x = center_point.x + point_closer_to_arc;
tick_point_a->y = center_point.y;
- lv_point_transform(tick_point_a, angle_upscale, LV_SCALE_NONE, ¢er_point);
+ lv_point_transform(tick_point_a, angle_upscale, LV_SCALE_NONE, LV_SCALE_NONE, ¢er_point, false);
tick_point_b->x = center_point.x + adjusted_radio_with_tick_len;
tick_point_b->y = center_point.y;
- lv_point_transform(tick_point_b, angle_upscale, LV_SCALE_NONE, ¢er_point);
+ lv_point_transform(tick_point_b, angle_upscale, LV_SCALE_NONE, LV_SCALE_NONE, ¢er_point, false);
}
else { /* Nothing to do */ }
}
diff --git a/src/widgets/slider/lv_slider.c b/src/widgets/slider/lv_slider.c
index c82be3124..3ac007807 100644
--- a/src/widgets/slider/lv_slider.c
+++ b/src/widgets/slider/lv_slider.c
@@ -194,11 +194,9 @@ static void lv_slider_event(const lv_obj_class_t * class_p, lv_event_t * e)
lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB);
/*The smaller size is the knob diameter*/
- lv_coord_t zoom = lv_obj_get_style_transform_scale(obj, LV_PART_KNOB);
lv_coord_t trans_w = lv_obj_get_style_transform_width(obj, LV_PART_KNOB);
lv_coord_t trans_h = lv_obj_get_style_transform_height(obj, LV_PART_KNOB);
lv_coord_t knob_size = LV_MIN(lv_obj_get_width(obj) + 2 * trans_w, lv_obj_get_height(obj) + 2 * trans_h) >> 1;
- knob_size = (knob_size * zoom) >> 8;
knob_size += LV_MAX(LV_MAX(knob_left, knob_right), LV_MAX(knob_bottom, knob_top));
knob_size += 2; /*For rounding error*/
knob_size += lv_obj_calculate_ext_draw_size(obj, LV_PART_KNOB);
diff --git a/tests/ref_imgs/draw/transform_argb8888.png b/tests/ref_imgs/draw/transform_argb8888.png
index d2b7475a7..6f027840f 100644
Binary files a/tests/ref_imgs/draw/transform_argb8888.png and b/tests/ref_imgs/draw/transform_argb8888.png differ
diff --git a/tests/ref_imgs/draw/transform_rgb565.png b/tests/ref_imgs/draw/transform_rgb565.png
index cff3b748a..7a181efb4 100644
Binary files a/tests/ref_imgs/draw/transform_rgb565.png and b/tests/ref_imgs/draw/transform_rgb565.png differ
diff --git a/tests/ref_imgs/draw/transform_rgb888.png b/tests/ref_imgs/draw/transform_rgb888.png
index 8433c9991..141f9d52b 100644
Binary files a/tests/ref_imgs/draw/transform_rgb888.png and b/tests/ref_imgs/draw/transform_rgb888.png differ
diff --git a/tests/ref_imgs/draw/transform_xrgb8888.png b/tests/ref_imgs/draw/transform_xrgb8888.png
index 8433c9991..141f9d52b 100644
Binary files a/tests/ref_imgs/draw/transform_xrgb8888.png and b/tests/ref_imgs/draw/transform_xrgb8888.png differ
diff --git a/tests/src/test_cases/draw/test_draw_line.c b/tests/src/test_cases/draw/test_draw_line.c
index 62a93ff7d..6e025f2a7 100644
--- a/tests/src/test_cases/draw/test_draw_line.c
+++ b/tests/src/test_cases/draw/test_draw_line.c
@@ -28,8 +28,8 @@ static void radial_lines_create(lv_style_t * style, uint32_t line_index)
p[i][1].x = 100 + length;
p[i][1].y = 100;
- lv_point_transform(&p[i][0], i * 150, 256, &pivot);
- lv_point_transform(&p[i][1], i * 150, 256, &pivot);
+ lv_point_transform(&p[i][0], i * 150, LV_SCALE_NONE, LV_SCALE_NONE, &pivot, false);
+ lv_point_transform(&p[i][1], i * 150, LV_SCALE_NONE, LV_SCALE_NONE, &pivot, false);
lv_line_set_points(line, p[i], 2);
lv_obj_set_pos(line, line_index % 4 * 200, line_index / 4 * 200);
diff --git a/tests/src/test_cases/draw/test_draw_transform.c b/tests/src/test_cases/draw/test_draw_transform.c
index 241c8bee8..4c9da37ad 100644
--- a/tests/src/test_cases/draw/test_draw_transform.c
+++ b/tests/src/test_cases/draw/test_draw_transform.c
@@ -88,29 +88,43 @@ static void draw_images(lv_layer_t * layer, lv_draw_image_dsc_t * dsc)
dsc->pivot.x = 50;
dsc->pivot.y = 50;
dsc->rotation = 0;
- dsc->zoom = 128;
+ dsc->zoom_x = 128;
+ dsc->zoom_y = 128;
lv_draw_image(layer, dsc, &area);
lv_area_move(&area, 110, 0);
- dsc->zoom = 300;
+ dsc->zoom_x = 300;
+ dsc->zoom_y = 300;
lv_draw_image(layer, dsc, &area);
lv_area_move(&area, 110, 0);
dsc->pivot.x = 0;
dsc->pivot.y = 0;
- dsc->zoom = 128;
+ dsc->zoom_x = 128;
+ dsc->zoom_y = 128;
lv_draw_image(layer, dsc, &area);
lv_area_move(&area, 110, 0);
- dsc->zoom = 300;
+ dsc->zoom_x = 300;
+ dsc->zoom_y = 300;
lv_draw_image(layer, dsc, &area);
/* Zoom + Angle*/
dsc->rotation = 650;
- dsc->zoom = 200;
+ dsc->zoom_x = 200;
+ dsc->zoom_y = 200;
lv_area_move(&area, 200, 0);
lv_draw_image(layer, dsc, &area);
+ /* Zoom non uniform + Angle*/
+ dsc->rotation = 750;
+ dsc->zoom_x = 128;
+ dsc->zoom_y = 350;
+ dsc->pivot.x = 40;
+ dsc->pivot.y = 40;
+ lv_area_move(&area, 100, 0);
+ lv_draw_image(layer, dsc, &area);
+
/*Edge color bleeding test*/
lv_draw_rect_dsc_t rect_dsc;
lv_draw_rect_dsc_init(&rect_dsc);
@@ -128,22 +142,32 @@ static void draw_images(lv_layer_t * layer, lv_draw_image_dsc_t * dsc)
dsc->pivot.x = 50;
dsc->pivot.y = 50;
dsc->rotation = 0;
- dsc->zoom = 256;
+ dsc->zoom_x = 256;
+ dsc->zoom_y = 256;
lv_draw_image(layer, dsc, &area);
lv_area_move(&area, 180, 0);
dsc->rotation = 300;
- dsc->zoom = 200;
+ dsc->zoom_x = 200;
+ dsc->zoom_y = 200;
lv_draw_image(layer, dsc, &area);
lv_area_move(&area, 150, 0);
dsc->rotation = 1400;
- dsc->zoom = 150;
+ dsc->zoom_x = 150;
+ dsc->zoom_y = 150;
lv_draw_image(layer, dsc, &area);
lv_area_move(&area, 120, 0);
dsc->rotation = 2000;
- dsc->zoom = 100;
+ dsc->zoom_x = 100;
+ dsc->zoom_y = 100;
+ lv_draw_image(layer, dsc, &area);
+
+ lv_area_move(&area, 120, 0);
+ dsc->rotation = 2000;
+ dsc->zoom_x = 350;
+ dsc->zoom_y = 100;
lv_draw_image(layer, dsc, &area);
}