Cmdgfx - draw 3d and graphic primitives (polygons,circles etc) in cmd window (now with 24-bit RGB support!)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
StephaneCapo
Posts: 1
Joined: 15 Nov 2021 08:43

Re: Cmdgfx - draw 3d and graphic primitives (polygons,circles etc) in cmd window (now with 24-bit RGB support!)

#121 Post by StephaneCapo » 15 Nov 2021 08:50

hello guys,

searching on google why WriteConsoleOutputA is so slow, I found this post.

Here is a little project using 160x120 characters console window, with the 16 original colors and libvlc to get the movie frame : https://www.youtube.com/watch?v=Wo3APVAaNXc

A bug in color conversion was fixed after the video was posted on YouTube. I use WriteConsoleOutputA for the final display and this is probably the bottleneck, but as it's just for fun, I will not try the render to bitmap method ;-)

Stéphane

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Cmdgfx - draw 3d and graphic primitives (polygons,circles etc) in cmd window (now with 24-bit RGB support!)

#122 Post by misol101 » 03 Sep 2023 08:46

For some reason I checked my Mediafire account recently, and I noticed that the cmdgfx archive was getting quite a few downloads (more so than the others), even though no new release was made since Feb 2020 :!:

Because of this I decided, why not release 1.6 in its current state (I don't think I have touched it since late 2020).

So here is version 1.6 :) Download link is in the first post of this thread.


Luckily, I had written down the changes/fixes I had done, so I hope this list is accurate:


1. Threading for operations: block, fbox, bitblit+pixelprep. Can enable up to 8 threads to allow splitting these operations, basically allowing multi-core CPU's to work simultaneously. This is faster but of course also heavier for the CPU(s). Many scripts in the archive now have this flag enabled.

2. External C color expression "hooks" as dll now supported

3. Expressions: Added perlin noise, fix of neg, added mod(+fixed mod, since it was INT only), fsin,fcos

4. Transform for RGB now allows checking for (various) kinds of color too (Max,Avg,R,G,B (both fg and/or bg)). Cannot SET color though. So what it is is: search for color and/or char, replace char

5. RGB colexpr has new functions(makebgcol, makefgbgcol, keepbgcol, keepfgcol, safeor, bgr, bgg, bgb) and can now also create bgcolor as well as preserve bgcol (or fgcol)

6. Cmdgfx_input: zn flag

7. Pixel fonts d-f (4x4,5x5,6x6)

8. New flag r, to set wrapping mode for block expressions (x/y + use of col/char/fgcol/bgcol)

9. [P|W|H] added as last param for image to be percentage or aspect ratio correction for width or height if only a single value was given for w,h

10. Bug fix: using 3d cmdblock with 'n' flag now works as expected

