文章目录
1.算法程序
- 1.算法程序
- 2.作者答疑
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
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?