Comments (4)
In the meanwhile if you just need bigger fonts check for example the X11 fonts.
from hagl.
Currently there is no convenient way but you could use hagl_scale_blit()
. Below example blits random 6x9 chars as 24x36.
bitmap_t bitmap;
bitmap.buffer = (uint8_t *) malloc(6 * 9 * sizeof(color_t));
for (uint16_t i = 1; i < 20000; i++) {
int16_t x0 = rand() % DISPLAY_WIDTH;
int16_t y0 = rand() % DISPLAY_HEIGHT;
color_t color = rand() % 0xffff;
uint16_t code = rand() % 0xffff;
hagl_get_glyph(code, color, &bitmap, font6x9);
hagl_scale_blit(x0, y0, 24, 36, &bitmap);
}
I have intentionally left scaled fonts out for now because I have not figured out a good API on how to do it. Lets assume we add a scaling factor.
hagl_put_char(code, x0, y0, color, font8x8, scale);
Still quite ok, but what about background color?
hagl_put_char(code, x0, y0, color, background, font8x8, scale);
What is we need be able to put chars rotated 90 degrees?
hagl_put_char(code, x0, y0, color, background, font8x8, scale, rotate);
etc. In the end there will be too many parameters and the code will look ugly. One option would be to add a style struct.
font_style_t style;
style.font = font8x8;
style.scale = 2;
style.color = rand() % 0xffff;
hagl_put_char(code, x0, y0, style);
This way it would be easy to maintain BC even when adding new stylable parameters. Question is should other functions such as hagl_draw_line()
use style struct instead of simple color?
Other possibility would be to use builder style functions.
hagl_set_font(font8x8);
hagl_set_font_scale(2);
hagl_set_font_color(0xffff);
hagl_put_char(code, x0, y0);
Or maybe use actual builders.
font_style_t style;
hagl_set_font(font8x8, &style);
hagl_set_font_scale(2, &style);
hagl_set_font_color(0xffff, &style);
hagl_put_char(code, x0, y0, style);
I think I personally like the first option ie. style structs most.
from hagl.
hmmm, ok, thanks, I see what you mean. Not quite as simple as it first seems if you don't want to get into a mess in the future
from hagl.
Thanks for the suggestion...
Having thought about it, I think I'm really going to need font scaling for what I'm planning, as I'm going to be wanting to use a few different sizes, up to a size where 1 or 2 digits pretty much fills the screen.
A style struct seems a pretty nice way of doing it, so I can go for that.
If I make these changes (and they end up being neat enough, following coding standards, etc), is this something you'd be interested in merging in at some point? If so I'll make an effort to do to properly lol
If not then no worries, I might keep the code outside of hagl so I can keep on master. Having said that, it might be a while until I get around to it anyway :/
The biggest problem I can see is that adding style (or anything) to the existing hagl_put_char, etc., functions is that it'd be a breaking change to the API?
from hagl.
Related Issues (20)
- Esp8266 support? HOT 5
- Which IDE used ? HOT 1
- Why does text come out so small? HOT 1
- Support for getScreen? HOT 1
- Hex to rgb565
- Unable to set HAGL_CHAR_BUFFER_SIZE from main
- Add HAL for Raspberry Pi Pico VGABOARD HOT 4
- hagl_put_char / hagl_put_text always drawn on black background HOT 4
- [Low prio] Offscreen drawing in a bitmap HOT 3
- Big stack allocations HOT 3
- DISPLAY_DEPTH < 8 HOT 2
- Overflow bug in hagl_scale_blit
- Generating new fonts HOT 6
- Found a dot that is not rendered at bottom right of screen. HOT 2
- is it possible to use HAGL with platformio and arduino framework? HOT 2
- null hal / qemu hal HOT 4
- Ability to rotate the display at runtime HOT 1
- Input API? HOT 7
- [Minor] README.md contains 2 "Draw a line" sections
- Include a 8x8 font by default HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hagl.