Bézier curve animation symmetric fantasy art

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
neorobin
Posts: 47
Joined: 01 May 2012 12:18

Bézier curve animation symmetric fantasy art

#1 Post by neorobin » 02 Oct 2016 03:57

Bezier curve symmetric fantasy art

tested on 64bit Win7 and 32bit XP.

Please edit the 19th line of code, replace the ★ to a real TAB character (ASCII 0x9).

Image

Image


No symmetric code

Code: Select all

@echo off & setlocal enabledelayedexpansion & color 0A & chcp 437

set "hexWid=64" & set "hexHei=42" & REM 100 x 66

for /f "tokens=2 delims=[]" %%a in ('ver') do for /f "tokens=2 delims=. " %%a in ("%%a") do set /a "FullScreen=-((%%a-6)>>31)"
if "%1"=="" (
    for %%a in ( FontSize:00060004 FontFamily:00000030 WindowSize:00%hexHei%00%hexWid% ScreenColors:0000000a CodePage:000001b5 ScreenBufferSize:00%hexHei%00%hexWid% FullScreen:!FullScreen:-=!
    ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do >nul reg add HKCU\Console\Bezier_CMD /v %%b /t reg_dword /d 0x%%c /f
    start "Bezier_CMD" /max "%ComSpec%" /c %~s0 1 & exit
) else ( >nul reg delete HKCU\Console\Bezier_CMD /f )

set "Path=%SystemRoot%\system32" & for /f "delims==" %%a in ('set') do if /i "%%a" neq "Path" if /i "%%a" neq "hexWid" if /i "%%a" neq "hexHei" set "%%a="

set /a "pixel_w=4, pixel_h=6" & rem FontSize 4X6
set /a "Cols=wid=0x%hexWid%, lines=hei=0x%hexHei%, ctrl_wid=wid * 3 / 3, ctrl_hei=hei * 3 / 3, iMax=wid*hei"
set /a "XC = Cols/2, YC = lines/2"
(for /l %%i in (1 1 !wid!) do set "t= !t!") & (for /l %%i in (1 1 !hei!) do set "scr=!scr!!t!") & set "t="

set "TAB=★" & for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "BS=%%a"
set /a "buffwid = wid, linesWantBackAbove = hei - 1 + 1, cntBS = 2 + (buffwid + 7) / 8 * linesWantBackAbove"
set "BSs=" & for /L %%a in (1 1 !cntBS!) do set "BSs=!BSs!%BS%"
set "aLineBS=" & for /L %%a in (1 1 !wid!) do set "aLineBS=!aLineBS!%BS%"

set "dic=QWERTYUIOPASDFGHJKLZXCVBNM@#$+[]{}" & set "sumLines=30" & rem sumLines ^< lenth of dic, dic: as pen, don't use syntax character

set /a "DotPerLine=15, DotPerLineSQ=DotPerLine*DotPerLine, DotPerLineCube=DotPerLine*DotPerLineSQ"

set /a "pathDensity=50, pathDensitySQ=pathDensity*pathDensity, pathDensityCube=pathDensitySQ*pathDensity"

for /L %%h in (0 1 3) do for %%i in (0 1 3) do ^
set /a "cx%%h_%%i=!random! %% ctrl_wid - (ctrl_wid>>1), cy%%h_%%i=!random! %% ctrl_hei - (ctrl_hei>>1)"


for /L %%j in (0 1 !DotPerLine!) do (
    set /a "tr_%%j=DotPerLine-%%j,tr2_%%j=tr_%%j*tr_%%j,te2_%%j=%%j*%%j,t0_%%j=tr2_%%j*tr_%%j, t1_%%j=3*tr2_%%j*%%j, t2_%%j=3*tr_%%j*te2_%%j, t3_%%j=te2_%%j*%%j"
)

for /L %%# in (0) do (

    for /L %%i in (1 1 !pathDensity!) do (

        REM pens
        set "dic=!dic:~1!!dic:~0,1!" & set "born=!dic:~%sumLines%,1!"

        set /a "tr=pathDensity-%%i,tr2=tr*tr,te2=%%i*%%i,ct0=tr2*tr, ct1=3*tr2*%%i, ct2=3*tr*te2, ct3=te2*%%i"
        for /L %%h in (0 1 3) do (
            set /a "x%%h=(ct0*cx%%h_0+ct1*cx%%h_1+ct2*cx%%h_2+ct3*cx%%h_3)/pathDensityCube, y%%h=(ct0*cy%%h_0+ct1*cy%%h_1+ct2*cy%%h_2+ct3*cy%%h_3)/pathDensityCube"
        )

        REM title %%i/!pathDensity! {!x0!,!y0!},{!x1!,!y1!},{!x2!,!y2!},{!x3!,!y3!}

        for /L %%j in (0 1 !DotPerLine!) do (

            set /a "x=XC + (t0_%%j*x0+t1_%%j*x1+t2_%%j*x2+t3_%%j*x3)*pixel_h/(pixel_w*DotPerLineCube), y=YC + (t0_%%j*y0+t1_%%j*y1+t2_%%j*y2+t3_%%j*y3)/DotPerLineCube, inScr=(x-0^x-wid)&(y-0^y-hei)"

            if !inScr! lss 0 (
                set /a "ind=x+y*wid+1, lenL=ind-1"
                for /f "tokens=1,2" %%a in ("!lenL! !ind!") do (set scr=!scr:~0,%%a!!born!!scr:~%%b!)
            )
        )

        REM clear old line
        for %%c in ("!dic:~0,1!") do set "scr=!scr:%%~c= !"

        <nul set /p "=!aLineBS!" & (2>nul echo;%TAB%!BSs!) & <nul set /p "=%BS%"
        <nul set /p "=%BS%!scr:~0,-1!"
    )

    for /L %%h in (0 1 3) do (
        set /a "cx%%h_0=cx%%h_3, cy%%h_0=cy%%h_3, cx%%h_1 = (cx%%h_3 << 1) - cx%%h_2, cy%%h_1 = (cy%%h_3 << 1) - cy%%h_2"
        for %%i in (2 3) do set /a "cx%%h_%%i=!random! %% ctrl_wid - (ctrl_wid>>1), cy%%h_%%i=!random! %% ctrl_hei - (ctrl_hei>>1)"
    )
)
>nul pause
exit




