Skip to content

EV3-G API Display - #410

Merged
dwalton76 merged 7 commits into
ev3dev:developfrom
dwalton76:ev3g-api-display
Oct 13, 2017
Merged

dwalton76 merged 7 commits into
ev3dev:developfrom
dwalton76:ev3g-api-display

Conversation

@dwalton76

Copy link
Copy Markdown
Collaborator

For issue #356

Comment thread ev3dev/display.py

screen.image.paste(picture, (0, 0))
"""
return self._img

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do what we can to keep this accessor in some form, as it's what all existing display code is based on.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to remember why I removed this and can't come up with a good reason....will put this back and rename the other def image to def image_filename

@dwalton76

Copy link
Copy Markdown
Collaborator Author

I just noticed the EV3-G display block for text allows you to specify font size in terms of

0 – small font
1 – small, bold font
2 – large font

@ddemidov any recommendations on what fonts we should use for those three choices?

Comment thread ev3dev/display.py Outdated
else:
return self._img.paste(filename_im, (x1, y1))

def shapes_line(self, clear_screen=True, x1=0, y1=0, x2=0, y2=0, line_color='black', width=1):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not draw_line, draw_circle, etc.?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just went went the names the @dlech had in the image posted in #356 I'm not sure if those are official names of the EV3-G equivalents or not though. I agree though draw_line, etc sounds better.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where it comes from:

image

I don't think calling them draw_line/draw_circle/etc. will be confusing. It might even work to just call it line/circle...

Comment thread ev3dev/display.py Outdated

return self.draw.line((x1, y1, x2, y2), fill=line_color, width=width)

def shapes_circle(self, clear_screen=True, x=50, y=50, radius=40, fill_color='black', outline_color='black'):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document color options and how to make it transparent

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you make it transparent? We are way beyond my experience level with PIL :)

Regarding supported color names, PIL says they support Common HTML colour names, I could never find a definitive list of the color names they support so didn't attempt to include that in the doc string.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I don't know... I've never used it 😆 My guess is to pass None.

Comment thread ev3dev/display.py
x2 = x + radius
y2 = y + radius

return self.draw.ellipse((x1, y1, x2, y2), fill=fill_color, outline=outline_color)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if you passed, say, red to this function in the EV3 (the EV3 has a monochrome display)? Does it convert the color brightness to a single greyscale channel, or do something else?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

red it converted to black on my EV3. I don't know if there is a cutoff where something close to white translates to white instead of black or not.

Comment thread ev3dev/display.py
else:
return self.draw.text((x, y), text, fill=text_color)

def text_grid(self, text, clear_screen=True, x=0, y=0, text_color='black', font=None):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document what these two text methods do... I'm a bit confused myself

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a page somewhere that shows what all of the different fonts look like on the EV3 screen? I'm looking but can't find it...was going to include that in the doc string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://python-ev3dev.readthedocs.io/en/latest/other.html#ev3dev.fonts.load (e6a1dde)

I couldn't find info on how this was generated... somewhere I think @ddemidov had a Jupyter notebook with some code for it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#225 links to the notebook with the code used to generate the image.

Comment thread ev3dev/display.py
GRID_ROWS = 12
GRID_ROW_PIXELS = 10

def __init__(self, desc='Display'):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious... what is the description for?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just so if you print the object as a string the __str__ has something to work with

Comment thread ev3dev/display.py

return self.draw.line((x1, y1, x2, y2), fill=line_color, width=width)

def circle(self, clear_screen=True, x=50, y=50, radius=40, fill_color='black', outline_color='black'):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These defaults seem a bit random 😆

I swear, this is my last comment 😉 I need to be better about all-in-one reviews.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah those are just so the user sees a full circle on the screen if they are kicking the tires and call circle() without passing any args

@dwalton76
dwalton76 merged commit 8e57eea into ev3dev:develop Oct 13, 2017
@dwalton76
dwalton76 deleted the ev3g-api-display branch October 17, 2017 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants