ENNTool/ENNTool{,GL{CanvasPanel,TTFTexture}}.py: adds [-c x,y,z] & [-t float].

This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-07-25 14:26:47 +02:00
parent 455a3fdcba
commit 54522ac329
3 changed files with 20 additions and 12 deletions

View File

@ -39,11 +39,12 @@ class ENNToolApp(object):
def parseArgv(self, argv): def parseArgv(self, argv):
def usage(argv0): def usage(argv0):
print("usage: {}".format(os.path.basename(argv0)), file=sys.stderr) print("usage: {}".format(os.path.basename(argv0)), file=sys.stderr)
print(" [-A] [-f fps] [-h] [-o fname]".format(os.path.basename(argv0)), file=sys.stderr) print(" [-a] [-c x,y,z] [-f fps] [-h] [-o fname]".format(os.path.basename(argv0)), file=sys.stderr)
print(" [-p] [-r WxH] [-R WxH] [-s fname]", file=sys.stderr) print(" [-p] [-r WxH] [-R WxH] [-s fname]", file=sys.stderr)
print(" [-S] [-v] [--] fname..", file=sys.stderr) print(" [-S] [-t float] [-v] [--] fname..", file=sys.stderr)
print("", file=sys.stderr) print("", file=sys.stderr)
print(" -a........: select animation mode (UNIMPLEMENTED)", file=sys.stderr) print(" -a........: select animation mode (UNIMPLEMENTED)", file=sys.stderr)
print(" -c x,y,z..: specify camera position", file=sys.stderr)
print(" -f fps....: set video FPS; defaults to 25", file=sys.stderr) print(" -f fps....: set video FPS; defaults to 25", file=sys.stderr)
print(" -h........: show this screen", file=sys.stderr) print(" -h........: show this screen", file=sys.stderr)
print(" -o fname..: output video filename; extension determines video type", file=sys.stderr) print(" -o fname..: output video filename; extension determines video type", file=sys.stderr)
@ -52,9 +53,10 @@ class ENNToolApp(object):
print(" -R WxH....: set MiRCART cube resolution; defaults to 0.1x0.2", file=sys.stderr) print(" -R WxH....: set MiRCART cube resolution; defaults to 0.1x0.2", file=sys.stderr)
print(" -s fname..: input script filename", file=sys.stderr) print(" -s fname..: input script filename", file=sys.stderr)
print(" -S........: select scrolling mode", file=sys.stderr) print(" -S........: select scrolling mode", file=sys.stderr)
print(" -t float..: scrolling rate in Y coordinates per frame", file=sys.stderr)
print(" -v........: be verbose", file=sys.stderr) print(" -v........: be verbose", file=sys.stderr)
try: try:
optlist, argv = getopt(argv[1:], "Af:ho:pr:R:s:Sv") optlist, argv = getopt(argv[1:], "Ac:f:ho:pr:R:s:St:v")
optdict = dict(optlist) optdict = dict(optlist)
if "-h" in optdict: if "-h" in optdict:
@ -69,6 +71,8 @@ class ENNToolApp(object):
if not "-R" in optdict: if not "-R" in optdict:
optdict["-R"] = "0.1x0.2" optdict["-R"] = "0.1x0.2"
if "-c" in optdict:
optdict["-c"] = [float(r) for r in optdict["-c"].split(",")][0:3]
if "-r" in optdict: if "-r" in optdict:
optdict["-r"] = [int(r) for r in optdict["-r"].split("x")][0:2] optdict["-r"] = [int(r) for r in optdict["-r"].split("x")][0:2]
if "-R" in optdict: if "-R" in optdict:
@ -87,9 +91,13 @@ class ENNToolApp(object):
print("\r[{:<50}] {}%".format( print("\r[{:<50}] {}%".format(
("=" * int(progressDiv * 50)), int(progressDiv * 100)), end=endChar) ("=" * int(progressDiv * 50)), int(progressDiv * 100)), end=endChar)
# }}} # }}}
# {{{ modeScroll(self, argv, optdict, GLVideoWriter, GLpanel, GLpanel, fps=25, scrollRate=0.1): XXX # {{{ modeScroll(self, argv, optdict, GLVideoWriter, GLpanel, GLpanel, fps=25): XXX
def modeScroll(self, argv, optdict, GLVideoWriter, GLcanvas, GLpanel, fps=25, scrollRate=0.1): def modeScroll(self, argv, optdict, GLVideoWriter, GLcanvas, GLpanel, fps=25):
MiRCART = [] MiRCART = []
if "-t" in optdict:
scrollRate = float(optdict["-t"])
else:
scrollRate = 0.1
if "-v" in optdict: if "-v" in optdict:
time0 = time.time() time0 = time.time()
for inFileArg in argv: for inFileArg in argv:
@ -150,6 +158,9 @@ class ENNToolApp(object):
videoFps, videoPath = int(optdict["-f"]), optdict["-o"] if "-o" in optdict else None videoFps, videoPath = int(optdict["-f"]), optdict["-o"] if "-o" in optdict else None
GLpanel = ENNToolGLPanel(appPanelSkin, size=optdict["-r"], parentFrame=self.appFrame) GLpanel = ENNToolGLPanel(appPanelSkin, size=optdict["-r"], parentFrame=self.appFrame)
GLcanvas = ENNToolGLCanvas(GLpanel, optdict["-r"]) GLcanvas = ENNToolGLCanvas(GLpanel, optdict["-r"])
if "-c" in optdict:
GLcanvas.initOpenGL(cameraPos=optdict["-c"])
else:
GLcanvas.initOpenGL() GLcanvas.initOpenGL()
GLcanvas.initShaders() GLcanvas.initShaders()
GLVideoWriter = ENNToolGLVideoWriter(videoPath, GLpanel.GetClientSize(), videoFps=videoFps) GLVideoWriter = ENNToolGLVideoWriter(videoPath, GLpanel.GetClientSize(), videoFps=videoFps)

