PiSupply / PaPiRus

Resources for PaPiRus ePaper eInk displays
https://www.pi-supply.com/product/papirus-epaper-eink-screen-hat-for-raspberry-pi/
Other
346 stars 88 forks source link

Text background #80

Closed etatus closed 7 years ago

etatus commented 7 years ago

Is it possible to write in-line white text with black background as it was selected (white text, black background)? It would be a handy feature.

shawaj commented 7 years ago

So you just want a function where you can have say a sentence that is partly white text on black background and partly black text on white background?

On 12 Mar 2017 2:33 am, "etatus" notifications@github.com wrote:

Is it possible to write in-line white text with black background as it was selected (white text, black background)? It would be an handy feature.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/80, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCuouL2RbS6idwGTxlP9l2HLvXmYVwks5rk1lvgaJpZM4MaaVS .

etatus commented 7 years ago

You don't need to change parts of a sentence, just tell the write function if you want the normal text or inverted text. The visual effect would be something like this: menu-selection

shawaj commented 7 years ago

Yes this seems like a good idea. I think what would be most useful is having two functions - one that does the whole text inverted and one that can do just a selection, similar to how bold would work in HTML or markdown.

Are you able to implement that?

etatus commented 7 years ago

From here: http://stackoverflow.com/questions/18869365/a-watermark-inside-a-rectangle-which-filled-the-certain-color

I could get this piece of code:

import Image
import ImageFont
import ImageDraw

img = Image.open("in.jpg")

draw = ImageDraw.Draw(img)
font = ImageFont.truetype(
    "/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-C.ttf", 66)
x, y = (width - 510, height-100)
# x, y = 10, 10
text = "copyright"
w, h = font.getsize(text)
draw.rectangle((x, y, x + w, y + h), fill='black')
draw.text((x, y), text, fill=(209, 239, 8), font=font)
img.save('out.jpg')

I think it would be easy to adapt to papirus, but I'm not familiar with papirus' code structure.

shawaj commented 7 years ago

See #105 for potential fix

francesco-vannini commented 7 years ago

This has been implemented in #105

shawaj commented 7 years ago

@francesco-vannini one thing that the readme doesn't make clear is whether you can do this for an entire screen only, or if you can do it only for certain parts of text?

Guessing it's just around that text a the rest of the screen is just left clear but maybe worth clarifying in readme? What do you think?