您当前的位置: 首页 > 

插件开发

暂无认证

  • 5浏览

    0关注

    492博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

illustrator插件-常用功能开发-直角圆角化-js脚本开发-AI插件

插件开发 发布时间:2022-03-11 07:32:54 ,浏览量:5

文章目录
    • 1.算法程序
    • 2.作者答疑

1.算法程序

  illustrator是矢量编辑软件,画板是绘制处理的重要容器,在印刷方面的一个重要功能就是直角圆角化,开发一个直角圆角化功能,以下功能仅用于学习交流,请勿用于非法用途和商业用途,源代码如下所示:

// Round Any Corner
// rounds selected corners of PathItems.
// Especially for the corners at the intersection point of curves,
// this script may work better than "Round Corners" filter (but slower).

// ## How To Use

// ## Illustrator CS
//  1. Select the anchor(s) or whole path(es) to round.
//  2. Run this script. A prompt window appears to set the rounding radius.
//     Input the radius in point, then click OK.
//  #. You can choose a behavior like Illustrator10 by change the setting.
//     (-- see "setting" section below)

// ## Illustrator 10
//  1. Select the anchor(s) or whole path(es) to round
//     WITH a foreground path that specifies the rounding radius.
//     Half width of foreground path is used for the radius. (excluding stroke width)
//     Using a circle is most suitable for intuitive understanding and ease of use.
//     The script asks you to continue if there's a difference greater than 1 pt
//     between width and height of foreground path.
//  2. Run this script.  The foreground path is removed after rounding.
//  #. When the number of selected path is 1, predefined radius is used
//     for rounding. (-- see "setting" section below)

// ## Rounding Method
// Basically, the rounding method is compatible with the "Round Corners" filter.
// It is to add two anchors instead of the original anchor, at the points of
// specified line length from each selected corner.  So if there're too many
// anchors on original path, this script can not round nicely.

// ## Radius
// Actually, the specified "radius" is not for a radius of arcs which drawn.
// It is for the line length from each selected corner and is for the base
// to compute the length of handles.  The reason calling it "radius" is
// for compatibility with the "Round Corners" filter.


// This script does not round the corners which already rounded.
// (for example, select a circle and run this script does nothing)

// ### notice
// In the rounding process, the script merges anchors which nearly
// overlapped (when the distance between anchors is less than 0.05 points).

// This script does not work for some part of compound pathes.
// When this occurs, please select part of the compound path or release the compound path and
// select them, then run script again.
// I still have not figured out how to get properties from grouped pathes inside a compound path.

// JavaScript Script for Adobe Illustrator CS3
// Tested with Adobe Illustrator CS3 13.0.3, Windows XP SP2 (Japanese version).
// This script provided "as is" without warranty of any kind.
// Free to use and distribute.

// Change Log
// 2005-09-18 release on the web
// ...
// 2009-04-28 modified input part to accept unit and operator
// 2009-05-23 some refinements

var PMSLibs = confirm("此脚本会将路径直角调整为圆角\n--只会调整直角,路径不受任何影响(非软件自带效果可比)");
var ver10 = (version.indexOf('10') == 0);

roundAnyCorner();
function roundAnyCorner() {
    // setting ----------------------------------------------

    // -- rr : rounding radius ( unit : point )
    // ## on IllustratorCS, this value is for default value in prompt window.

    var rr = 10;

    // -- use_foreground_shape_to_set_radius
    // set this "true" to use half width of foreground path as rounding radius
    // instead of set the radius with prompt window.
    // ## on Illustrator10, this value is always true.

    var use_foreground_shape_to_set_radius = false; // set true or false

    // -- check_circle
    // when use_foreground_shape_to_set_radius = true, 
    // setting this "true", the script asks you to continue if there's a difference
    // greater than 1 pt between width and height of foreground path.
    // it only checks difference between width and height.

    var check_circle = true;

    // ------------------------------------------------------
    if (ver10) use_foreground_shape_to_set_radius = true;

    var s = [];
    getPathItemsInSelection(1, s); // extract pathItems which pathpoints length is greater than 1
    if (s.length             
关注
打赏
1665481431
查看更多评论
0.1461s