Re: Cmdgfx - draw graphic primitives (polygons,circles etc) in cmd line window
Posted: 16 Sep 2016 21:44
Alright, I tried some jscript too. Result was fast (~80 fps), even though a new window opens for every frame, when calling shell.Run(!). This obviously ruins the effect...
Is there some way I can run an external from js without opening a new window? Tried Exec, but then no output from WriteConsoleOutput is shown And "start /B" for Run didn't work either.
Script:
Is there some way I can run an external from js without opening a new window? Tried Exec, but then no output from WriteConsoleOutput is shown And "start /B" for Run didn't work either.
Script:
Code: Select all
@if (true == false) @end /*
@echo off
setlocal ENABLEDELAYEDEXPANSION
cmdwiz setfont 6 & cls & mode 140,50
cmdwiz gettime&set STARTT=!errorlevel!
cscript //nologo //e:javascript "%~dpnx0" %*
mode 80,50 & cls
cmdwiz gettime&set /a FPS=(!errorlevel!-%STARTT%)/1000&set /a FPS=400/!FPS!&echo !FPS!
endlocal
exit /b 0 */
nofStars = 200
var starsX=[], starsY=[], starsS=[], starsC=[]
var shell = new ActiveXObject("WScript.Shell");
for (i = 0; i < nofStars; i++) {
starsX.push(Math.floor(Math.random() * 140))
starsY.push(Math.floor(Math.random() * 50))
starsS.push(Math.random() * 1.2 + 0.1)
if (starsS[i] < 0.5) {
starsC.push(8)
} else if (starsS[i] < 1.1) {
starsC.push(7)
} else {
starsC.push(15)
}
}
for (j = 0; j < 400; j++) {
outString=""
for (i = 0; i < nofStars; i++) {
starsX[i] += starsS[i]
if (starsX[i] > 140) {
starsX[i] = 0
}
outString = outString + "& pixel " + starsC[i] + " 0 . " + Math.floor(starsX[i]) + "," + starsY[i]
}
// var wsx = shell.Exec("cmd /c cmdgfx \"" + outString + "\" k"); // can read/print stdout/stderr output this way, but no WriteConsoleOutput is shown :(
//// WScript.Echo(wsx.StdOut.ReadAll())
shell.Run("cmdgfx \"" + outString + "\" k",10); // Always opens a new window :(
}