Updated README. Added example config. Added default font for ease of use.
This commit is contained in:
parent
77514c4d13
commit
58abb91c64
@ -3,9 +3,10 @@ A utility which can be used to create custom images for TRMNL devices via code
|
|||||||
|
|
||||||
# How to write new visual stuff
|
# How to write new visual stuff
|
||||||
1. Inherit from `Widget` and then do your magic inside your own class.
|
1. Inherit from `Widget` and then do your magic inside your own class.
|
||||||
2. Instantiate your widget in `main.cpp` and add it to the vector of widgets.
|
2. Add your widget builder in `main.cpp` inside `init builders`.
|
||||||
3. ???
|
3. Write your config file.
|
||||||
4. Profit
|
4. ???
|
||||||
|
5. Profit
|
||||||
|
|
||||||
# ImageMagick commands
|
# ImageMagick commands
|
||||||
### Convert image without dithering
|
### Convert image without dithering
|
||||||
|
|||||||
14
config_example.json
Normal file
14
config_example.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"width": 800,
|
||||||
|
"height": 600,
|
||||||
|
"output": "trmnl.png",
|
||||||
|
"font": "font.ttf",
|
||||||
|
"widgets":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "widget_name",
|
||||||
|
"parameter1": "example",
|
||||||
|
"parameter2": 10
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
1
main.cpp
1
main.cpp
@ -63,6 +63,7 @@ int main(int argc, char **argv)
|
|||||||
// Change screen size from JSON
|
// Change screen size from JSON
|
||||||
json_extract(cfg, "width", screen_width);
|
json_extract(cfg, "width", screen_width);
|
||||||
json_extract(cfg, "height", screen_height);
|
json_extract(cfg, "height", screen_height);
|
||||||
|
json_extract(cfg, "font", default_font_name);
|
||||||
|
|
||||||
// Create surface
|
// Create surface
|
||||||
main_surface = SDL_CreateRGBSurfaceWithFormat(0, screen_width, screen_height, 32, SDL_PIXELFORMAT_RGBA8888);
|
main_surface = SDL_CreateRGBSurfaceWithFormat(0, screen_width, screen_height, 32, SDL_PIXELFORMAT_RGBA8888);
|
||||||
|
|||||||
@ -53,7 +53,7 @@ void clean_sdl()
|
|||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
TTF_Font* get_font(const string& filename, int size)
|
TTF_Font* get_font(int size, const string& filename)
|
||||||
{
|
{
|
||||||
pair<string, int> key(filename, size);
|
pair<string, int> key(filename, size);
|
||||||
if (0 != font_map.count(key))
|
if (0 != font_map.count(key))
|
||||||
|
|||||||
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
|
|
||||||
|
std::string default_font_name = "font.ttf";
|
||||||
|
|
||||||
// Call this before everything
|
// Call this before everything
|
||||||
// Prints its messages
|
// Prints its messages
|
||||||
bool init_sdl();
|
bool init_sdl();
|
||||||
@ -17,7 +19,7 @@ void clean_sdl();
|
|||||||
|
|
||||||
// A simple way to get a font pointer to use
|
// A simple way to get a font pointer to use
|
||||||
// Can return NULL
|
// Can return NULL
|
||||||
TTF_Font* get_font(const std::string& filename, int size);
|
TTF_Font* get_font(int size, const std::string& filename = default_font_name);
|
||||||
|
|
||||||
// Reads the file and tries to parse a JSON file with comments
|
// Reads the file and tries to parse a JSON file with comments
|
||||||
// cfg - output json struct
|
// cfg - output json struct
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user