View File

@ -20,8 +20,8 @@ from OpenGL.GL import shaders
import ctypes, wx, wx.glcanvas import ctypes, wx, wx.glcanvas
class ENNToolGLCanvas(wx.glcanvas.GLCanvas): class ENNToolGLCanvas(wx.glcanvas.GLCanvas):
# {{{ initOpenGL(self): XXX # {{{ initOpenGL(self, cameraPos=(-5.0, 3.0, -5)): XXX
def initOpenGL(self): def initOpenGL(self, cameraPos=(-5.0, 3.0, -5)):
self.glContext = wx.glcanvas.GLContext(self) self.glContext = wx.glcanvas.GLContext(self)
self.SetCurrent(self.glContext) self.SetCurrent(self.glContext)
@ -31,7 +31,7 @@ class ENNToolGLCanvas(wx.glcanvas.GLCanvas):
glLoadIdentity(); glFrustum(-1, 1, -1, 1, 1, 100); glLoadIdentity(); glFrustum(-1, 1, -1, 1, 1, 100);
glMatrixMode(GL_MODELVIEW) glMatrixMode(GL_MODELVIEW)
glEnable(GL_DEPTH_TEST) glEnable(GL_DEPTH_TEST)
glTranslatef(-5.0, 3.0, -5) glTranslatef(*cameraPos)
# }}} # }}}
# {{{ initShaders(self): XXX # {{{ initShaders(self): XXX
def initShaders(self): def initShaders(self):

View File

@ -48,9 +48,6 @@ class ENNToolGLTTFTexture(object):
underLine = False underLine = False
if newChar[3] != " ": if newChar[3] != " ":
pilImageDraw.text(curPos, newChar[3], (255, 255, 255, 255), pilFont) pilImageDraw.text(curPos, newChar[3], (255, 255, 255, 255), pilFont)
elif newChar[0] == newChar[1]:
pilImageDraw.rectangle((*curPos, curPos[0] + pilFontSize[0], curPos[1] + pilFontSize[1] - 1),
fill=(255, 255, 255, 255))
if underLine and False: if underLine and False:
pilImageDraw.line( pilImageDraw.line(
xy=(curPos[0], curPos[1] + (pilFontSize[1] - 2), xy=(curPos[0], curPos[1] + (pilFontSize[1] - 2),