{Gunzo} Animated Pixel Art - ASCII ArtAnimated Pixel Art - ASCII Art is not only an easy-to-use platform to create and visualize pixel animations. This script can also be used with the Nyan Cat visualization as a companion tool for all traders to know when the price is changing on the chart.
OVERVIEW :
In the first place, this tool has been created to celebrate the new design of the Trading View platform. The new monogram logo and the previous cloud logo can be displayed as pixel art within this script.
To test the limits of the pine script language, I tried to improve this simple pixel art script to be able to display complex pixel animations with good performance (max allowed 100 milliseconds per bar). That's how the Nyan Cat companion was created. Nyan Cat is moving every time the data on the chart is refreshed, so the animation time may differ depending on your environment. Only the pixels that changed between two animations are repainted on each loop so that the performance is significantly improved and allowing so to create bigger pixel art designs.
HOW IT WORKS :
The pixels are displayed on the chart using a huge table variable. Each cell of the table can be used to display one pixel of the initial matrix. New designs can easily be implemented as the pixel matrix is stored as a simple text variable.
The pixel matrix is composed of hexadecimal characters (0123456789ABCDEF). Each hexadecimal character correspond to a color in the 16 color palette.
SETTINGS :
Matrix Visual : Name of the pixel art matrix to be displayed
Matrix Colors : Palette to be used for painting the pixels. 16 color palette for colorful matrix or phosphor colors for retro aspect on simple pixel art.
Type of art : Pixel art paint square pixels on chart and ASCII art paints hexadecimal characters on a chart.
Pixel Grid color : Color used between each pixel, by default it is transparent.
Pixel Width : Change the aspect ratio of the matrix. Useful to fine-tune the size of the pixels according to your screen size and the script size.
Pixel Height : Change the aspect ratio of the matrix. Useful to fine-tune the size of the pixels according to your screen size and the script size.
ASCII Background Character : Character that will be replaced with no color
Nyancat
PineGIF - Display Gifs & Images In Tradingview [LuxAlgo]Pinescript is not designed to create or display images, let alone gifs, but it's very fun to try, and that's what this script does. This script allows the user to display three different gifs. In this post, we explain how we managed to display images/gif's using pinescript tables.
1. Image Pre-Processing
Due to pinescript limitations, we can't possibly display images with an excessively high resolution. As such we targeted pixel art as a primary image source. We used a pixel art gif of the magnificent Octocat (the mascot for the source-code hosting service GitHub) for our first try.
We first extract each frame from the gif and resize them to a 50x50 resolution which returns frames made of 2500 pixels. This process was done using python.
Getting Individual Pixels RGBA Values
Python can easily return a matrix containing each pixel's rgba value. For convenience, we converted the rgba values to hex.
We then create a simple code allowing us to return a pinescript array containing the 2500 pixel hex colors. We do this process for each frame.
2. Defining Table Cell Color
In the code, each frame is its own array. We create a new table with dimensions equal to len(frame1)^2 (we assume height = width).
The color of a cell is defined by the color of the image pixel at the same exact location. When a new bar is created, we do this exact process using a different frame which ultimately allows a new frame to be displayed.
3. Playing The GIFs
By default, the script will play the gif of the Tradingview cloud logo raining. In order to play the gif, simply use the replay mode. The replay speed allows the user to determine the frame rate (0.1 for the raining cloud and Nyan cat works best, 0.5 for Octocat).
We included the frames of the Octocat and Nyan cat gifs in the script.
4. Some Other Cool Images
Displaying static images is possible and involves the same process described above.
An original idea of the lizard, implemented by the wizard.