Create a function that can make a color gradient for CCanvas

MQL5 资料库 积分

工作已完成

执行时间17 分钟

指定

I am doing some work with CCanvas, and I would like to make a "strength bar" UI display.

For example I would like the strength bar to start off grey, and progress to a more blue color as the value gets higher.

I need someone good with graphics code to help create a function for me that creates the gradient color pallet.


My function signature looks something like this:

void createColorGradient(
   const int width,
   const int height,
   const uint startColorARGB,
   const uint endColorARGB,
   const double gradientAngle,     
   uint &x[],
   uint &y[]
) {
   // Universal Consts
   const double radianPerDegree = 0.0174532925;
        
   // Reszie arrays
   ArrayResize(x, width);
   ArrayResize(y, height);
   
   // Convert angle to gradient
   const double gradientRadian = radianPerDegree * gradientAngle;


I am trying to understand some gradient code I found, but they don't use color so the solution is more complex than I can figure out in a reasonable amount of time.

The functions outputs x, y ARBG values ready for use in CCanvas.

There may be another value needed like gradient step or so, or this may need to be turned into a Class.

Anyone good with graphics let me know your proposals.

 


反馈

1
开发者 1
等级
(187)
项目
262
69%
仲裁
12
33% / 67%
逾期
16
6%
空闲
发布者: 993 代码

项目信息

预算
59+ USD
开发人员
53.1 USD