Post Reply 
How to use graphic.draw_filled_polygon?
11-29-2021, 02:22 PM
Post: #11
RE: How to use graphic.draw_filled_polygon?
(11-29-2021 10:04 AM)Guenter Schink Wrote:  
(11-29-2021 12:42 AM)StephenG1CMZ Wrote:  Just a thought, if it can't convert tuple to int, is it expecting #nnn for colour instead of (255 255 255)?

Yes, an integer is required, be it decimal or hex. A little "lambda" may be of help to create it rather than calculate it by hand. E.g:

Code:
RGB=lambda red, green, blue: (((red*256)+green)*256)+blue
draw_filled_polygon([(0,0),(160,120),(0,240)],RGB(120,120,120))

gets you a grey triangle

G√ľnter

I'm a Python beginner. Can you tell me why use lambda over the following? What's the advantage?

Code:
def RGB(red,green,blue):
  return (((red*256)+green)*256)+blue

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How to use graphic.draw_filled_polygon? - toml_12953 - 11-29-2021 02:22 PM



User(s) browsing this thread: 1 Guest(s)