Page 2 of 2

Re: Bézier curve animation symmetric fantasy art

Posted: 08 Oct 2016 18:16
by foxidrive
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.

Re: Bézier curve animation symmetric fantasy art

Posted: 09 Oct 2016 18:22
by misol101
My "final" version of this looks like:

Image

Re: Bézier curve animation symmetric fantasy art

Posted: 10 Oct 2016 23:08
by Aacini
@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

Re: Bézier curve animation symmetric fantasy art

Posted: 07 Aug 2020 12:14
by IcarusLives
Edited: Fixed to be true to OP

I created a windows 10 VT100 version of the non-symmetrical version

Sorry for digging this up, but I hope you enjoy!

Image

Code: Select all

@echo off & setlocal enabledelayedexpansion

mode 100,100

( for /f %%a in ('echo prompt $E^| cmd') do set "esc=%%a" ) & <nul set /p "=!esc![?25l"

set /a "pixel_w=8, pixel_h=8"
set /a "Cols=wid=100, lines=hei=100, ctrl_wid=wid * 3 / 3, ctrl_hei=hei * 3 / 3
set /a "XC = Cols/2, YC = lines/2"

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 () 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, y%%h=(ct0*cy%%h_0+ct1*cy%%h_1+ct2*cy%%h_2+ct3*cy%%h_3)/pathDensityCube"
        )
		
		
		
        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 (
				for /f "tokens=1,2" %%x in ("!killDot[%%i][%%j]!") do <nul set /p "=%esc%[38;5;16m%esc%[%%y;%%xHÛ" & set "killDot[%%i][%%j]="
				set "scr=!scr!%esc%[38;5;%%jm%esc%[!y!;!x!HÛ"
				set "killDot[%%i][%%j]=!x! !y!"
			)
        )
		
		<nul set /p "=!scr!" & set "scr="
    )
	
    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)"
    )
)