rgbaStart="rgba(0.216 0.484 0.919 1);"
rgbaEnd="rgba(0.416 0.284 0.119 1);"
bellaFrames=30

# Note all bash vars are global, except local
function bella_rgba_to_arr () {
    local localrgb=$1
    result="${localrgb#rgba\(*}"
    result="${result%*\);}"
    resultArr=($result)
    echo "inside ${#resultArr[@]}"
}

function lerp () {
	result=$(awk -v "start=$1" -v "end=$2" -v "frames=$3" -v "counter=$4" 'BEGIN {print ((end-(start))*((counter-1)/(frames-1)))+(start)}')
}

bella_rgba_to_arr "${rgbaStart}"
rgbaStartArr=(${resultArr[@]})
bella_rgba_to_arr "${rgbaEnd}"
rgbaEndArr=(${resultArr[@]})


for ((c = 0 ; c < ${#rgbaStartArr[@]} ; c++ )); do
    echo "$c ${rgbaStartArr[$c]}"
done
for ((c = 0 ; c < ${#rgbaEndArr[@]} ; c++ )); do
    echo "$c ${rgbaEndArr[$c]}"
done

for ((i = 1 ; i <= ${bellaFrames} ; i++ )); do 
	#red=$(awk -v rStart="${rgbaStartArr[0]}" -v rEnd="${rgbaEndArr[0]}" -v frames="$bellaFrames" -v "counter=$i" 'BEGIN {print ((rEnd-(rStart))*((counter-1)/(frames-1)))+(rStart)}')
	#green=$(awk -v gStart="${rgbaStartArr[1]}" -v gEnd="${rgbaEndArr[1]}" -v frames="$bellaFrames" -v "counter=$i" 'BEGIN {print ((gEnd-(gStart))*((counter-1)/(frames-1)))+(gStart)}')
	#blue=$(awk -v bStart="${rgbaStartArr[2]}" -v bEnd="${rgbaEndArr[2]}" -v frames="$bellaFrames" -v "counter=$i" 'BEGIN {print ((bEnd-(bStart))*((counter-1)/(frames-1)))+(bStart)}')
	#alpha=$(awk -v aStart="${rgbaStartArr[3]}" -v aEnd="${rgbaEndArr[3]}" -v frames="$bellaFrames" -v "counter=$i" 'BEGIN {print ((aEnd-(aStart))*((counter-1)/(frames-1)))+(aStart)}')
	lerp ${rgbaStartArr[0]} ${rgbaEndArr[0]} ${bellaFrames} ${i}
    red=$result
	lerp ${rgbaStartArr[1]} ${rgbaEndArr[1]} ${bellaFrames} ${i}
    green=$result
	lerp ${rgbaStartArr[2]} ${rgbaEndArr[2]} ${bellaFrames} ${i}
    blue=$result
	lerp ${rgbaStartArr[3]} ${rgbaEndArr[3]} ${bellaFrames} ${i}
    alpha=$result
    echo "$red $green $blue $alpha"
done