Conmajia 2012
Updated on Feb. 18, 2018node
In Photoshop, there is a very powerful feature Curve Adjust, as shown in figure 1.ide
figure 1 Curve Adjust in Photoshopspa
You can adjust image parameters by adding, deleting or dragging nodes of the image curve.3d
Basically, such a curve is simple to implement:code
Detailed design procedure is omitted. The result is show in figure 2:blog
figure 2 Animated Exampleip
The Node
list.get
List<Point> points;
Deal with node handlers.it
Rectangle getHandle(Point p) { Rectangle rect = new Rectangle( p.X - 3, p.Y - 3, 6, 6); return rect; }
Check for mouse position.io
bool isHandle(Point p) { foreach (Point pt in points) { if (isInside(p, getHandle(pt))) { downIndex = points.IndexOf(pt); downPoint = pt; current = pt; return true; } } return false; }
Draw handlers.
void drawHandle(Graphics g, Point p) { if (points.IndexOf(p) == downIndex) g.FillRectangle( Brushes.Black, getHandle(p)); else g.DrawRectangle( Pens.Black, getHandle(p)); }
Draw the curve.
void drawCurve(Graphics g) { g.DrawCurve(Pens.Black, points.ToArray()); }
Total sample source code: download
The End. \(\Box\)