Symmetric code

Code: Select all

@echo off & setlocal enabledelayedexpansion & color 0A & chcp 437

set "hexWid=65" & set "hexHei=43" & REM 101 x 67

for /f "tokens=2 delims=[]" %%a in ('ver') do for /f "tokens=2 delims=. " %%a in ("%%a") do set /a "FullScreen=-((%%a-6)>>31)"
if "%1"=="" (
    for %%a in ( FontSize:00060004 FontFamily:00000030 WindowSize:00%hexHei%00%hexWid% ScreenColors:0000000a CodePage:000001b5 ScreenBufferSize:00%hexHei%00%hexWid% FullScreen:!FullScreen:-=!
    ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do >nul reg add HKCU\Console\Bezier_CMD /v %%b /t reg_dword /d 0x%%c /f
    start "Bezier_CMD" /max "%ComSpec%" /c %~s0 1 & exit
) else ( >nul reg delete HKCU\Console\Bezier_CMD /f )

set "Path=%SystemRoot%\system32" & for /f "delims==" %%a in ('set') do if /i "%%a" neq "Path" if /i "%%a" neq "hexWid" if /i "%%a" neq "hexHei" set "%%a="

set /a "pixel_w=4, pixel_h=6" & rem FontSize 4X6
set /a "Cols=wid=0x%hexWid%, lines=hei=0x%hexHei%, ctrl_wid=wid * 3 / 3, ctrl_hei=hei * 3 / 3, iMax=wid*hei"
set /a "XC = Cols/2, YC = lines/2"
(for /l %%i in (1 1 !wid!) do set "t= !t!") & (for /l %%i in (1 1 !hei!) do set "scr=!scr!!t!") & set "t="

set "TAB=★" & for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "BS=%%a"
set /a "buffwid = wid, linesWantBackAbove = hei - 1 + 1, cntBS = 2 + (buffwid + 7) / 8 * linesWantBackAbove"
set "BSs=" & for /L %%a in (1 1 !cntBS!) do set "BSs=!BSs!%BS%"
set "aLineBS=" & for /L %%a in (1 1 !wid!) do set "aLineBS=!aLineBS!%BS%"

set "dic=QWERTYUIOPASDFGHJKLZXCVBNM@#$+[]{}" & set "sumLines=30" & rem sumLines ^< lenth of dic, dic: as pen, don't use syntax character

set /a "DotPerLine=15, DotPerLineSQ=DotPerLine*DotPerLine, DotPerLineCube=DotPerLine*DotPerLineSQ"

set /a "pathDensity=50, pathDensitySQ=pathDensity*pathDensity, pathDensityCube=pathDensitySQ*pathDensity"

for /L %%h in (0 1 3) do for %%i in (0 1 3) do ^
set /a "cx%%h_%%i=!random! %% ctrl_wid - (ctrl_wid>>1), cy%%h_%%i=!random! %% ctrl_hei - (ctrl_hei>>1)"


for /L %%j in (0 1 !DotPerLine!) do (
    set /a "tr_%%j=DotPerLine-%%j,tr2_%%j=tr_%%j*tr_%%j,te2_%%j=%%j*%%j,t0_%%j=tr2_%%j*tr_%%j, t1_%%j=3*tr2_%%j*%%j, t2_%%j=3*tr_%%j*te2_%%j, t3_%%j=te2_%%j*%%j"
)

for /L %%# in (0) do (

    for /L %%i in (1 1 !pathDensity!) do (

        REM pens
        set "dic=!dic:~1!!dic:~0,1!" & set "born=!dic:~%sumLines%,1!"

        set /a "tr=pathDensity-%%i,tr2=tr*tr,te2=%%i*%%i,ct0=tr2*tr, ct1=3*tr2*%%i, ct2=3*tr*te2, ct3=te2*%%i"
        for /L %%h in (0 1 3) do (
            set /a "x%%h=(ct0*cx%%h_0+ct1*cx%%h_1+ct2*cx%%h_2+ct3*cx%%h_3)/pathDensityCube, y%%h=(ct0*cy%%h_0+ct1*cy%%h_1+ct2*cy%%h_2+ct3*cy%%h_3)/pathDensityCube"
        )

        REM title %%i/!pathDensity! {!x0!,!y0!},{!x1!,!y1!},{!x2!,!y2!},{!x3!,!y3!}

        for /L %%j in (0 1 !DotPerLine!) do (

            set /a "dx=(t0_%%j*x0+t1_%%j*x1+t2_%%j*x2+t3_%%j*x3)*pixel_h/(pixel_w*DotPerLineCube), dy=(t0_%%j*y0+t1_%%j*y1+t2_%%j*y2+t3_%%j*y3)/DotPerLineCube"

            for %%u in (+ -) do for %%v in (+ -) do (

                set /a "x=XC %%u dx, y=YC %%v dy, inScr=(x-0^x-wid)&(y-0^y-hei)"

                if !inScr! lss 0 (
                    set /a "ind=x+y*wid+1, lenL=ind-1"
                    for /f "tokens=1,2" %%a in ("!lenL! !ind!") do (set scr=!scr:~0,%%a!!born!!scr:~%%b!)
                )
            )
        )

        REM clear old line
        for %%c in ("!dic:~0,1!") do set "scr=!scr:%%~c= !"

        <nul set /p "=!aLineBS!" & (2>nul echo;%TAB%!BSs!) & <nul set /p "=%BS%"
        <nul set /p "=%BS%!scr:~0,-1!"
    )

    for /L %%h in (0 1 3) do (
        set /a "cx%%h_0=cx%%h_3, cy%%h_0=cy%%h_3, cx%%h_1 = (cx%%h_3 << 1) - cx%%h_2, cy%%h_1 = (cy%%h_3 << 1) - cy%%h_2"
        for %%i in (2 3) do set /a "cx%%h_%%i=!random! %% ctrl_wid - (ctrl_wid>>1), cy%%h_%%i=!random! %% ctrl_hei - (ctrl_hei>>1)"
    )
)
>nul pause
exit
Last edited by neorobin on 04 Oct 2016 02:51, edited 2 times in total.

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

