Implementing Color Fading Effects on Text in ProBuilder

01 Sep 2019
0 comment
0 attachment

This ProBuilder code snippet demonstrates how to create a fading color effect on text by adjusting the alpha transparency. The example uses a series of `DrawText` functions to display text with decreasing levels of opacity, creating a visual fade-out effect.


BACKGROUNDCOLOR(0,0,0) // color unimportant
R=235 // 1st 235
G=235 // 2nd 235
B=255 // last can have 255
Fade0=255 // bright
Fade1=128 // bit less
Fade2=64 // more less
Fade3=32 // even more less
Fade4=0 // invisible
DrawText("■",barindex,0.4,Monospaced,Bold,30) coloured(R,G,B,Fade0)
DrawText("■",barindex,0.2,Monospaced,Bold,30) coloured(R,G,B,Fade1)
DrawText("■",barindex,0,Monospaced,Bold,30) coloured(R,G,B,Fade2)
DrawText("■",barindex,-0.2,Monospaced,Bold,30) coloured(R,G,B,Fade3)
DrawText("■",barindex,-0.4,Monospaced,Bold,30) coloured(R,G,B,Fade4)
Return

The code snippet above uses several key functions and properties:

  • BACKGROUNDCOLOR: Sets the background color of the chart. Here, it is set to black (0,0,0).
  • RGB Values: Defines the color of the text. The RGB values used are close to white, with a slight emphasis on blue (R=235, G=235, B=255).
  • Fade Variables: These variables control the alpha transparency of the text color. Starting from fully opaque (Fade0=255) to completely transparent (Fade4=0).
  • DrawText: This function is used to draw text on the chart. It takes parameters for the text character, position on the x-axis (barindex), vertical position (y-axis), font style (Monospaced, Bold), font size (30), and the color including the alpha transparency.
  • The text character “■” (a solid square block) is used to better visualize the fading effect.
  • The vertical positions (0.4 to -0.4) are adjusted to spread the text blocks vertically, enhancing the visual representation of fading.

This example is useful for developers looking to implement visual effects in their ProBuilder applications, particularly for enhancing the UI elements with dynamic color changes.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/backgroundcolor-limits-white-drawing-color/#post-41150

Visit Link
What is a Snippet? A snippet is a small, reusable chunk of code designed to solve specific tasks quickly. Think of it as a shortcut that helps you achieve your coding goals without reinventing the wheel. How to Use: Simply copy the snippet and paste it into your project where needed. Don't forget to tweak it to fit your context. Snippets are not just time-savers; they're also learning tools to help you become a more efficient coder.
AVT Senior
This author is like an anonymous function, present but not directly identifiable. More details on this code architect as soon as they exit 'incognito' mode.
Author’s Profile

Comments

Search Snippets

Showing some results...
Sorry, no result found!

Snippets Categories

global
35
indicator
133
strategy
171

Recent Snippets

How to Create a Simple MTF Trend Dashboard with EMA and SMA
indicator
This indicator builds a compact multi-timeframe (MTF) dashboard that shows whether price is trading above or below a [...]
How to Display Per-Bar Volume Accumulation in Real Time (Intrabar Updates)
global
This snippet tracks and displays the current bar’s accumulated volume while the bar is still forming, instead of only [...]
Ticks Counter: Count Tick Updates Per Bar on Tick or Time Charts
global
This snippet counts how many tick updates have occurred for the current bar by incrementing a per-bar counter on each [...]
How to Build a Step-Based Trailing Stop That Moves to Break-Even First
strategy
This snippet implements a step trailing stop that advances in fixed increments once price reaches predefined profit [...]
Utilizing Arrays to Track and Compare Indicator Values Within the Same Bar in ProBuilder
indicator
This ProBuilder code snippet demonstrates how to use arrays to compare the values of an indicator (RSI in this case) [...]
Logo Logo
Loading...