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)的更多相关文章

  1. 📟 Character Liquid Crystal Display Control (English)

    A replica CLCD module control. Initiated on May 5, 2012 Updated on Feb 21, 2017 Copyright 2012-2017 ...

  2. HTML5资料

    1 Canvas教程 <canvas>是一个新的用于通过脚本(通常是JavaScript)绘图的HTML元素.例如,他可以用于绘图.制作图片的组合或者简单的动画(当然并不那么简单).It ...

  3. Delphi XE2 之 FireMonkey 入门(14) - 滤镜: 概览

    相关单元: FMX.Filter FMX.FilterCatBlur FMX.FilterCatGeometry FMX.FilterCatTransition FMX_FilterCatColor ...

  4. javascript:Bing Maps AJAX Control, Version 7.0

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. 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 ...

  6. Java基础之在窗口中绘图——移动曲线的控制点(CurveApplet 3 moving the control points)

    Applet程序. import javax.swing.*; import java.awt.*; import java.awt.geom.*; import javax.swing.event. ...

  7. Java基础之在窗口中绘图——显示曲线的控制点(CurveApplet 2 displaying control points)

    Applet程序. import javax.swing.*; import java.awt.*; import java.awt.geom.*; @SuppressWarnings("s ...

  8. 越狱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 ...

  9. 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 ...

随机推荐

  1. TypeScript笔记 5--变量声明(解构和展开)

    解构是什么 解构(destructuring assignment)是一种表达式,将数组或者对象中的数据赋给另一变量. 在开发过程中,我们经常遇到这样问题,需要将对象某个属性的值赋给其它两个变量.代码 ...

  2. java的运算符和表达式

    )1.算数运算符:java中常用的算术运算符除了 +.-.*./之外,还有%(取余).++(自增).--(自减). )1.1%(取余):可适用于整数,char,浮点数的取余中.在取余中,如果进行运算的 ...

  3. debian 9 双显卡安装NVIDIA显卡驱动

    最近用debian,给debian装n卡驱动折腾了好几天了,主要还是网络不好,官方wiki的方法下载经常卡死..摸索了几天感觉已经摸到了头绪,决定写下来供大家参考参考 先提供单显卡NVIDIA驱动的安 ...

  4. lnmp14最新版

    系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian/Deepin Server/Aliyun/Amazon/Mint Linux发行版 需要5GB以上硬盘剩 ...

  5. gettype

    取得变量的类型. 语法: string gettype(mixed var); 返回值: 字符串 函数种类: PHP 系统功能 内容说明 本函数用来取得变量的类型.返回的类型字符串可能为下列字符串其中 ...

  6. YUM常用命令介绍

    http://www.cnblogs.com/lostyue/archive/2012/05/06/2485653.html 1.列出所有可更新的软件清单 命令:yum check-update 2. ...

  7. 豹哥嵌入式讲堂:ARM Cortex-M开发之文件详解(8)- 镜像文件(.bin/.hex/.s19)

    大家好,我是豹哥,猎豹的豹,犀利哥的哥.今天豹哥给大家讲的是嵌入式开发里的image文件(.bin, .hex, .s19). 今天这节课是豹哥<ARM Cortex-M开发之文件详解>主 ...

  8. Appium移动自动化测试之—基于java的iOS环境搭建

    本文仅供参考,同时感谢帮助我搭建环境的同事 操作系统的名称:Mac OS X操作系统的版本:10.12.6 接下来我们开始踏上搭建Appium+java+ios之路,本文只说个大概,毕竟本机已经装过了 ...

  9. nginx中location匹配顺序

    一.location语法 语法: Syntax: location [ = | ~ | ~* | ^~ ] uri { ... } location @name { ... } Default: - ...

  10. 前端之CSS介绍--选择器

    一.CSS简介 介绍 css我们称呼层叠样式表(英文全称:Cascading Style Sheets).它是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等 ...