Re: Bézier curve animation

#2 Post by misol101 » 02 Oct 2016 05:14

Neat!

neorobin
Posts: 47
Joined: 01 May 2012 12:18

Re: Bézier curve animation symmetric fantasy art

#3 Post by neorobin » 04 Oct 2016 02:59

@misol101

Thanks!

Now added a symmetric effect version.

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Bézier curve animation symmetric fantasy art

#4 Post by Aacini » 04 Oct 2016 11:51

I like this animation very much! :D

I want to do several modifications to it, so I should understand its basic operation first. I started modifying the code in several small points. I rearranged and modified several small segments in order to made they clearer or more efficient. I renamed some variables in a way clearer for me; for example, you may change the value of the configuration parameters NumOfLines, DotsPerLine and pathDensity and see how the change affect the animation. I removed unused variables and duplicated ones; for example, in this line:

Code: Select all

set /a "wid=0x%hexWid%, hei=0x%hexHei%, ctrl_wid=wid * 3 / 3, ctrl_hei=hei * 3 / 3"

... the value of ctrl_wid and ctrl_hei are the same of wid and hei, so I removed these two "ctrl_" variables and used the standard ones.

For my planned modifications I need to address the screen as a two-dim matrix instead of a long string, so I also removed all the code that use %BS% characters to move the cursor and replaced it by the usual CLS method instead. This is the code so far just before starting to insert my additional modifications.

