📉 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 ...
随机推荐
- cesium编程入门(四)界面介绍及小控件隐藏
感性认识 界面介绍,viewer Geocoder : 查找位置工具,查找到之后会将镜头对准找到的地址,默认使用bing地图 Home Button :视角返回初始位置. Scene Mode Pic ...
- 10个html5增加的重要新特性和内容
文章开篇之前我们先了解一下什么是html5,百度上是这样定义html5的:万维网的核心语言.标准通用标记语言下的一个应用超文本标记语言(HTML)的第五次重大修改. 其实说白了html5也就是人为定义 ...
- docker运行dubbo-admin
一:简介 dubbo-admin是dubbo框架的管理平台. 二: 创建继续镜像 Dockerfile FROM fangjipu/jdk8:8 RUN yum -y install epel-rel ...
- PHP安全之webshell和后门检测
基于PHP的应用面临着各种各样的攻击: XSS:对PHP的Web应用而言,跨站脚本是一个易受攻击的点.攻击者可以利用它盗取用户信息.你可以配置Apache,或是写更安全的PHP代码(验证所有用户输入) ...
- HDU 4763 Theme Section
题目: It's time for music! A lot of popular musicians are invited to join us in the music festival. Ea ...
- python原始字符串
str1='let's go' File "<input>", line 1 str1='let's go' ^ SyntaxError: invalid syntax ...
- 怎么使用linux命令重启服务器
一下的命令都可以重启Linux服务器: 1.shutdown -r now 2.reboot 3.startx
- eclipse中如何同期化
打开MyEclipse8.0help->Software Updates->find and install(如果没有这个就用help->Software Updates->A ...
- 微信小程序实现顶部、底部联动滑动
这个场景一般用于展示数据时,数据过多,每条一行显示不下,表头可以横向滑动,下面要显示的数据部分横向纵向都可以滑动.表头或下面数据部分横向滑动的时候,两部分可以进行联动 具体效果像这样(随便写的丑样式布 ...
- jQuery --- 实现 checkbox 样式的单选框
早就想写点博客了 一直懒着动 最近发现一些写过的东西都不记得了,下决心把自己平时遇到的问题.得到的经验记录下来,希望能大家一点帮助 这是之前写的一个模态框 要求单选 但是 要求radio的默认样式 ...