Conmajia 2012

Updated on Feb. 18, 2018

In Photoshop, there is a very powerful feature Curve Adjust, as shown in figure 1.

figure 1 Curve Adjust in Photoshop

You can adjust image parameters by adding, deleting or dragging nodes of the image curve.

Basically, such a curve is simple to implement:

  • A curve is presented by a series of points which are called nodes
  • Each node is an adjustable handle
  • Mouse events handlers for each node

Detailed design procedure is omitted. The result is show in figure 2:



figure 2 Animated Example

Sample Codes

The Node list.

List<Point> points;

Deal with node handlers.

Rectangle getHandle(Point p)
{
Rectangle rect = new Rectangle(
p.X - 3,
p.Y - 3,
6,
6);
return rect;
}

Check for mouse position.

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\)

最新文章

  1. Hibernate 表映射 主键生成策略与复合主键
  2. 【Discuz】关闭QQ互联插件提示信息:系统繁忙,请稍后再试
  3. jquery遍历
  4. qml 相关的博客
  5. LOGSTASH再入门第一发
  6. 了解SQL Server锁争用:NOLOCK 和 ROWLOCK 的秘密
  7. Linux之top
  8. AngularJS--购物车全选/取消全选功能实现
  9. 18个超有趣的SVG绘制动画赏析
  10. JQuery DOM操作 、属性和CSS样式操作、其他函数
  11. myeclipse和jdk的安装和配置
  12. js之省市区(县)三级联动效果
  13. python中的zip、lambda、map操作
  14. 转:ActiveMQ的作用总结(应用场景及优势)
  15. Spring定时器corn表达式详解
  16. Coneroller执行时候的-26374及-26377错误
  17. MVC的初步认识理论
  18. jmeter bean shell断言加密的响应信息(加密接口测试二)
  19. libcurl开源库在Win32程序中使用下载文件显示进度条实例
  20. C#后端接收form-data,创建实体类

热门文章

  1. Spark算子--SortByKey
  2. sizeof(extern类型数组)
  3. A glance at endpoint security
  4. ASP.NET网络爬虫小研究 HtmlAgilityPack基础,爬取数据保存在数据库中再显示再自己的网页中
  5. RAC某节点v$asm_disk查询hang分析处理
  6. Intellij-@Override报错
  7. python_斐波那契数列
  8. Python---socket库
  9. MoonLight可视化订单需求区域分析系统前端
  10. getResource()和getSystemResource()分析