Code: Select all

@echo off
setlocal EnableDelayedExpansion
color 0A
chcp 437

rem Original code by neorobin
rem http://www.dostips.com/forum/viewtopic.php?f=3&t=7447
rem This version modified by Antonio Perez Ayala, aka Aacini

set "hexWid=64" & set "hexHei=42" & REM Screen size in hexa: 100 x 66

if "%1" equ "" (
    for /f "tokens=2 delims=[]" %%a in ('ver') do for /f "tokens=2 delims=. " %%a in ("%%a") do set /a "FullScreen=-((%%a-6)>>31)"
    for %%a in ( FontSize:00060004 FontFamily:00000030 WindowSize:00%hexHei%00%hexWid% ScreenColors:0000000a
                 CodePage:000001b5 ScreenBufferSize:00%hexHei%00%hexWid% FullScreen:!FullScreen:-=! ) do (
        for /f "tokens=1,2 delims=:" %%b in ("%%a") do >nul reg add HKCU\Console\Bezier_CMD /v %%b /t reg_dword /d 0x%%c /f
    )
    start "Bezier_CMD" /max "%ComSpec%" /c %~s0 1
    exit
) else (
    >nul reg delete HKCU\Console\Bezier_CMD /f
)

(
   for /f "delims==" %%a in ('set') do set "%%a="
   set "Path=%SystemRoot%\system32"
   set /A hexWid=%hexWid%, hexHei=%hexHei%
)

rem Configuration parameters
set /A "NumOfLines=15, DotsPerLine=30, pathDensity=50"

set /a "pixel_w=4, pixel_h=6" & rem FontSize 4X6
set /a "wid=0x%hexWid%, hei=0x%hexHei%, XC = wid/2, YC = hei/2"
(for /l %%i in (1 1 !wid!) do set "t= !t!") & (for /l %%i in (1 1 !hei!) do set "scr=!scr!!t!") & set "t="
for /F %%a in ('echo prompt $H ^| cmd') do Set "BS=%%a"

set "dic=QWERTYUIOPASDFGHJKLZXCVBNM@#$+[]{}"
set /a "NumOfLinesSQ=NumOfLines*NumOfLines, NumOfLinesCube=NumOfLines*NumOfLinesSQ"
set /a "pathDensitySQ=pathDensity*pathDensity, pathDensityCube=pathDensitySQ*pathDensity"

for /L %%h in (0 1 3) do for %%i in (0 1 3) do (
   set /a "cx%%h_%%i=!random! %% wid - (wid>>1), cy%%h_%%i=!random! %% hei - (hei>>1)"
)

for /L %%j in (1 1 %NumOfLines%) do (
   set /a "tr_%%j=NumOfLines-%%j, tr2_%%j=tr_%%j*tr_%%j, te2_%%j=%%j*%%j, t0_%%j=tr2_%%j*tr_%%j, t1_%%j=3*tr2_%%j*%%j, t2_%%j=3*tr_%%j*te2_%%j, t3_%%j=te2_%%j*%%j"
)

