[CLX] Progressbar - Logo
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © cryptolinx

//@version=5
// @description This script is part of the Library Progressbar - Showcase. You can find it under: https://www.tradingview.com/script/RRwvtQAQ-Progressbar/
indicator("[CLX] Scale - Logo", overlay = true)

import cryptolinx/Motion/11 as motion

// ———— User Inputs {
//
var int __OFFSET_X = input.int(0, 'Offset X-Axis', minval = 0, step = 1)
var int __Y = input.int(1000, 'Y-Axis', minval = 0, step = 1)
var string __LOGO_TEXT = input.string('SCALE.','Logo Text')
var string __TAGLINE1 = input.string('- A Pine Script™ Showcase -','Tagline #1')
var string __TAGLINE2 = input.string('v3.x','Tagline #2')
var string __SIZE_LOGO = input.string(size.huge, 'Size Logo', options=[size.small, size.tiny, size.normal, size.large, size.huge, size.auto])
var string __SIZE_TAG1 = input.string(size.normal, 'Size Tag #1', options=[size.small, size.tiny, size.normal, size.large, size.huge, size.auto])
var string __SIZE_TAG2 = input.string(size.small, 'Size Tag #2', options=[size.small, size.tiny, size.normal, size.large, size.huge, size.auto])
var color __COL_LOGO = input.color(#efe5ff, 'Color Logo Text')
var color __COL_DECOR = input.color(#7d1aff, 'Color Logo Decoration')
var color __COL_TAG1 = input.color(#CCCCCC, 'Color Logo')
var color __COL_TAG2 = input.color(color.rgb(194, 167, 225, 69), 'Color Logo')
// }


// ———— Simple Animated Logo/Tag Idea {
//
renderLogo(string _logo, string _tag1 = '', string _tag2 = '', string _sizeLogo = size.huge, string _sizeTag1 = size.normal, string _sizeTag2 = size.small,
  color _colorLogo = #efe5ff,  color _colorTag1 = #CCCCCC,  color _colorTag2 = color.white, color _colorDecor = #7d1aff, int _x = bar_index, float _y = 0) =>
    // >>
    array.from(
     // -- motion placholder
     label.new(bar_index + _x, _y, text = '', size = _sizeTag1, color = #00000000, textcolor = _colorDecor, text_font_family = font.family_default, style = label.style_label_center, textalign = text.align_center),
     // -- logo text
     label.new(bar_index + _x, _y, text = _logo, size = _sizeLogo, color = #00000000, textcolor = _colorLogo, text_font_family = font.family_default, style = label.style_label_center, textalign = text.align_center),
     // -- decoration
     label.new(bar_index + _x, _y, text = '└', size = _sizeLogo, color = #00000000, textcolor = color.new(_colorDecor, 75), text_font_family = font.family_default, style = label.style_label_upper_right, textalign = text.align_left),
     label.new(bar_index + _x, _y, text = '┘', size = _sizeLogo, color = #00000000, textcolor = color.new(_colorDecor, 75), text_font_family = font.family_default, style = label.style_label_upper_left, textalign = text.align_left),
     label.new(bar_index + _x, _y, text = '┌', size = _sizeLogo, color = #00000000, textcolor = color.new(_colorDecor, 75), text_font_family = font.family_default, style = label.style_label_lower_right, textalign = text.align_left),
     label.new(bar_index + _x, _y, text = '┐', size = _sizeLogo, color = #00000000, textcolor = color.new(_colorDecor, 75), text_font_family = font.family_default, style = label.style_label_lower_left, textalign = text.align_left),
     // -- tag 1 + 2
     label.new(bar_index + _x, _y, text = '\n\n\n\n\n' + _tag1, size = _sizeTag1, color = #00000000, textcolor = _colorTag1, text_font_family = font.family_default, style = label.style_label_up, textalign = text.align_left),
     label.new(bar_index + _x, _y, text = _tag2 + '\n\n\n\n\n\n', size = _sizeTag2, color = #00000000, textcolor = _colorTag2, text_font_family = font.family_default, style = label.style_label_center, textalign = text.align_left))
// }

// ———— Simple Animated Logo/Tag Idea {
//
renderTag(string _tag, string _size = size.large, color _color, int _x = bar_index, float _y = -500) =>
    // >>
    array.from(
     // -- motion placholder
     label.new(bar_index + _x, _y, text = '', size = _size, color = #00000000, textcolor = _color, text_font_family = font.family_default, style = label.style_label_center, textalign = text.align_center),
     // -- decoration
     label.new(bar_index + _x, _y, text = '└', size = _size, color = #00000000, textcolor = color.new(_color, 75), text_font_family = font.family_default, style = label.style_label_upper_right, textalign = text.align_left),
     label.new(bar_index + _x, _y, text = '┘', size = _size, color = #00000000, textcolor = color.new(_color, 75), text_font_family = font.family_default, style = label.style_label_upper_left, textalign = text.align_left),
     label.new(bar_index + _x, _y, text = '┌', size = _size, color = #00000000, textcolor = color.new(_color, 75), text_font_family = font.family_default, style = label.style_label_lower_right, textalign = text.align_left),
     label.new(bar_index + _x, _y, text = '┐', size = _size, color = #00000000, textcolor = color.new(_color, 75), text_font_family = font.family_default, style = label.style_label_lower_left, textalign = text.align_left))

// }

// ———— Update Logo {
//
update(array <label> _logo, string tag, int _x = bar_index, float _y = 200) =>
    // --
    if barstate.islast
        for i = 0 to array.size(_logo) - 1
            label.set_xy(array.get(_logo, i), _x, _y)
        label.set_text(array.get(_logo, 0), tag)
// }

// ———— Motion 🪄 {
//
// ⚠️ IMPORTANT: TO GET EVERYTHING WELL, YOU HAVE TO USE `varip` keyword on variable decleration.
//
varip logoKf = motion.keyframe.new(3, 1)
// --
var array <label> LOGO = renderLogo(__LOGO_TEXT, __TAGLINE1 , __TAGLINE2 , __SIZE_LOGO, __SIZE_TAG1, __SIZE_TAG2, __COL_LOGO, __COL_TAG1, __COL_TAG2, __COL_DECOR)
string tag = '\n\n\n' + motion.transition(logoKf, _fx = 'marquee', _seq = '▰▱▱▱▰▱▱▱▰', _subLen = 3, _autoplay = true)
update(LOGO, tag)
// }


// #EOF