Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add text and rounded rectangle via methods and dir change #6

Open
wants to merge 25 commits into
base: master
from

Conversation

@TG-Techie
Copy link

TG-Techie commented Dec 22, 2018

added four things:

  • round_rect, a normal rect with rounded corners,
  • fill_round_rect, filled version of above
  • text method (with an overwrite in init)
  • TGFONT01.py with a dict of data that defines the shape of the letters and characters

and also some init acceleratable things

TG-Techie added 6 commits Dec 22, 2018
… replace rext with this?
… is an option its on teh border of petdious.

Signed-off-by: TG-Techie <TGTechie01@gmail.com>
Signed-off-by: TG-Techie <TGTechie01@gmail.com>
@TG-Techie TG-Techie changed the title Added round_rect as a seperate object Added round_rect and text method as a seperate object Dec 23, 2018
@TG-Techie TG-Techie changed the title Added round_rect and text method as a seperate object Added round_rect and text method as a seperate objects Dec 23, 2018
@sommersoft

This comment has been minimized.

Copy link

sommersoft commented Dec 23, 2018

@TG-Techie took me a few to understand the structure and proposed usage of this. Its a work in progress, so doesn't need to be fully polished yet, and may void my comments anyway. That said, I have a few open-ended review comments:

  • Standard Font(s):
    • If a standard font, or fonts, are going to be included, then the files need to be setup as a package. i.e.: create a folder ./adafruit_gfx/, and move adafruit_gfx.py and any font files to that folder.
    • If TGFONT01.py is going to be the standard font, I would change the name to something like gfx_standard_font. Nothing wrong with attributing the work to you, but that is what the license info in the file is for. (Please do not misunderstand this comment; I/we appreciate your contribution!!!)
    • If font objects can be passed into __init__, do all assignment/import there. This will help with memory usage, since currently the std_font will get imported even if you pass in a separate font object. So, instead of try: import <module> as std_font at the top, move it into __init__ like so (shortened for brevity):
def __init__(font=None):
    if not font:
        # use the standard font, which is part of the package.
        # since its part of the package, we don't need a try
        import <module> as std_font
    else:
        std_font = font
    # handle any type/instance checking
    self._font = std_font

As this took a little longer than I expected, I'll have to finish up my review/comments later. Off for family vacationy stuff...

.travis.yml Show resolved Hide resolved
Copy link

sommersoft left a comment

Here are a couple more suggestions. I'm still working through my understanding of _place_char and _very_slow_text; without usage examples so far, just need to visualize it. 😄

Also, docs/api.rst needs to be updated to the new location (adafruit_gfx.adafruit_gfx iirc) for Sphinx to build.

adafruit_gfx/gfx.py Show resolved Hide resolved
adafruit_gfx/gfx.py Outdated Show resolved Hide resolved
@TG-Techie

This comment has been minimized.

Copy link
Author

TG-Techie commented Dec 26, 2018

screen shot 2018-12-26 at 7 23 21 am

I have attached a photo of the raw hand typed data bits to create the letters. the 8th bit is always one and should be ignored since the height is 7(for this specific font). That does not apply to the first two bytes with specifying x and y dimensions. I feel like I should note that this is the 3rdish time I've implemented text support and I find my method (pun not intended) has become more condensed each time and has traded readability for brevity. thanks for the help, I'll start on the improvements. :-). @sommersoft hope your vacay time with family went well.
@TG-Techie

This comment has been minimized.

Copy link
Author

TG-Techie commented Dec 26, 2018

and some example code:

out = gfx.GFX(240,320,disp.pixel, disp.hline, disp.vline, disp.rect)
white = color(255,255,255)
blue = color(0,0,255)

out.fill_rect(0,0,100,50,io.green)
out.fill_round_rect(0,0,100,50,25,io.red)
out.round_rect(0,0,100,50,25,io.blue)
#out.fill_round_rect(0,0,100,50,20,io.blue)
#io.round_rect(0,0,100,50,20,io.red)
out.fill_circle(25,25,25,io.white)
out.hline(0,25,50,io.red)

#out._place_char(0,0,'A',1,white)
out.text(0,0,"""HELLO
WORLD __DEGREESIGN__
HELLO
WOvLD
HELLO
WORLD
""", 2,blue)
out.text(0,0,"""HELLO
WORLD __DEGREESIGN__
HELLO
WOvLD
HELLO
WORLD
""", 1,white)
time.sleep(10)
out.fill_round_rect(0,0,239,315,15,color(255,255,128))
out.round_rect(0,0,239,315,15,color(255,0,255))
#for i in range(7):
    #out.round_rect(50+i,200+i,50-i*2,70-i*2,20-i,color(255,0,255))
import time, random as rand

while 1:
    time.sleep(.1)
    todo = (out.fill_round_rect, out.round_rect)[rand.randint(0,1)]
    x = rand.randint(0,100)
    y = rand.randint(0,150)
    width = min(rand.randint(20,200),240-x-1)
    height = min(rand.randint(20,300),320-y-1)
    r = rand.randint(10,70)
    todo(x,y,width,height,r,color(128+rand.randint(0,127),128+rand.randint(0,127),128+rand.randint(0,127)))

#where disp is a display one has setup and color is rgb 0-255 , in this case.

TG-Techie added 6 commits Dec 26, 2018
… is a dict. small linty stuff too
…he background color to clear
@TG-Techie TG-Techie changed the title Added round_rect and text method as a seperate objects add text and rounded rectangle via methods and dir change Dec 27, 2018
TG-Techie added 5 commits Dec 27, 2018
TG-Techie added 3 commits Dec 27, 2018
arg
@TG-Techie

This comment has been minimized.

Copy link
Author

TG-Techie commented Dec 27, 2018

WOOO HOOO

@kattni kattni requested review from ladyada and adafruit/circuitpythonlibrarians Dec 27, 2018
@dherrada

This comment has been minimized.

Copy link
Contributor

dherrada commented May 20, 2019

@sommersoft were these changes the ones you wanted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.