for /L %%# in () do (

    for /L %%i in (1 1 %pathDensity%) do (

        REM pens
        set "dic=!dic:~1!!dic:~0,1!"

        set /a "tr=pathDensity-%%i,tr2=tr*tr,te2=%%i*%%i,ct0=tr2*tr, ct1=3*tr2*%%i, ct2=3*tr*te2, ct3=te2*%%i"
        for /L %%h in (0 1 3) do (
            set /a "x%%h=(ct0*cx%%h_0+ct1*cx%%h_1+ct2*cx%%h_2+ct3*cx%%h_3)/pathDensityCube"
            set /a "y%%h=(ct0*cy%%h_0+ct1*cy%%h_1+ct2*cy%%h_2+ct3*cy%%h_3)/pathDensityCube"
        )

        REM title %%i/!pathDensity! {!x0!,!y0!},{!x1!,!y1!},{!x2!,!y2!},{!x3!,!y3!}

        for /L %%j in (1 1 %NumOfLines%) do (

            set /a "x=XC + (t0_%%j*x0+t1_%%j*x1+t2_%%j*x2+t3_%%j*x3)*pixel_h/(pixel_w*NumOfLinesCube)"
            set /a "y=YC + (t0_%%j*y0+t1_%%j*y1+t2_%%j*y2+t3_%%j*y3)/NumOfLinesCube"
            set /a "inScr=(x-0^x-wid)&(y-0^y-hei)"

            if !inScr! lss 0 (
                set /a "ind=x+y*wid+1, lenL=ind-1"
                for /f "tokens=1,2" %%a in ("!lenL! !ind!") do set "scr=!scr:~0,%%a!!dic:~%DotsPerLine%,1!!scr:~%%b!"
            )

        )

        REM clear old line
        for %%c in ("!dic:~0,1!") do set "scr=!scr:%%~c= !"

        CLS
        <nul set /p "=%BS%!scr:~0,-1!"
    )

    for /L %%h in (0 1 3) do (
        set /a "cx%%h_0=cx%%h_3, cy%%h_0=cy%%h_3, cx%%h_1 = (cx%%h_3 << 1) - cx%%h_2, cy%%h_1 = (cy%%h_3 << 1) - cy%%h_2"
        for %%i in (2 3) do set /a "cx%%h_%%i=!random! %% wid - (wid>>1), cy%%h_%%i=!random! %% hei - (hei>>1)"
    )
)

Antonio

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

Re: Bézier curve animation symmetric fantasy art

#5 Post by misol101 » 04 Oct 2016 13:47

Aacini: your version is blinking quite a bit... (Win7)

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Bézier curve animation symmetric fantasy art

#6 Post by Aacini » 04 Oct 2016 18:09

Yes. As I said, I changed the code that move the cursor via %BS% characters, for the usual CLS method that present a small flicker. The final code will move the cursor again, so it will have not any blinking.

Antonio

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Bézier curve animation symmetric fantasy art

#7 Post by foxidrive » 06 Oct 2016 14:48

The level of flicker is probably dependant on the graphic card, monitor and CPU grunt too.

I too like the animations. Tres lubberly!

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Bézier curve animation symmetric fantasy art

#8 Post by Aacini » 07 Oct 2016 00:38

I completed my "Lines in color" modification! :mrgreen: 8)

Image

Code: Select all

@echo off
setlocal EnableDelayedExpansion

if "%~1" neq "" if "%~1" neq "1" goto %1

rem Original code written by neorobin
rem http://www.dostips.com/forum/viewtopic.php?f=3&t=7447

rem This "Lines in color" version created by Antonio Perez Ayala, aka Aacini
rem Use PowerShell to move cursor and show text in color as described at:
rem http://www.dostips.com/forum/viewtopic.php?f=3&t=6936&p=46206#p46206

rem Configuration parameters
set "hexWid=64" & set "hexHei=42" & REM Screen size in hexa: 100 x 66
set /A "NumOfLines=12, DotsPerLine=30, pathDensity=50"

if %NumOfLines% gtr 15 echo The number of lines must be less than 16 & pause & exit /B

if "%1" equ "" (
    for /f "tokens=2 delims=[]" %%a in ('ver') do for /f "tokens=2 delims=. " %%a in ("%%a") do set /a "FullScreen=-((%%a-6)>>31)"
    for %%a in ( FontSize:00060004 FontFamily:00000030 WindowSize:00%hexHei%00%hexWid% ScreenColors:00000007
                 CodePage:000001b5 ScreenBufferSize:00%hexHei%00%hexWid% FullScreen:!FullScreen:-=! ) do (
        for /f "tokens=1,2 delims=:" %%b in ("%%a") do >nul reg add HKCU\Console\Bezier_CMD /v %%b /t reg_dword /d 0x%%c /f
    )
    start "Bezier_CMD" /max "%ComSpec%" /c %~s0 1 & exit
) else (
    >nul reg delete HKCU\Console\Bezier_CMD /f
)

