Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- menu * {
- Spiral Out:/SpiralOfLife 60
- }
- alias SpiralOfLife {
- if (%spiralOfLife) {
- Spiral.Destroy
- }
- Spiral.Create $1
- }
- on 1:close:@SpiralOfLife: {
- .timerSpiralofLife off
- %spiralofLife = $false
- .hfree SpiralOfLife
- }
- alias Spiral.Destroy {
- .timerSpiralOfLife off
- close @SpiralofLife
- %spiralOfLife = $false
- .hfree SpiralOfLife
- }
- alias Spiral.Create {
- Spiral.InitWindow
- Spiral.InitDots $1
- Spiral.StartAnimation
- }
- alias Spiral.StartAnimation {
- .timerSpiralOfLife 0 0 Spiral.RenderScene
- }
- alias Spiral.InitDots {
- var %MultiDirection 0
- var %dotCount $1
- var %baseSize 4
- var %baseDist 4
- var %baseAngle 4
- var %angleOffset $calc(%baseAngle / (%dotCount + 1) * (1 + %multiDirection))
- var %redBase 0
- var %redOffset $calc(255 / %dotCount)
- var %currDist %baseDist
- var %x 1
- hadd -m SpiralOfLife DotCount %dotCount
- while %x <= %dotCount {
- var %baseAngle %baseAngle - %angleOffset
- hadd -m SpiralOfLife %x $+ .AngleOffset %baseAngle
- hadd -m SpiralOfLife %x $+ .Size $calc(%baseSize * ((%x * .05) + 1))
- hadd -m SpiralOfLife %x $+ .Angle 90
- hadd -m SpiralOfLife %x $+ .Distance %currDist
- hadd -m SpiralOfLife %x $+ .Color $rgb(%redBase,35,70)
- inc %currDist $calc(%baseSize * ((%x * .05) + 1))
- inc %redBase %redOffset
- inc %x
- }
- }
- alias Spiral.InitWindow {
- var %window.h 768
- var %window.w 1024
- hadd -m SpiralOfLife window.midx $calc(%window.w / 2)
- hadd -m SpiralOfLife window.midy $calc(%window.h / 2)
- hadd -m SpiralOfLife window.w %window.w
- hadd -m SpiralofLife window.h %window.h
- window -aBdfp @SpiralOfLife -1 -1 %window.w %window.h
- }
- alias Spiral.RenderScene {
- var %dotCount $hget(SpiralOfLife,DotCount)
- drawrect -nrf @SpiralOfLife $rgb(255,255,255) 1 0 0 $hget(SpiralOfLife,window.w) $hget(SpiralOfLife,window.h)
- var %lastX, %lastY
- var %window.midx $hget(SpiralOfLife,window.midx)
- var %window.midy $hget(SpiralOfLife,window.midy)
- var %list,%list2,%list3
- while %dotCount {
- var %length $hget(SpiralOfLife,%dotCount $+ .Distance)
- var %dotSize $hget(SpiralOfLife,%dotCount $+ .Size)
- var %dotOffset %dotSize / 2
- var %NewAngle $calc(($hget(SpiralOfLife,%dotCount $+ .Angle) + $hget(SpiralOfLife,%dotCount $+ .AngleOffset)) % 360)
- var %zz $sin(%newAngle).deg
- var %newX $calc(%zz * %length + %window.midx - %dotOffset)
- ;var %newY $calc($cos(%newAngle).deg * %length + %window.midy - %dotOffset)
- var %newY $calc($cos($calc(%newAngle * 2)).deg * %length + %window.midy - %dotOffset)
- %list = %list $round(%zz,2)
- %list2 = %list2 %newX
- %list3 = %list3 %newY
- var %color $hget(SpiralOfLife,%dotCount $+ .Color)
- ;Uncomment the next line to draw dots;
- ;drawDot -nr @SpiralOfLife %color %dotSize %newX %newY
- if %lastX != $null && %lastY != $null {
- ;Uncomment the next line to draw lines
- drawline -nr @SpiralOfLife %color 2 %newX %newY %lastX %lastY
- }
- var %lastX %newX
- var %lastY %newY
- hadd -m SpiralOfLife %dotCount $+ .Angle %newAngle
- dec %dotCount
- }
- var %dotCount $hget(SpiralOfLife,DotCount)
- var %iter $int($calc(%dotCount / 2))
- var %x 2,%lastX,%lastY
- /*
- while %x <= %iter {
- if $count(%list,$token(%list,1 - $+ %x,32)) == $floor($calc(%dotCount / %x)) {
- var %k $v2
- var %y %x
- while %nny {
- var %z %k
- while %z {
- dec %z
- }
- dec %y
- }
- drawsave -q80 @SpiralOfLife SpiralOfLife- $+ %x $+ - $+ $ticks $+ .jpg
- %x = $calc(%iter + 1)
- }
- inc %x
- }
- */
- drawDot @SpiralOfLife
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement