📉 Draggable Curve Control (English)
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\)
📉 Draggable Curve Control (English)的更多相关文章
- 📟 Character Liquid Crystal Display Control (English)
A replica CLCD module control. Initiated on May 5, 2012 Updated on Feb 21, 2017 Copyright 2012-2017 ...
- HTML5资料
1 Canvas教程 <canvas>是一个新的用于通过脚本(通常是JavaScript)绘图的HTML元素.例如,他可以用于绘图.制作图片的组合或者简单的动画(当然并不那么简单).It ...
- Delphi XE2 之 FireMonkey 入门(14) - 滤镜: 概览
相关单元: FMX.Filter FMX.FilterCatBlur FMX.FilterCatGeometry FMX.FilterCatTransition FMX_FilterCatColor ...
- javascript:Bing Maps AJAX Control, Version 7.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Convert BSpline Curve to Arc Spline in OpenCASCADE
Convert BSpline Curve to Arc Spline in OpenCASCADE eryar@163.com Abstract. The paper based on OpenCA ...
- Java基础之在窗口中绘图——移动曲线的控制点(CurveApplet 3 moving the control points)
Applet程序. import javax.swing.*; import java.awt.*; import java.awt.geom.*; import javax.swing.event. ...
- Java基础之在窗口中绘图——显示曲线的控制点(CurveApplet 2 displaying control points)
Applet程序. import javax.swing.*; import java.awt.*; import java.awt.geom.*; @SuppressWarnings("s ...
- 越狱Season 1-Episode 5: English, Fitz or Percy
Season 1, Episode 5: English, Fitz or Percy -Pope: I assume this is about your transfer request for ...
- the Linux Kernel: Traffic Control, Shaping and QoS
−Table of Contents Journey to the Center of the Linux Kernel: Traffic Control, Shaping and QoS 1 Int ...
随机推荐
- [国嵌攻略][137][DM9000网卡驱动编程]
DM9000数据发送 DM9000数据发送函数是在/drivers/net/dm9000.c中的dm9000_start_xmit函数 static int dm9000_start_xmit(str ...
- day2 作业
1.判断下列逻辑语句的True,False. 1),1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 ...
- UE4 内容示例网络同步Learn
一, 1.1 Actor的复制 Actor中的Replicates ,为true时,服务器会把该Actor同步,显示在客户端中. 1.2 Switch Has Authority判断是客户端还是服务器 ...
- Use LiveCD to acquire images from a VM
Forensic examiners usually acquire images from suspect's PC or Laptop. What if the target computer i ...
- MySQL事务隔离级别的实现原理
回顾 在MySQL的众多存储引擎中,只有InnoDB支持事务,所有这里说的事务隔离级别指的是InnoDB下的事务隔离级别. 读未提交:一个事务可以读取到另一个事务未提交的修改.这会带来脏读.幻读.不可 ...
- iOS enum 定义与使用
枚举其实很重要,特别是在应用开发初期,服务器端数据格式需要更改得情况下,枚举和宏都能是程序简洁,并且改动小. 网上有个人写的言简意赅,适合初学 转自:http://blog.csdn.net/ysy4 ...
- <%=pageCount %>
<%=pageCount %>,这里是指获取页面控件的值.
- jQuery中foreach的continue和break
摘录自:http://blog.csdn.net/penginpha/article/details/12159389 1. continue. 可以使用return. $("***&quo ...
- MYSQL Nested Join Optimization
table_factor的语法和标准sql比较,后者只接受table_reference,每个逗号项都等于一个inner Join,e.g. SELECT * FROM t1 LEFT JOIN (t ...
- 修改ncnn的openmp异步处理方法 附C++样例代码
ncnn刚发布不久,博主在ios下尝试编译. 遇上了openmp的编译问题. 寻找各种解决方案无果,亲自操刀. 采用std::thread 替换 openmp. ncnn项目地址: https://g ...