echo/
echo   @   @   @@@@@   @@@   @@@@@
echo   @   @   @   @    @      @
echo   @ @ @   @@@@@    @      @
echo   @@ @@   @   @    @      @
echo   @   @   @   @   @@@     @    @   @   @

"%~F0" Main  |  "%~F0" Output
goto :EOF


:Main

(
   for /f "delims==" %%a in ('set') do set "%%a="
   set "Path=%SystemRoot%\system32"
   set /A hexWid=%hexWid%, hexHei=%hexHei%, NumOfLines=%NumOfLines%, DotsPerLine=%DotsPerLine%, pathDensity=%pathDensity%
)

set /a "pixel_w=4, pixel_h=6" & rem FontSize 4X6
set /a "wid=0x%hexWid%, hei=0x%hexHei%, XC = wid/2, YC = hei/2"
set /a "NumOfLinesSQ=NumOfLines*NumOfLines, NumOfLinesCube=NumOfLines*NumOfLinesSQ"
set /a "pathDensitySQ=pathDensity*pathDensity, pathDensityCube=pathDensitySQ*pathDensity"

for /L %%h in (0 1 3) do for %%i in (0 1 3) do (
   set /a "cx%%h_%%i=!random! %% wid - (wid>>1), cy%%h_%%i=!random! %% hei - (hei>>1)"
)

for /L %%j in (1 1 %NumOfLines%) do (
   set /a "tr_%%j=NumOfLines-%%j, tr2_%%j=tr_%%j*tr_%%j, te2_%%j=%%j*%%j, t0_%%j=tr2_%%j*tr_%%j, t1_%%j=3*tr2_%%j*%%j, t2_%%j=3*tr_%%j*te2_%%j, t3_%%j=te2_%%j*%%j"
)

for /L %%# in () do (

    for /L %%i in (1 1 %pathDensity%) do (

        set /a "tr=pathDensity-%%i,tr2=tr*tr,te2=%%i*%%i,ct0=tr2*tr, ct1=3*tr2*%%i, ct2=3*tr*te2, ct3=te2*%%i"
        for /L %%h in (0 1 3) do (
            set /a "x%%h=(ct0*cx%%h_0+ct1*cx%%h_1+ct2*cx%%h_2+ct3*cx%%h_3)/pathDensityCube"
            set /a "y%%h=(ct0*cy%%h_0+ct1*cy%%h_1+ct2*cy%%h_2+ct3*cy%%h_3)/pathDensityCube"
        )

        set "tail="
        set "head="
        set /A "h=(h+1)%%DotsPerLine"

        for /L %%j in (1,1,%NumOfLines%) do (

            REM clear last dots
            if defined x%%j[!h!] (
                set /A "x=x%%j[!h!], y=y%%j[!h!]"
                set "tail=!tail!,!x!,!y!"
            )

            set /a "x=XC + (t0_%%j*x0+t1_%%j*x1+t2_%%j*x2+t3_%%j*x3)*pixel_h/(pixel_w*NumOfLinesCube)"
            set /a "y=YC + (t0_%%j*y0+t1_%%j*y1+t2_%%j*y2+t3_%%j*y3)/NumOfLinesCube"
            set /A "inScr=(x>>31)|(y>>31)|((wid-x-1)>>31)|((hei-y-1)>>31)"

            if !inScr! equ 0 (
                set /A "x%%j[!h!]=x, y%%j[!h!]=y, j=16-%%j"
                set "head=!head!,!x!,!y!,!j!"
            )

        )

        if defined tail echo T!tail!
        echo H!head!

    )

    for /L %%h in (0 1 3) do (
        set /a "cx%%h_0=cx%%h_3, cy%%h_0=cy%%h_3, cx%%h_1 = (cx%%h_3 << 1) - cx%%h_2, cy%%h_1 = (cy%%h_3 << 1) - cy%%h_2"
        for %%i in (2 3) do set /a "cx%%h_%%i=!random! %% wid - (wid>>1), cy%%h_%%i=!random! %% hei - (hei>>1)"
    )
)
exit


