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

  • B
  • Thread starter Wes Turner
  • Start date
  • Tags
    Shape
In summary, the conversation discusses the need for an equation to adjust the G value of a long, thin shape with a smooth color gradient from red to yellow. Suggestions for equations include using a linear equation or an exponential distribution with an offset, and using two linear relations on either side of the midpoint. The quadratic equation is deemed not suitable for this situation.
  • #1
Wes Turner
66
14
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: 496
Mathematics news on Phys.org
  • #2
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
  • #3
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.
 
  • #4
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
  • #5
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.
 

1. What is the process for finding the equation to place RGB=255 128 0 on a long thin shape?

The process for finding the equation to place RGB=255 128 0 on a long thin shape involves several steps. First, you will need to determine the dimensions and orientation of the shape. Then, you will need to calculate the surface area of the shape. Next, you will use the RGB values to determine the color density needed for the shape. Finally, you can use this information to create an equation that will accurately place the RGB value on the shape.

2. Can the equation be used for any shape, or only a long thin one?

The equation for placing RGB=255 128 0 can be used for any shape, as long as the dimensions and orientation of the shape are known. However, the process may vary depending on the shape's complexity and surface area. It is important to carefully follow the steps to ensure accurate placement of the RGB value.

3. Is it possible to place multiple RGB values on the same long thin shape?

Yes, it is possible to place multiple RGB values on the same long thin shape. This can be achieved by using the equation and adjusting the color density for each RGB value. It is important to carefully plan and calculate the placement to ensure that the colors do not overlap or interfere with each other.

4. Will the equation work for all RGB values, or only specific ones?

The equation for placing RGB=255 128 0 can be modified to work for different RGB values. However, the process may vary depending on the desired RGB value and the surface area of the shape. It is important to carefully consider the dimensions and orientation of the shape to determine the correct color density for the desired RGB value.

5. Are there any alternative methods for placing RGB=255 128 0 on a long thin shape?

Yes, there are alternative methods for placing RGB=255 128 0 on a long thin shape. One method is to use a computer program or software that allows for precise color placement on shapes. Another method is to manually paint or color the shape using a brush or marker with the desired RGB value. However, using the equation is a more accurate and efficient method for placing RGB values on a long thin shape.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
802
  • Introductory Physics Homework Help
Replies
25
Views
478
  • Electrical Engineering
3
Replies
83
Views
4K
  • Introductory Physics Homework Help
Replies
34
Views
705
  • Differential Equations
Replies
16
Views
903
  • Classical Physics
Replies
6
Views
329
Replies
25
Views
2K
  • Introductory Physics Homework Help
Replies
30
Views
2K
Replies
17
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
Back
Top