summaryrefslogtreecommitdiff
path: root/wasp/draw565.py
AgeCommit message (Collapse)Author
2021-07-22draw565: Improve line wrappingDaniel Thompson
Currently the final word of wrapped text will always appear as a single word on its own line. Fix this by rearranging the break cases to avoid searching for the most recent space when we get to the end of the text. Fixes: #230 Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2021-06-04draw565: Fix bounding box calculationsDaniel Thompson
wasp-os uses an drawing optimization technique to automatically place a single pixel line on the right of glyphs when rendering them. This results in a change to the bounding box for a rendered string (by adding a single pixel on the right of the final character). Fix the bounding box calculations accordingly. Among other things this eliminates graphical artifacts when rendering labels in 2048. Fixes: #203 Fixes: 58b5c0378ec3 ("draw565: Optimize the string drawing") Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2021-03-29draw565: Optimize the string drawingDaniel Thompson
Currently there is a redundant fill operation issued for every character drawn. This was added to draw the background colours correctly but the change did not account for the optimized character rendering in _draw_glyph(). This results in ~15% performance improvement for character rendering Fixes: cc34c5d46de9 ("draw565: Fix wrong background color of strings") Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2021-03-22draw565: Avoid over-long lines when handling spaceDaniel Thompson
Currently, if the line wrapper attempts to break a line on a space and that space character is outside the bounding box, then we generate an over-long line. Fix this by handling line break generation *after* we have checked the length of the current line. Fixes: #193 Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2021-02-05drivers: draw565: Added bounding_box() function that returns the size of a ↵kozova1
string. This function returns a tuple of (width, height) of the string, as it would appear if used in draw.string() Signed-off-by: kozova1 <mug66kk@gmail.com>
2021-02-04draw565: Fix an out-by-one error in _bounding_boxDaniel Thompson
Currently we add an extra blank pixel to the end of the string but this is not required. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2021-01-17drivers: st7789: Pre-allocate a memoryviewDaniel Thompson
Reduce the cost of slicing the linebuffer by pre-allocating a memoryview. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2021-01-17draw565: Optimize string drawingDaniel Thompson
Avoid needless bouncing the chip select when drawing glyphs. This improved performance by around 15% for 24pt fonts. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-29draw565: Add lighten/darken functionsDaniel Thompson
Add functions to generate shades from a single (usually theme provided) basic palette colour. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-29draw565: Allow strings to be right justifiedDaniel Thompson
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-28draw565: Handle empty strings when calculating the bounding boxDaniel Thompson
Currently the empty string cannot be drawn into a fixed width box. Fix this by adding a special case for empty strings. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-28draw565: Fix bug in the straight line optimizationDaniel Thompson
Currently the line drawing code does not draw the final pixel of straight lines. Thus a line from (0, 0) to (10, 10) finishes on a different pixel to (10, 0) to (10, 10). Fix this by removing the spurious subtract one from the end point Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-27draw565: fix width handling for vertical and horizontal linesDaniel Thompson
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-27draw565: Add a polar line drawing function.Daniel Thompson
Polar coordinates are very convenient for implementing anything with radial lines (such as a traditional watch face). Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-27draw565: Add width to the line drawing functionDaniel Thompson
Currently all lines are a single pixel wide. To draw wider lines we must draw two parallel lines with a single pixel offset and this is a *very* inefficient approach, espeically on ST7789 where we spend longer setting the clipping window than we do drawing each pixel. Fix this by constructing a line using a variable sized square rather than a single pixel. This will "overdraw" (some pixels will be drawn more than once) but since square blocks can be efficiently transferred to the display the overdraw is acceptable. Note: It is a difficult decision whether to maintain the convention that color is the last argument or to keep compatibility with existing line drawing tests. This patch opts for the former and fixes up all uses within the existing codebase. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-27draw565: Improve default argument values for line()Daniel Thompson
Currently there are default argument values for the start and end coordinates but the defaults don't really make any sense since there is no reason to prefer the value 0 over any other. Remove them. Similarly color currently defaults to 0xffff which isn't right. It should default to the foreground colour. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-12draw565: Added line drawing functionKozova1
This is the API: drawable.line(x1, y1, x2, y2, color) The function has optimizations for the case of vertical or horizontal lines. Signed-off-by: Kozova1 <mug66kk@gmail.com> [daniel@redfelineninja.org.uk: Minor update to commit message] Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-08-02draw565: Fix wrong background color of stringsSiroj42
Signed-off-by: Joris Warmbier <siroj42@t-online.de>
2020-06-22wasp: Switch to the faster fill routinesDaniel Thompson
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-06-22draw565: Optimize filled rectangle drawingDaniel Thompson
The original approach is *really* bad at drawing vertical lines (it ends up working a pixel at a time and works the chip select for each one. Optimize both the pixel fill and the use of the line buffer. The result is 20% faster for quarter screen fills, 3x for horizontal lines and 6x for vertical lines. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-05-24draw565: rle2bit: Add support for palette overridesDaniel Thompson
This allows some interesting manipulations of 2-bit images.
2020-05-18draw565: Switch to a different palette for RLE 2-bit imagesDaniel Thompson
This is an incompatible change... older 2-bit images will need to be re-encoded to display correctly.
2020-05-17draw565: Fix line optimization codeDaniel Thompson
sx is measured in pixels (2-bytes) and len(display.linebuffer) gives a value in bytes so the divisor isn't right. Whilst we are here let's make sure we use integer division too. Fixes: #18
2020-05-14wasp: draw565: docstrings for headings and __init__Daniel Thompson
2020-05-11wasp: draw565: docstring improvementsDaniel Thompson
2020-04-11wasp: On-device crash reportingDaniel Thompson
If an application crashes let's report it on the device so it can be distinguished from a hang (if nothing else it should mean we get better bug reports).
2020-04-10wasp: draw565: Optimize the bit expansion blitter slightly.Daniel Thompson
2020-04-10wasp: draw565: Automatic RLE format conversionDaniel Thompson
From here we can also bring colour to the launcher!
2020-04-10wasp: draw565: Fix colors when burst filling a line.Daniel Thompson
2020-04-08wasp: draw565: Optimize the 2-bit RLE drawing functionsDaniel Thompson
There's a bunch of different changes here but there are only really three big wins. The biggest win comes from restructuring the 2-bit RLE decode loop to avoid the inner function (~20%) but the switch to 16-bit writes in _fill() and adoption of quick_write (e.g. no CS toggling) are also note worthy (and about 5% each).
2020-04-06wasp: draw565: Add 2-bit RLE decoderDaniel Thompson
2020-04-06wasp: draw565: Allow the drawing context to be resetDaniel Thompson
The main reason to reset the drawing context is so that it can be reset before we call foreground() on an application.
2020-03-22Add licensing information for all wasp-os files.Daniel Thompson
2020-03-09draw565: Optimize the font renderingDaniel Thompson
This is a big one... more than 4x increase in font rendering performance!
2020-03-09wasp: draw565: Refactor to allow apps to focus on the drawable.Daniel Thompson
2020-02-23wasp: draw565: Add some docstringsDaniel Thompson
2020-02-19wasp: Add a simple font rendererDaniel Thompson