Bézier curve animation symmetric fantasy art

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: Bézier curve animation symmetric fantasy art

#16 Post by foxidrive » 08 Oct 2016 18:16

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

Thank you Antonio. That worked for the two Bezier functions but your script gave me a string of Divide by zero errors.

I have a spinal injury that has worsened to due to my progressive disease called EDS and it has made sleeping very difficult for me for well over a year. This level of chronic sleep deprivation has made in-depth technical tasks too difficult for me to investigate - which is why I ask simple questions.

I removed and replaced the same line and the errors disappeared and returned.

Windows 8.1 32 bit here.

Code: Select all

Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by zero error.
Divide by z   ero error.

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

Re: Bézier curve animation symmetric fantasy art

#17 Post by misol101 » 09 Oct 2016 18:22

My "final" version of this looks like:

Image

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

Re: Bézier curve animation symmetric fantasy art

#18 Post by Aacini » 10 Oct 2016 23:08

@foxidrive:

The line with the screen size definitions must not be removed. Here there are several screen size definitions; you may test they all one by one until you find the best one for your screen:

Code: Select all

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

set "hexWid=46" & set "hexHei=2E" & REM Screen size in hexa: 70 x 46

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

__________________________________________________________________________________

I introduced several small modifications in my last program that makes the code simpler and faster; the new version is below. The next animation example was created with these configuration parameters:

Code: Select all

rem Configuration parameters
set "hexWid=90" & set "hexHei=60" & REM Screen size in hexa: 144 x 96
set /A "NumOfLines=7, DotsPerLine=60, pathDensity=50"


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=15, 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 %%a in ( FontSize:00060004 FontFamily:00000030 WindowSize:00%hexHei%00%hexWid% ScreenColors:00000007
                 CodePage:000001b5 ScreenBufferSize:00%hexHei%00%hexWid% FullScreen:1 ) 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 wid=0x%hexWid%, hei=0x%hexHei%, NumOfLines=%NumOfLines%, DotsPerLine=%DotsPerLine%, pathDensity=%pathDensity%
)

set /a "XC = wid/2, YC = hei/2,  pixel_w=4, pixel_h=6" & rem FontSize 4X6
set /a "NumOfLinesCube=NumOfLines*NumOfLines*NumOfLines, pathDensityCube=pathDensity*pathDensity*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=NumOfLines-%%j,tr2=tr*tr,te2=%%j*%%j, t0_%%j=tr2*tr, t1_%%j=3*tr2*%%j, t2_%%j=3*tr*te2, t3_%%j=te2*%%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 /A "h=(h+1)%%DotsPerLine"
        for %%h in (!h!) do (

            if defined scr%%h echo T!scr%%h!
            set "scr%%h="

            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>>31)|(y>>31)|((wid-x-1)>>31)|((hei-y-2)>>31),  j=16-%%j"

                if !inScr! equ 0 set "scr%%h=!scr%%h!,!x!,!y!,!j!"

            )

            echo H!scr%%h!
        )

    )

    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 and colors: T,X1,Y1,C1,X2,Y2,C2 ... (colors are ignored in Tail)
rem - Head coordinates and colors: H,X1,Y1,C1,X2,Y2,C2 ...

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

Antonio

Post Reply