-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from GreenWizard2015/dev
Dev
- Loading branch information
Showing
47 changed files
with
2,889 additions
and
1,531 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
patreon: GreenWizard | ||
buy_me_a_coffee: greenwizard89 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ __pycache__ | |
/.project | ||
/Data/ | ||
/.vscode | ||
/debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pygame as G | ||
import numpy as np | ||
|
||
class CAppMode: | ||
def __init__(self, app): | ||
self._app = app | ||
self._paused = True | ||
return | ||
|
||
def on_event(self, event): | ||
if event.type == G.KEYDOWN: | ||
if event.key in [G.K_p, G.K_RETURN]: | ||
self._paused = not self._paused | ||
|
||
if event.key == G.K_SPACE: | ||
self._paused = True | ||
return | ||
|
||
def on_render(self, window): | ||
return | ||
|
||
def on_sample(self, tracked): | ||
if self._paused: return | ||
self._app._dataset.store(tracked, np.array(self._pos)) | ||
return | ||
|
||
def on_prediction(self, pos, data): | ||
return | ||
|
||
@property | ||
def paused(self): return self._paused | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pygame | ||
import pygame.locals as G | ||
import numpy as np | ||
import time | ||
from App.Utils import Colors | ||
|
||
class CBackground: | ||
def __init__(self): | ||
self._backgroundDynamic = False | ||
return | ||
|
||
def on_tick(self, deltaT): | ||
return | ||
|
||
def _brightness(self): | ||
T = time.time() | ||
amplitude = 1.0 / 2.0 | ||
duration = 30.0 | ||
# smooth brightness change over N seconds | ||
sin = np.sin(2.0 * np.pi * T / duration) | ||
res = 1.0 + amplitude * sin | ||
return res | ||
|
||
def on_render(self, window): | ||
bg = Colors.SILVER | ||
if self._backgroundDynamic: | ||
# take color from Colors.asList based on current time, change every 5 seconds | ||
bg = Colors.asList[int(time.time() / 5) % len(Colors.asList)] | ||
# apply brightness | ||
bg = np.multiply(bg, self._brightness()).clip(0, 255).astype(np.uint8) | ||
window.fill(bg) | ||
return | ||
|
||
def on_event(self, event): | ||
if not(event.type == G.KEYDOWN): return | ||
# toggle background dynamic (B) | ||
if G.K_b == event.key: | ||
self._backgroundDynamic = not self._backgroundDynamic | ||
return | ||
pass |
Oops, something went wrong.