hzeller / rpi-rgb-led-matrix

Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
GNU General Public License v2.0
3.64k stars 1.16k forks source link

Accessing background color in python bindings #1106

Open ElBertrando opened 4 years ago

ElBertrando commented 4 years ago

I have a pretty good working model now. I am trying to access the background color in the DrawText function (from the runtext.py) python example. I know you added canvas->Fill(bg_color.r, bg_color.g, bg_color.b); for me when I was running by script, but I don't see a way access it via samplebase.py or from DrawText()

hzeller commented 4 years ago

In the Python binding, there is also a Fill(red, green, blue) method on the canvas that you can use.

ElBertrando commented 4 years ago

Using runtext.py as basis, I should be able to access the Fill() method when the offscreen_canvas = self.matrix.CreateFrameCanvas() is created. So I should be able to access the method by offscreen_canvas.Fill(R,G,B) ? However I do not see autofill in my IDE so I must be doing something wrong in this situation...

hzeller commented 4 years ago

Well, apart from the IDE, did you run the code and see if Python complains ?

ElBertrando commented 4 years ago

Well there we go ! I thought it wasn't accessible.
OK one more question for today -- Is text outline color available -O color of outline ??

hzeller commented 4 years ago

Read the C++ code how that outline frame is done: you first need to generate an outline font that is essentially a larger font, one pixel around the original font. Then draw that first in your desired outline color before you draw the regular text.

ElBertrando commented 4 years ago

I am looking at the graphics.pyx code and see that it takes 6 arguments for the python bindings:

def DrawText(core.Canvas c, Font f, int x, int y, Color color, text):
    return cppinc.DrawText(c.__getCanvas(), f.__font, x, y, color.__color, text.encode('utf-8')

However the c++ code takes 8 arguments to modify the DrawText method. Do I need to modify this ?

hzeller commented 4 years ago

you might need to add the kerning parameter to the Python bindings.

Turmburger commented 4 years ago

Bbnnkojjj Nudeln uikn, z zu if ⁣Gesendet mit BlueMail ​

Am 28. Juli 2020, 01:28, um 01:28, Bret W notifications@github.com schrieb:

I am looking at the graphics.pyx code and see that it takes 6 arguments for the python bindings:

def DrawText(core.Canvas c, Font f, int x, int y, Color color, text):
return cppinc.DrawText(c.__getCanvas(), f.__font, x, y, color.__color,
text.encode('utf-8')

However the c++ code takes 8 arguments to modify the DrawText method. Do I need to modify this ?

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/hzeller/rpi-rgb-led-matrix/issues/1106#issuecomment-664689549

ElBertrando commented 4 years ago

I have a fully working project now :) However I am just now revisiting the outline problem as my last task. Just to clarify, I will need to modify the graphics.pyx code to add the kerning parameter -- Just this file ? Also I cannot read the German in Turmburger commented