fix canvas_get_vgcanvas, init text_baseline/text_align

This commit is contained in:
xianjimli 2019-03-06 11:21:01 +08:00
parent ca5bd6d42f
commit 2d39829ef1
3 changed files with 28 additions and 0 deletions

View File

@ -283,6 +283,31 @@ static ret_t on_paint_center(void* ctx, event_t* e) {
#include "vg_common.inc"
static ret_t on_paint_text(void* ctx, event_t* e) {
int32_t x = 0;
int32_t y = 0;
paint_event_t* evt = (paint_event_t*)e;
canvas_t* c = evt->c;
color_t color = color_init(0xff, 0, 0, 0xff);
vgcanvas_t* vg = canvas_get_vgcanvas(c);
color = color_init(0xff, 0, 0, 0xff);
canvas_set_stroke_color(c, color);
canvas_stroke_rect(c, x, y, 100, 30);
color = color_init(0xff, 0, 0, 0xff);
canvas_set_text_color(c, color);
canvas_set_font(c, NULL, 30);
vgcanvas_set_fill_color(vg, color);
vgcanvas_fill_text(vg, "ABC", 0, 0, 100);
/*
vgcanvas_translate(vg, x, y);
canvas_draw_text(c, L"abc", 3, 0, 0);
*/
return RET_OK;
}
static ret_t on_paint_vg(void* ctx, event_t* e) {
paint_event_t* evt = (paint_event_t*)e;
canvas_t* c = evt->c;

View File

@ -2,6 +2,7 @@
* 2019/03/05
* 更新文档。
* slide view支持循环切换。
* 修改canvas\_draw\_text和vgcanvas\_fill\_text坐标不一致的问题。
* 2019/03/04
* 完善progressbar/slider的显示函数。

View File

@ -1349,6 +1349,8 @@ vgcanvas_t* canvas_get_vgcanvas(canvas_t* c) {
canvas_get_clip_rect(c, &r);
vgcanvas_clip_rect(vg, r.x, r.y, r.w, r.h);
vgcanvas_begin_path(vg);
vgcanvas_set_text_align(vg, "left");
vgcanvas_set_text_baseline(vg, "top");
}
return vg;