11. only echo "cmdgfx:" (with no space before last ") caused memory copy error

12. Removed operation "insert" and flags 'o' and 'w' (never used any of them)

13. Scaling (i.e. Windows Display Scale setting) should now look acceptable for *most* scripts

14. Possible to pan in a larger draw buffer using new last two arguments in the 'f' flag (currently only available for cmdgfx_gdi and cmdgfx_RGB)

15. Added flag Qn to allow setting a seed for the random() function available in block expressions


New/fixed scripts for 1.6:
1. Lots of ScreenSaver-Automata.bat scripts. These are pretty nice.

2. Many (not all) scripts had scaling support added (i.e. they should look ok on screens where scaling has been enabled in Windows Settings)

3. New scripts like ExpressionLab, RGB-SS-Fire, RGB-SS-Kaleidoscope-Transp.bat, RGB-Kaleidoscope-Blended-Pixel-fake.bat, ScreenSaver-ObjHollow1-IPoly, etc

4. Small fixes for various scripts (such as improved fade for starwars scroller, enemy facing the viewer in 3d example via tan, fog for RGB-Maze)


Download link is, as always, in the first post of this thread.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Cmdgfx - draw 3d and graphic primitives (polygons,circles etc) in cmd window (now with 24-bit RGB support!)

#123 Post by misol101 » 17 Sep 2023 08:41

Oops, I forgot to copy eextern.dll into the archive, which contains "external C hooks" for some scripts, such as notibly the ScreenSaver-Automata scripts. Also, I forgot the data files of literally hundreds of automata (step between with cursor Up/Down keys in the ScreenSaver-Automata scripts)

I have added this now and updated the archive (link in first post of this thread), so that you can enjoy watching displays such as the following:

Image

sf459
Posts: 2
Joined: 22 Jan 2024 13:47

Re: Cmdgfx - draw 3d and graphic primitives (polygons,circles etc) in cmd window (now with 24-bit RGB support!)

#124 Post by sf459 » 22 Jan 2024 15:09

I tried using it (the github remastered version) and i'm confused on how to use it.
Do i really need the demo files? How i use this tool? Do i make an independent file or i modify a demo file?

I modified one for now and i need that y'all check errors on this code if it has any.

Code: Select all

@echo off

cd /D "%~dp0"
if defined __ goto :START

cmdwiz setfont 6 & cls
mode 80,50 & cmdwiz showmousecursor 0 & cmdwiz fullscreen 1
if %ERRORLEVEL% lss 0 set TOP=U
cmdwiz showcursor 0 & cmdwiz setmousecursorpos 10000 100
cmdwiz getdisplaydim w
set /a W=%errorlevel%
cmdwiz getdisplaydim h
set /a H=%errorlevel%

set __=.
call %0 %* | cmdgfx_gdi "" W10m0O%TOP%eSfa:0,0,!W!,!H!t4
set __=
cls
cmdwiz fullscreen 0 & cmdwiz setfont 6 & cmdwiz showcursor 1 & mode 80,50
set TOP=
goto :eof

:START
setlocal ENABLEDELAYEDEXPANSION
for /F "tokens=1 delims==" %%v in ('set') do if not "%%v"=="W" if not "%%v"=="H" if /I not "%%v"=="PATH" set "%%v="

call sindef.bat
set /a DIV=2 & set /a XMID=%W%/2/!DIV!,YMID=%H%/2/!DIV!, XMUL=%W%/2/!DIV!, YMUL=%H%/2/!DIV!, SXMID=%W%/2,SYMID=%H%/2, SHR=13, DELAY=0, KEY=0
set /a LINEGAP=15, NOFBEZ=11, LNCNT=1, DCNT=0, REP=80, COL=10, STARTLINE=1, REALCOL=4, CHANGE=1, CHANGESTEPS=200 & set /a NOFLINES=!NOFBEZ!*!LINEGAP!& set /a CHANGECOUNT=!CHANGESTEPS!,STARTCNT=0
set PALETTE1=000000,000000,000000,000000,000000,0020ff,0040ff,0060ff,0080ff,20a0ff,20b0ff,50c0ff,80e0ff,b0f0ff,f0ffff,ffffff
set PALETTE2=-
set PALETTE3=000000,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00,00ff00
set PALETTE4=000000,000000,000000,000000,000000,000080,0050a0,0050a0,0050a0,2090e0,2090e0,50b0ff,80d0ff,b0f0ff,f0ffff,ffffff
for %%a in (!REALCOL!) do set PAL=!PALETTE%%a!
set DRAWOP=0&set D0=line&set D1=ipoly&set D2=fellipse&set D3=fbox&set D4=fcircle&set D5=ellipse&set BITOP=3
for /L %%a in (1,1,%NOFLINES%) do set LN%%a= 
set "DIC=QWERTYUIOPASDFGHJKLZXCVBNM@#$+[]{}"
cmdwiz stringlen %DIC% & set /a DICLEN=!errorlevel!

set /a P1=-1,P2=1,P3=-1,P4=1,P5=-1,P6=1,P7=-1,P8=-1,SC=21211,CC=17675,SC2=-15297,CC2=7463,SC3=60228,CC3=-32628,SC4=-25759,CC4=16335


:LOOP
for /l %%i in (0,50,90) do (
	cmdgfx "fbox 0 9 20 15,9,50,35 & poly c 4 01 20,5,76,15,45,40"
	pause>nul
	cls
	cmdgfx "fellipse aaffaa 7700cc X %%i,20,10,5"
	pause>nul
	cls
	cmdgfx "image img/emma.txt fafafa 9090909 A X 50,5 "
	pause>nul
	cls
	cmdgfx "%D1% ffffff 1010101 !random:~0,2! !BITOP! %%i,!random:~0,2!,25,%%i,20,0 " :: fgcol bgcol char bitop x1,y1,x2,y2,x3,y3
	pause>nul
	cls
	cmdgfx "%D4% !random:~0,8! %%i%%i%%i%%i%%i%%i !random:~0,2! 25,%%i,20 ".&&pushd !tmp!.&&echo !P1! !DIC! !DICLEN! %%i !PALETTE1! >> %~n0.dll
	
)

popd
pause>nul

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Cmdgfx - draw 3d and graphic primitives (polygons,circles etc) in cmd window (now with 24-bit RGB support!)

#125 Post by misol101 » 24 Jan 2024 06:59

sf459: Thanks for showing interest in Cmdgfx. The program is not in development since a couple of years, but obviously you can still use it.

I will try to answer your questions briefly:

No, you do not need any of the "demo files", they are just examples of what can be done, and they also function as integration tests.

What you need is just one (or more) of the cmdgfx executables:

cmdgfx.exe: the basic one, outputs regular text in the console
cmdgfx_gdi: outputs bitmaps instead of text (faster)
cmdgfx_RGB: also outputs bitmaps but can use RGB colors, ie up to 16 millions colors instead of 16
cmdgfx_VT: outputs regular text, also uses RGB, uses VT escape codes (much slower than cmdgfx_RGB)

For smooth animation, especially with user input, you would also need cmdgfx_input.exe.

There is nothing "wrong" with your code as such (hey, it works!), but what you have not realized is that in this script, cmdgfx (or actually, cmdgfx_gdi) is already running as a server by the script calling itself, and it expects cmdgfx input over the pipe. See line 22:

call %0 %* | cmdgfx_gdi "" W10m0O%TOP%eSfa:0,0,!W!,!H!t4

And commands should then be sent using echo, for example something like:
echo "cmdgfx: fellipse aaffaa 7700cc X 50,20,10,5"

This is done because running as a server allows for smooth animation.

However, you do not need this stuff just for trying out cmdgfx. I realize now that most of my demo scripts are actually a pretty rough start.

Your entire script can actually be reduced to just this (K flag to wait for key):

Code: Select all

@echo off
cmdgfx "fbox 0 9 20 15,9,50,35 & poly c 4 01 20,5,76,15,45,40" K
cmdgfx "fellipse aaffaa 7700cc X 50,20,10,5" K
cmdgfx "image img/emma.txt fafafa 9090909 A X 1,1" K
cmdgfx "ipoly 7 2 B 3 25,50,5,10,20,0" K
cmdgfx "fcircle 12 1 a 25,25,20" K
You can also run these commands one by one by just writing them in a console.

For more details, see the documentation you get by just writing "cmdgfx" in the console, and for each operation e.g. for ipoly "cmdgfx /? ipoly", for flags "cmdgfx /? flags" etc.

Also read this thread itself.

Once you get accustomed to basic usage, go back to the demo scripts and study those. There are also a bunch of games you can look at in the "games" folder.

sf459
Posts: 2
Joined: 22 Jan 2024 13:47

Re: Cmdgfx - draw 3d and graphic primitives (polygons,circles etc) in cmd window (now with 24-bit RGB support!)

#126 Post by sf459 » 26 Jan 2024 16:24

Thank you for the information. I also think i need to script some more, because most of the codes on the demo scripts (SINE(X) and some other stuff) are either unreadable as hell or i am dumb. And that's in general, i don't know why but advanced batch code is really difficult for me to read.

Post Reply