📉 Draggable Curve Control (English)
2024-09-23 08:58:44
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\)
最新文章
- Hibernate 表映射 主键生成策略与复合主键
- 【Discuz】关闭QQ互联插件提示信息:系统繁忙,请稍后再试
- jquery遍历
- qml 相关的博客
- LOGSTASH再入门第一发
- 了解SQL Server锁争用:NOLOCK 和 ROWLOCK 的秘密
- Linux之top
- AngularJS--购物车全选/取消全选功能实现
- 18个超有趣的SVG绘制动画赏析
- JQuery DOM操作 、属性和CSS样式操作、其他函数
- myeclipse和jdk的安装和配置
- js之省市区(县)三级联动效果
- python中的zip、lambda、map操作
- 转:ActiveMQ的作用总结(应用场景及优势)
- Spring定时器corn表达式详解
- Coneroller执行时候的-26374及-26377错误
- MVC的初步认识理论
- jmeter bean shell断言加密的响应信息(加密接口测试二)
- libcurl开源库在Win32程序中使用下载文件显示进度条实例
- C#后端接收form-data,创建实体类
热门文章
- Spark算子--SortByKey
- sizeof(extern类型数组)
- A glance at endpoint security
- ASP.NET网络爬虫小研究 HtmlAgilityPack基础,爬取数据保存在数据库中再显示再自己的网页中
- RAC某节点v$asm_disk查询hang分析处理
- Intellij-@Override报错
- python_斐波那契数列
- Python---socket库
- MoonLight可视化订单需求区域分析系统前端
- getResource()和getSystemResource()分析