B Finding the Equation to Place RGB=255 128 0 on a Long Thin Shape

  • B
  • Thread starter Thread starter Wes Turner
  • Start date Start date
  • Tags Tags
    Shape
AI Thread Summary
The discussion focuses on finding an equation to adjust the green (G) value in an RGB color gradient from red to yellow along a long thin shape. The goal is to determine a method to position the G value of 127.5 at any point along the shape, rather than just the midpoint. While a quadratic equation was initially considered, it was found unsuitable due to potential negative or excessive values. Alternatives discussed include using two linear equations on either side of the desired point or employing a spline or exponential distribution with an offset. The conversation emphasizes the need for precise control over the color transition along the shape.
Wes Turner
Messages
68
Reaction score
15
I have a long thin shape (rope, bar). The color of the shape changes smoothly from red (RGB=255 0 0) at one end to yellow (RGB=255 255 0) at the other. I need an equation that will allow me to adjust the G value from 0 to 255 in a way that I can choose where on the shape it has the value 127.5 (equal parts red and yellow, RGB = 255 128 0), if the 127.5 is rounded.

The linear equation y = 255x + 0 places that point at the midpoint (0.5) of the shape. The rounded values at 0.1 intervals are:
Color shading.jpg


I would like an equation that will enable me to place the G=127.5 value anywhere on that shape from 0.0 to 1.0. I'm not sure if a quadratic equation is the best choice or some type of exponential. For the quadratic, I would have three points ((0.0), (k,127.5), (1,255)) and could solve 3 equations in 3 unknowns.

Is there a better way?

Thanks
 

Attachments

  • Color shading.jpg
    Color shading.jpg
    12.8 KB · Views: 566
Mathematics news on Phys.org
In general a quadratic equation will go to negative values if your midpoint is too close to the 255 side, and above 255 if it is tooclose to the right side. You could use two linear relations left and right of it, or use a spline.

An exponential distribution with an offset (##a+e^{bx+c}##) would work as well.
 
  • Like
Likes Wes Turner
mfb said:
In general a quadratic equation will go to negative values if your midpoint is too close to the 255 side, and above 255 if it is too close to the right side.
Yeah, after some testing, I discovered that the quadratic is not a good choice.

You could use two linear relations left and right of it, or use a spline.
I'm not sure what you mean by two linear relations, but a spline might be a good choice. I didn't think of that. Thanks.

An exponential distribution with an offset (##a+e^{bx+c}##) would work as well.
Another good suggestion. Thanks.
 
Wes Turner said:
I'm not sure what you mean by two linear relations
G(x)=c*x up to the fixed point in the middle, and G(x)=a+b*x from there to the end (where a+b=255 to satisfy G(1)=255).
 
  • Like
Likes Wes Turner
mfb said:
G(x)=c*x up to the fixed point in the middle, and G(x)=a+b*x from there to the end (where a+b=255 to satisfy G(1)=255).
Got it, thanks.
 
Thread 'Video on imaginary numbers and some queries'
Hi, I was watching the following video. I found some points confusing. Could you please help me to understand the gaps? Thanks, in advance! Question 1: Around 4:22, the video says the following. So for those mathematicians, negative numbers didn't exist. You could subtract, that is find the difference between two positive quantities, but you couldn't have a negative answer or negative coefficients. Mathematicians were so averse to negative numbers that there was no single quadratic...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...
Back
Top