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 usage(argv0):
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(" [-S] [-v] [--] fname..", file=sys.stderr)
print(" [-S] [-t float] [-v] [--] fname..", file=sys.stderr)
print("", 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(" -h........: show this screen", 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(" -s fname..: input script filename", 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)
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)
if "-h" in optdict:
@ -69,6 +71,8 @@ class ENNToolApp(object):
if not "-R" in optdict:
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:
optdict["-r"] = [int(r) for r in optdict["-r"].split("x")][0:2]
if "-R" in optdict:
@ -87,9 +91,13 @@ class ENNToolApp(object):
print("\r[{:<50}] {}%".format(
("=" * int(progressDiv * 50)), int(progressDiv * 100)), end=endChar)
# }}}
# {{{ modeScroll(self, argv, optdict, GLVideoWriter, GLpanel, GLpanel, fps=25, scrollRate=0.1): XXX
def modeScroll(self, argv, optdict, GLVideoWriter, GLcanvas, GLpanel, fps=25, scrollRate=0.1):
# {{{ modeScroll(self, argv, optdict, GLVideoWriter, GLpanel, GLpanel, fps=25): XXX
def modeScroll(self, argv, optdict, GLVideoWriter, GLcanvas, GLpanel, fps=25):
MiRCART = []
if "-t" in optdict:
scrollRate = float(optdict["-t"])
else:
scrollRate = 0.1
if "-v" in optdict:
time0 = time.time()
for inFileArg in argv:
@ -150,7 +158,10 @@ class ENNToolApp(object):
videoFps, videoPath = int(optdict["-f"]), optdict["-o"] if "-o" in optdict else None
GLpanel = ENNToolGLPanel(appPanelSkin, size=optdict["-r"], parentFrame=self.appFrame)
GLcanvas = ENNToolGLCanvas(GLpanel, optdict["-r"])
GLcanvas.initOpenGL()
if "-c" in optdict:
GLcanvas.initOpenGL(cameraPos=optdict["-c"])
else:
GLcanvas.initOpenGL()
GLcanvas.initShaders()
GLVideoWriter = ENNToolGLVideoWriter(videoPath, GLpanel.GetClientSize(), videoFps=videoFps)

View File

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

View File

@ -48,9 +48,6 @@ class ENNToolGLTTFTexture(object):
underLine = False
if newChar[3] != " ":
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:
pilImageDraw.line(
xy=(curPos[0], curPos[1] + (pilFontSize[1] - 2),