Skip to content

Commit

Permalink
pending: pygame 1.9.4 + macOS majave has failure. The branch shall wa…
Browse files Browse the repository at this point in the history
…it 1.9.5 release.

pygame/pygame#555
  • Loading branch information
setminami committed Oct 30, 2018
1 parent 5005927 commit 6e997a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,7 @@ fabric.properties
# cProfiler file
output.prof

# pygame
tmp.png

# End of https://www.gitignore.io/api/ruby,macos,python,pycharm
24 changes: 17 additions & 7 deletions script/python3/display/dummy_for_macOS.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
from PIL import Image, ImageDraw
import pygame

pygame.init()
screen = pygame.display.set_mode((1000, 1000))
pygame.display.set_caption('XXX')
TMP_FILE = './tmp.png'

def get_device(actual_args):
print('dummy implementation')
# sd1331
Expand All @@ -12,20 +17,23 @@ def get_device(actual_args):

class canvas(object):
""" dummy canvas for 'with' sentense """
def __init__(self, device):
def __init__(self, device: emulator):
self.device = device
self.image = Image.new('RGB', (96, 64), (0, 0, 0))
self.draw = ImageDraw.Draw(self.image)

def __enter__(self):
self.device.show()
self.image = Image.new('RGB', (self.device.width, self.device.height), (0, 0, 0))
self.draw = ImageDraw.Draw(self.image)
# self.device.show()
return self

def __exit__(self, type, value, traceback):
self.device.cleanup()
self.image.save(TMP_FILE)
img = pygame.image.load(TMP_FILE).convert_alpha()
screen.blit(img, (0, 0))
pygame.display.update()
pass

def ellipse(self, arg, fill='white', outline='white'):
def ellipse(self, arg, fill='black', outline='white'):
"""
e.g.,
ellipse((left + margin, margin, right - margin, min(device.height, 64) - margin), outline="yellow")
Expand All @@ -38,11 +46,13 @@ def line(self, arg, fill):
e.g.,
line((cx, cy, cx + hrs[0], cy + hrs[1]), fill="white")
"""
self.draw.line(arg, fill)
pass

def text(self, arg, msg, fill, outline='', font=None):
def text(self, arg, msg, fill, outline='black', font=None):
"""
e.g.,
text((1.8 * (cx + margin), cy - an_lineheight * 4), 'next:', fill="yellow")
"""
# self.draw.text(arg, msg, fill, outline, font)
pass
1 change: 0 additions & 1 deletion script/python3/sunlight_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from util.device import SmartPlug

if is_debug():
print('## the ENV Cannot use luma library ##')
from display.dummy_for_macOS import get_device, canvas
else:
from luma.core.render import canvas
Expand Down

0 comments on commit 6e997a9

Please sign in to comment.