📉 Draggable Curve Control (English)

Conmajia 2012
Updated on Feb. 18, 2018

In Photoshop, there is a very powerful feature called 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;

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

原文地址:https://www.cnblogs.com/conmajia/p/8452407.html

时间: 2024-10-13 12:45:46

📉 Draggable Curve Control (English)的相关文章

『ENGLISH』

以A字母开头的词汇 英文 中文 abstract module 抽象模组 access 访问.存取 access control 存取控制 access control information 存取控制资讯 access mechanism 存取机制 access rights 存取权限 accessibility 无障碍性 accessibility information 无障碍网页资讯 accessibility problem 无障碍网页问题 accessible 无障碍的 access

Mysql DCL (Date Control Language)

Mysql DCL (Date Control Language) 数据库:mysql> select * from fen; +-------+-------+---------+ | name | china | english | +-------+-------+---------+ | ming | 69 | 99 | | hong | 48 | 33 | | qiang | 77 | 33 | +-------+-------+---------+ 3 rows in set (0.

A Complete ActiveX Web Control Tutorial

? Introduction ActiveX is a Microsoft technology developed in the mid 90's, that allows for the creation of applet-like applications that can be downloaded and run within Microsoft's Web browser. This article is intended for Visual C++ developers who

sublime text 3 环境变量的配置和安装Package Control

1.在运行里输入sysdm.cpl打开环境变量设置界面,输入sublime的安装目录,分号和之前的隔开 2.下载好Package Control,解压重命名为package control 下载地址:https://github.com/wbond/sublime_package_control 1.点击Preferences > Browse Packages菜单 2.进入打开的目录的上层目录,然后再进入Installed Packages/目录 3.将package control赋值到这里

Eng1&mdash;English daily notes

English daily notes 2015年 4月 Phrases 1. As a side note #作为附注,顺便说句题外话,和by the way意思相近,例句: @1:As a side note, there is no equivalent to tapply in the plyr package. 2. Across the range of #各种/各类/所有的,例句 @1:In order to improve all the mechanism, we' are l

Grid Control Agent无法配置成功的案例分享

最近在做GC的实验,在GC服务器上软件都顺利安装成功,OMS和自己上面的AGENT也都能够顺利启动,但是就是DB服务器的agent死活配置不成功,一直报错,找了半天也没有发现是什么原因.下面是部分实验过程: GC服务器: [[email protected] ~]# su - oracle [[email protected] ~]$ emctl status oms Oracle Enterprise Manager 10g Release 10.2.0.1.0 Copyright (c) 1

让你的English提高一个层次

  1.不要再用 more and more了:该词组被评为中国恶俗词组榜第一!!老师说..可以用a growing number of.. 2.inevitable..不可避免.. 3.should/would/could/may/might:为什么要用这个5个词?首先,语气比较委婉,不会很肯定,显的谦虚:其次,可以不考虑动词的形式:所以这五个词被称为最贱的词.. 4.physically beneficial身体健康:副词+形容词的表达方式,比较好看,接下来也会有举例: 5.worldwid

Convert BSpline Curve to Arc Spline in OpenCASCADE

Convert BSpline Curve to Arc Spline in OpenCASCADE [email protected] Abstract. The paper based on OpenCASCADE algorithms to approximate the NURBS curve to arc spline. The method is most useful in numerical control to drive the cutter along straight l

十几个remote control software

5 alternatives to LogMeIn Free for remote PC access VNC VNC, or Virtual Network Computing, isn’t itself a product, but an open-source remote-control and display technology that’s implemented by Tight VNC (free), Ultra VNC (free) and RealVNC (free and