Comments (11)
You should have a look at the hotspot and viewport classes: https://luma-core.readthedocs.io/en/latest/api-documentation.html#luma.core.virtual.hotspot. There is a specific example - carousel; that makes use of the hotspot functionality.
The canvas is a convenience wrapper around drawing text and simple line graphics (with whatever methods Pillows ImageDraw supports). You don't have to use it, as you can create am image directly, paste whatever bitmaps onto it, create an ImageDraw layer from that, updating text, etc. and then flush the image to the display with device.display(img)
from luma.lcd.
Thanks, just what I needed.
from luma.lcd.
A really slick phone-ish interface example would be nice, eg.
from luma.lcd.
Snapshots seem to be the way to go, I have several regions set up and working. One outstanding question though - from within the render function for a snapshot, how can I access paste_into() method of the snapshot so that I can paint an image in the snapshot?
from luma.lcd.
Update: got it working:
draw.bitmap((0,0),wifiIcon)
It looks like the draw
parameter of the render function is of type PIL.DrawImage.DrawImage
. This is the legacy API, yes?
from luma.lcd.
Yes, the render canvas is indeed a PIL.DrawImage.DrawImage
. The "legacy API" is provided by https://luma-core.readthedocs.io/en/latest/api-documentation.html#module-luma.core.legacy - the docs should explain why they are named legacy.
Also: just be aware that Pillow's draw.bitmap
does not do exactly what you might think it does - it is a actually mask operation, but if it probably works for your use case, then fair enough.
Would be interested to see a screenshot of your app !
from luma.lcd.
Ah, yes it does work for this use case - the icon is all one color with a transparent background, so the mask does pretty much the same thing. But I would very much like to know how to paint an actual bitmap - all colors preserved - from within the render method of a snapshot. Is this possible? Our app is not all that sexy but I will send a screen shot when it is fleshed out.
from luma.lcd.
In short, you can't: the render canvas
method encapsulates and manages the image and drawing surface entirely. Either something like (untested):
device = ...
bkgnd = Image.new(device.mode, device.size)
bkgnd.paste(wifiIcon, (0, 0))
with canvas(device, bkgnd) as draw:
draw.line((0, 0) + device.size, fill=128)
draw.line((0, device.size[1], device.size[0], 0), fill=128)
or dont use the canvas at all, and initiate an unmanaged draw object:
device = ...
im = Image.new(device.mode, device.size)
im.paste(wifiIcon, (0, 0))
draw = ImageDraw.Draw(im)
draw.line((0, 0) + device.size, fill=128)
draw.line((0, device.size[1], device.size[0], 0), fill=128)
del draw
device.display(im)
[All the canvas
context really does is manage creating the draw object and deleting it afterwards]
from luma.lcd.
Thanks Richard, things are working nicely now. Two questions: 1) Is there a way to specify custom RGB colors when using draw(), text(), etc? All I can find are strings like "yellow", "white", etc. 2) Are there any settings I can try to minimize the horizontal bleed from white text into the darker background colors? (eg. contrast, brightness)
from luma.lcd.
it supports whatever color gamut that Pillow supports, for example, see http://pillow.readthedocs.io/en/5.1.x/reference/ImageColor.html?highlight=color#color-names and https://pillow.readthedocs.io/en/5.1.x/reference/ImageDraw.html#example-draw-partial-opacity-text
You can supply a hex number (in a string, so "#ff0000"
is red), or if you supply a 3-tuple (255, 0, 0)
, then it is a solid color representing the RGB components, else a 4-tuple is RGBA, where the last value is the alpha transparency, eg, (255, 0, 0, 127)
from luma.lcd.
Update: got it working
Closing.
from luma.lcd.
Related Issues (20)
- ili9341 and PWM support? HOT 1
- Thoughts on Bridgetek EVE (Embedded Video Engine) HOT 11
- Support for ili9486 HOT 9
- Trying to get this to work with Spotpear LCD HOT 20
- ST7789 - maximum height and width? HOT 9
- Multiple TFT Screens (ST7735) HOT 2
- Standard 'gpio_LIGHT' pin causes crash of I2S HOT 1
- Support ILI9488 3.5" (320x480) displays HOT 4
- The function device.backlight(False) turns on the lights, instead of device.backlight(True) HOT 7
- DeprecationWarning: getsize is deprecated and will be removed in Pillow 10 (2023-07-01)
- RuntimeError: This module can only be run on a Raspberry Pi! HOT 3
- Comment error: HT1621 may actually 1/3 bias HOT 2
- ILI9341 issue?
- st7735 white screen HOT 1
- Question: HD44780 Cursor Show/Hide and Line/Blink
- This is simply a question / request: Have you ever consider porting this great project to micropython? HOT 2
- How to create custom characters, use function _make_custom HOT 2
- Is the ILI9341V display supported? HOT 4
- Colors are inverted on certain ili9486 displays.
- ILI9486 blank screen HOT 3
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 luma.lcd.