diff --git a/.directory b/.directory deleted file mode 100644 index c623a497ed78a4c2ef7f79879f36c6ba56cba279..0000000000000000000000000000000000000000 --- a/.directory +++ /dev/null @@ -1,3 +0,0 @@ -[Dolphin] -Timestamp=2018,4,7,1,43,30 -Version=4 diff --git a/README.md b/README.md index f32ac88fcc9f17bc2885156baa994a24a99853dc..46ff6e7b01c0212e2a6a1a526607443c7fb6597b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,15 @@ Der Android Client (Java) ist hier zu finden: https://gitlab.spline.de/jrt/Color Colorcircle sends RGB-Colors to manage the Spline-Logo -To run you should install python3 and modules: sys, pillow, re, socket and pygame (for example via pip) +The compiled binary is in release/bin -**https://www.pygame.org** +*cd release* + +*cd bin* + +*./colorcircle* + +If you want to run python file instead, you should install python3 and modules: sys, pillow, socket and tkinter (for example via pip) *cd Colorcircle* diff --git a/code/.directory b/code/.directory new file mode 100644 index 0000000000000000000000000000000000000000..b692cf994f877b19acbda92294ac13751a62f0bf --- /dev/null +++ b/code/.directory @@ -0,0 +1,3 @@ +[Dolphin] +Timestamp=2018,4,8,7,0,41 +Version=4 diff --git a/code/main.py b/code/main.py index 4d04bf9aa7708bc1cd4d42b607ce096f73bb9517..70b536cd9c146204fda4062794023b67c0b66547 100755 --- a/code/main.py +++ b/code/main.py @@ -1,107 +1,78 @@ -#!/usr/bin/python3 -import sys, pygame, socket, re +#!/usr/bin/env python +import sys, socket +import tkinter as tk from PIL import Image -pygame.init() -pygame.display.set_caption("Colorcircle") -icon = pygame.image.load("../images/icon.png") -pygame.display.set_icon(icon) -pygame.font.init() -myfont = pygame.font.SysFont('Times New Roman', 30) -size = width, height = 800, 600 -speed = [0, 0] -black = 0, 0, 0 -moveup = True -movedown = True -moveright = True -moveleft = True -screen = pygame.display.set_mode(size) -colorcircle = pygame.image.load("../images/colorcircle.png") -circlerect = colorcircle.get_rect() -im = Image.open("../images/colorcircle.png") -pix = im.load() +screen = tk.Tk() + host = "nom.spline.de" port = 8443 -connOpen=False -screen.fill(black) -screen.blit(colorcircle, circlerect) -pygame.draw.rect(screen, (255, 255, 255), (601, 1, 198, 49)) -textsurface = myfont.render('Power on', False, (0, 0, 0)) -screen.blit(textsurface,(610, 7)) -pygame.draw.rect(screen, (255, 255, 255), (601, 51, 198, 49)) -textsurface = myfont.render('Power off', False, (0, 0, 0)) -screen.blit(textsurface,(610, 57)) -textsurface = myfont.render('Animations:', False, (255, 255, 255)) -screen.blit(textsurface,(610, 106)) -pygame.draw.rect(screen, (255, 255, 255), (601, 150, 198, 49)) -textsurface = myfont.render('Rainbow', False, (0, 0, 0)) -screen.blit(textsurface,(610, 156)) -pygame.draw.rect(screen, (255, 255, 255), (601, 200, 198, 49)) -textsurface = myfont.render('Rainbow cycle', False, (0, 0, 0)) -screen.blit(textsurface,(610, 206)) -pygame.draw.rect(screen, (255, 255, 255), (601, 250, 198, 49)) -textsurface = myfont.render('Wipe red', False, (0, 0, 0)) -screen.blit(textsurface,(610, 256)) -pygame.draw.rect(screen, (255, 255, 255), (601, 300, 198, 49)) -textsurface = myfont.render('Wipe green', False, (0, 0, 0)) -screen.blit(textsurface,(610, 306)) -pygame.draw.rect(screen, (255, 255, 255), (601, 350, 198, 49)) -textsurface = myfont.render('Wipe blue', False, (0, 0, 0)) -screen.blit(textsurface,(610, 356)) -pygame.draw.rect(screen, (255, 255, 255), (601, 400, 198, 49)) -textsurface = myfont.render('TRB cycle', False, (0, 0, 0)) -screen.blit(textsurface,(610, 406)) -pygame.draw.rect(screen, (255, 255, 255), (601, 450, 198, 49)) -textsurface = myfont.render('T. Chase red', False, (0, 0, 0)) -screen.blit(textsurface,(610, 456)) -pygame.draw.rect(screen, (255, 255, 255), (601, 500, 198, 49)) -textsurface = myfont.render('T. Chase green', False, (0, 0, 0)) -screen.blit(textsurface,(610, 506)) -pygame.draw.rect(screen, (255, 255, 255), (601, 550, 198, 49)) -textsurface = myfont.render('T. Chase blue', False, (0, 0, 0)) -screen.blit(textsurface,(610, 556)) -pygame.display.flip() +im = Image.open("../images/colorcircle.png") +rgbIm = im.convert("RGB") +cc = tk.PhotoImage(file="../images/colorcircle.png") +screen.title("Colorcircle") +img = tk.Image("photo", file="../images/icon.png") +screen.call('wm','iconphoto',screen._w,img) +def poweron(): + send("155 0 0\n") + +def poweroff(): + send("0 0 0\n") + +def rb(): + send("rb") + +def rbc(): + send("rbc") + +def cwr(): + send("cwr") + +def cwg(): + send("cwg") + +def cwb(): + send("cwb") + +def trc(): + send("trc") + +def tcr(): + send("tcr") + +def tcg(): + send("tcg") + +def tcb(): + send("tcb") + + +def leftclick(event): + x = event.x + y = event.y + r,g,b = rgbIm.getpixel((x, y)) + data = str(r) + " " + str(g) + " " + str(b) + "\n" + send(data) + def send(data): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) s.send(data.encode()) s.close() - -while True: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - sys.exit() - - elif event.type == pygame.MOUSEBUTTONDOWN: - x,y = pygame.mouse.get_pos() - if x < 600: - data = re.sub(r'[(|)|,]', r'', str(pix[x,y]))+"\n" - elif x > 600 and y <= 50: - data = "255 0 0\n" - elif x > 600 and y > 50 and y <= 100: - data = "0 0 0\n" - elif x > 600 and y >= 150 and y < 200: - data = "rb" - elif x > 600 and y >= 200 and y < 250: - data = "rbc" - elif x > 600 and y >= 250 and y < 300: - data = "cwr" - elif x > 600 and y >= 300 and y < 350: - data = "cwg" - elif x > 600 and y >= 350 and y < 400: - data = "cwb" - elif x > 600 and y >= 400 and y < 450: - data = "trc" - elif x > 600 and y >= 450 and y < 500: - data = "tcr" - elif x > 600 and y >= 500 and y < 550: - data = "tcg" - elif x > 600 and y >= 550 and y < 600: - data = "tcb" - else: - data = "255 255 255\n" - send (data) - - key=pygame.key.get_pressed() - if key[pygame.K_ESCAPE]: - sys.exit() + +colorcircle = tk.Label(screen, image=cc, width=600, height=600) +colorcircle.bind("<Button-1>", leftclick) +colorcircle.pack(side="left") +bpoweron = tk.Button(screen, text="Power on", width=15, height=2, command = poweron).pack() +bpoweroff = tk.Button(screen, text="Power off", width=15, height=2, command = poweroff).pack() +brb = tk.Button(screen, text="Rainbow", width=15, height=2, command = rb).pack() +brbc = tk.Button(screen, text="Rainbow cycle", width=15, height=2, command = rbc).pack() +bcwr = tk.Button(screen, text="Wipe red", width=15, height=2, command = cwr).pack() +bcwg = tk.Button(screen, text="Wipe green", width=15, height=2, command = cwg).pack() +bcwb = tk.Button(screen, text="Wipe blue", width=15, height=2, command = cwb).pack() +btrc = tk.Button(screen, text="TRB cycle", width=15, height=2, command = trc).pack() +btcr = tk.Button(screen, text="Chase red", width=15, height=2, command = tcr).pack() +btcg = tk.Button(screen, text="Chase green", width=15, height=2, command = tcg).pack() +btcb = tk.Button(screen, text="Chase blue", width=15, height=2, command = tcb).pack() + +screen.mainloop() diff --git a/images/.directory b/images/.directory new file mode 100644 index 0000000000000000000000000000000000000000..42025ca97356095a11b6784b10df417583517865 --- /dev/null +++ b/images/.directory @@ -0,0 +1,3 @@ +[Dolphin] +Timestamp=2018,4,19,18,37,46 +Version=4 diff --git a/release/bin/colorcircle b/release/bin/colorcircle new file mode 100755 index 0000000000000000000000000000000000000000..ce7fc43065065f854a87219505e1324725b6149d Binary files /dev/null and b/release/bin/colorcircle differ diff --git a/release/images/.directory b/release/images/.directory new file mode 100644 index 0000000000000000000000000000000000000000..42025ca97356095a11b6784b10df417583517865 --- /dev/null +++ b/release/images/.directory @@ -0,0 +1,3 @@ +[Dolphin] +Timestamp=2018,4,19,18,37,46 +Version=4 diff --git a/release/images/colorcircle.png b/release/images/colorcircle.png new file mode 100644 index 0000000000000000000000000000000000000000..b3f5f15236c2a419744978c09126a0fafbc69adb Binary files /dev/null and b/release/images/colorcircle.png differ diff --git a/release/images/icon.png b/release/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..979072e19d0609da0788122c12691a408149a23f Binary files /dev/null and b/release/images/icon.png differ