:Output

rem The parameters received via lines read have these two forms:
rem - Tail coordinates:            T,X1,Y1,X2,Y2 ...
rem - Head coordinates and colors: H,X1,Y1,C1,X2,Y2,C2 ...

PowerShell  ^
   cls;  ^
   $console = $Host.UI.RawUI;  ^
   $console.CursorSize = 0;  ^
   $coords = $console.CursorPosition;  ^
   foreach ( $line in $input ) {  ^
      $type,$line = $line.Split(',');  ^
      $X,$Y,$line = $line;  ^
      while ( $X ) {  ^
         $coords.X = [int]$X;  $coords.Y = [int]$Y;  $console.CursorPosition = $coords;  ^
         if ( $type -eq 'T' ) {  ^
            Write-Host -NoNewLine ' ';  ^
         } else {  ^
            [int]$Color,$line = $line;  ^
            Write-Host  -ForegroundColor $Color  -NoNewLine  'Û';  ^
         }  ^
         $X,$Y,$line = $line;  ^
      }  ^
   }
%End PowerShell%
exit /B

Antonio

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Bézier curve animation symmetric fantasy art

#9 Post by foxidrive » 07 Oct 2016 03:01

Having tried the non-symetrical and symetrical code I find that it seems to need a mode command to set the size of the console widow.

My system has a small meltdown in the console window and looks nothing like it should. Yours is colourful Antonio but still warped in the wrong console size or maybe my font size is a problem...

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Bézier curve animation symmetric fantasy art

#10 Post by Aacini » 07 Oct 2016 09:43

@foxidrive:

You may change the screen size for a smaller one and test it. The configuration parameters are set in these lines:

Code: Select all

rem Configuration parameters
set "hexWid=64" & set "hexHei=42" & REM Screen size in hexa: 100 x 66
set /A "NumOfLines=12, DotsPerLine=30, pathDensity=50"

You must preserve the 100:66 = 1.52 aspect relation and give the sizes in hexadecimal. For example, to set a screen size of 80 x 52, use:

Code: Select all

set "hexWid=50" & set "hexHei=34" & REM Screen size in hexa: 80 x 52

If this change does not solve your problem, then perhaps it is related to the values set by REG ADD command...

Antonio

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

Re: Bézier curve animation symmetric fantasy art

#11 Post by misol101 » 07 Oct 2016 18:02

Image
Image

I had a go at a similar thing using my tool cmdgfx (viewtopic.php?f=3&t=7153), as described in the last post in that topic.

Both scripts (bezier.bat, bezier-expr.bat) run in a 220x95 console window, in the second case a plasma effect is overlaid over the bezier curves to get some colors. The framerate is good.

Keys: Space to create new moving pattern, RETURN to switch symmetric/assymetric, c to change color, s to cycle colors

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

Re: Bézier curve animation symmetric fantasy art

#12 Post by misol101 » 08 Oct 2016 06:07

Image

This morning I realized it was a shame to draw 50 bezier lines per frame and not actually make it look like they move. So I made a new version, (bezier2.bat), where I have less lines but each line moves individually every frame. This creates a totally different feeling and can be quite dizzying at times :)

Space to create new pattern.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Bézier curve animation symmetric fantasy art

#13 Post by foxidrive » 08 Oct 2016 08:27

Aacini wrote:

Code: Select all

set "hexWid=50" & set "hexHei=34" & REM Screen size in hexa: 80 x 52

If this change does not solve your problem, then perhaps it is related to the values set by REG ADD command...


Thanks for your advice Antonio.

Using your change the window is an odd shape but your animation worked - even though it bounced up and down at times with scroll bars.

I expected the window to be a different aspect ratio, and not what I saw.



Image

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

Re: Bézier curve animation symmetric fantasy art

#14 Post by misol101 » 08 Oct 2016 08:58

Aacini: I stole your sin macro and created yet another version. Thanks, it's great, no more lookup table (even though I'm not sure I use the macro completely right, but the result still looks lovely, so... :) )

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Bézier curve animation symmetric fantasy art

#15 Post by Aacini » 08 Oct 2016 16:30

@foxidrive: Try an even smaller size; for example:

Code: Select all

set "hexWid=3C" & set "hexHei=28" & REM Screen size in hexa: 60 x 40

Antonio

Post Reply