jrmobley / pebble-fctx Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi, i was tested on your test-app, changed the angle at
line 122
fctx_set_rotation(&fctx, 90);
but the text is not rotated.
I also testing on the other: https://github.com/jrmobley/pebble-laughing-demo. It's was same :(
I really like your project, hope you can fix it soon.
I have a piece of code that gets called on the minute, determines a resource ID, gets the path via fpath_create_from_resource then draws it using fctx_draw_commands.
sometimes the drawing part falls apart, even if the resource ID never changes.
Here's the piece of code
uint32_t weather_icon_resourceid = weather_icons_day[1].resourceid;
if (w_daynight == 1) {
fctx_set_offset(&fctx, FPointI(122+weather_icons_day[w_icon].offsetx-(temp_offset/30), weather_icons_day[w_icon].offsety));
weather_icon_resourceid = weather_icons_day[w_icon].resourceid;
} else {
fctx_set_offset(&fctx, FPointI(122+weather_icons_night[w_icon].offsetx-(temp_offset/30), weather_icons_night[w_icon].offsety));
weather_icon_resourceid = weather_icons_night[w_icon].resourceid;
}
fctx_set_scale(&fctx, FPointI(180,180), FPointI(168,168));
APP_LOG(APP_LOG_LEVEL_INFO, "weather icon resource id is %lu", weather_icon_resourceid);
weather_icon_path = fpath_create_from_resource(weather_icon_resourceid);
fctx_draw_commands(&fctx, FPointZero, weather_icon_path->data, weather_icon_path->size);
and here are two logs
[22:42:01] main.c:237> Redrawing screen
[22:42:01] main.c:339> weather icon resource id is 9
[22:42:01] main.c:388> Steps: 0
[22:43:01] main.c:237> Redrawing screen
[22:43:01] main.c:339> weather icon resource id is 9
[22:43:01] main.c:388> Steps: 0
[22:44:01] main.c:237> Redrawing screen
[22:44:01] main.c:339> weather icon resource id is 9
[22:44:01] main.c:388> Steps: 0
[22:45:01] main.c:237> Redrawing screen
[22:45:01] main.c:339> weather icon resource id is 9
[22:45:01] fctx.c:887> invalid draw command "
[22:45:01] main.c:388> Steps: 0
[22:46:01] main.c:237> Redrawing screen
[22:46:01] main.c:339> weather icon resource id is 9
[22:46:01] fctx.c:887> invalid draw command "
[22:46:01] main.c:388> Steps: 0
[22:47:01] main.c:237> Redrawing screen
[22:47:01] main.c:339> weather icon resource id is 9
[22:47:01] fctx.c:887> invalid draw command "
[22:47:01] main.c:388> Steps: 0
[22:48:01] main.c:237> Redrawing screen
[22:48:01] main.c:339> weather icon resource id is 9
[22:48:01] fctx.c:887> invalid draw command "
[22:48:01] main.c:388> Steps: 0
(once it starts happening this one will go on and on failing and not draw any icon, in the basalt emulator)
[22:47:04] main.c:237> Redrawing screen
[22:47:04] main.c:339> weather icon resource id is 9
[22:47:04] main.c:388> Steps: 21
[22:48:03] main.c:237> Redrawing screen
[22:48:03] main.c:339> weather icon resource id is 9
[22:48:03] main.c:388> Steps: 21
[22:49:03] main.c:237> Redrawing screen
[22:49:03] main.c:339> weather icon resource id is 9
[22:49:03] ault_handling.c:74> App fault! {b4d23fe5-030c-4a72-99e6-a18e84554cf4} PC: 0x1418 LR: 0x806b021
Program Counter (PC) : 0x1418 /Users/peter/pebble/PJ-Business/watchface/build/../src/main.c:341
Link Register (LR) : 0x806b021 ???
(this one sporadically happens and will restart the watchface, on actual basalt hardware with firmware 3.9.1)
both of these happen with SDK 3.9
the FPath has been defined at the top of main.c in this line
FPath *p_bt_icon, *p_tick_mark, *weather_icon_path;
attached is the fpath behind resource id 9
0910dn.fpath.zip
It'd be nice if the readme said to add
#include <pebble-fctx/fctx.h>
assuming that's how you actually include it (I'm just learning about fctx now)
There might be some other docs that I missed, but for the moment I assume the only docs are the readme.
The pivot transform is not mentioned in the readme. I got it to work for me with a bit of experimenting, but it would be great to have it explained together with the other transforms.
I would make a PR with the explanation myself, but I do not understand it well, especially in terms of ordering with respect to the other transforms.
Thanks for writing this library!
Find a way to eliminate the malloc
call in fctx_draw_path
. At least make it optional. Also provide an API for applying transforms independent of drawing. This would allow efficient re-use of transformed points in multiple plot calls.
It would be nice to have a function to get the width of a given string in pixels when it is drawn at a particular width, similar to graphics_text_layout_get_content_size from the Pebble SDK. Alternatively, fctx_draw_string could return that value.
Would you consider adding this functionality (or is it already there and I missed it)?
The fctx_move_to
, fctx_line_to
, and fctx_curve_to
functions need a buddy called fctx_close_path
.
The code at https://github.com/jrmobley/pebble-fctx/blob/master/fctx.c#L918 treats each character of the text string as its own glyph. This won't work for UTF-8 encoded strings where characters above 127 are represented as multiple bytes. Since Pebble's graphics_draw_text is explicitly marked as taking UTF-8, this should either be fixed or documented to not surprise programmers using the library.
Add some feature macros to disable font and text support at compile time.
Could you please publish a package compatible with diorite ? :)
Thanks !
Is there some trick to getting text drawing to work in Aplite?
Drawing text in Basalt & Chalk seems to work fine, but every time I try to run the same code in Aplite, I get the following error message:
[ERROR] fctx.c:39: NULL fctx->flag_buffer
Any ideas?
Letter-spacing has increased in the latest commit 9cd558f. Using the same svg font files, the newly generated ffont files used in the latest fctx produce significantly wider lines than ffont files from the same svg sources compiled for and used with the previous fctx release. There were no code changes in the watchface. I could observe this on centered and right justified lines, but have no left justified lines to confirm it also happens there.
Example screenshot before and after
I compiled this replacing set_text_size with set_text_em_height and none of the text displayed
Also I added the below to the json
"dependencies": {
"pebble-fctx": "^1.5.0"
},
and changed the include to
#include <pebble-fctx/fctx.h>
#include <pebble-fctx/ffont.h>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.