范文健康探索娱乐情感热点
投稿投诉
热点动态
科技财经
情感日志
励志美文
娱乐时尚
游戏搞笑
探索旅游
历史星座
健康养生
美丽育儿
范文作文
教案论文

illustrator插件直角圆角化AI插件

  illustrator是矢量编辑软件,画板是绘制处理的重要容器,在印刷方面的一个重要功能就是直角圆角化,开发一个直角圆角化功能,以下功能仅用于学习交流,请勿用于非法用途和商业用途,源代码如下所示:var PMSLibs = confirm("此脚本会将路径直角调整为圆角 --只会调整直角,路径不受任何影响(非软件自带效果可比)"); 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 < 1) return;      // When use half width of foreground path as rounding radius     if (use_foreground_shape_to_set_radius) {         if (s.length < 2) {             // case : the number of selected path is 1             // ver10 -- round by predefined value             // CS -- ask radius by prompt window             if (!ver10) use_foreground_shape_to_set_radius = false;         } else {             // case : the number of selected path > 1             var pi = s.shift();      // remove foreground path from list of selection             var rr2 = getRadius(pi, check_circle); // get half width of it              if (rr2 < 0) return;              if (rr2 > 0) {                 rr = rr2;                 pi.remove();           // remove the path             } else {                 // case : the width of foreground path is 0                 // ver10 -- round by predefined value.  the foreground path remains.                 // CS -- ask radius by prompt window  the foreground path remains.                 if (!ver10) use_foreground_shape_to_set_radius = false;             }         }     }      if (!use_foreground_shape_to_set_radius) {         rr = prompt("输入圆角半径r-- 可以使用的单位有pt(默认)、mm、inr-- 也可以进行四则运算(+ - * /)", rr); // input the radius;          if (!rr) return;          rr = rr.replace(/mm/ig, "*2.83464567");         rr = rr.replace(/pt/ig, "");         rr = rr.replace(/in/ig, "*72");         rr = rr.replace(/s+/g, "");          try {             var eval_rr = eval(rr);         } catch (e) {             alert("ERROR: " + e.description);             return;         }          if (isNaN(eval_rr) || eval_rr <= 0) {             alert(" 警告:错误的四则计算公式!计算结果必须为正值。");             return;         }          rr = eval_rr;     }      //var tim = new Date();     var p, op, pnts;     var skipList, adjRdirAtEnd, redrawFlg;     var i, nxi, pvi, q, d, ds, r, g, t, qb;     var anc1, ldir1, rdir1, anc2, ldir2, rdir2;      var hanLen = 4 * (Math.sqrt(2) - 1) / 3;     var ptyp = PointType.SMOOTH;      for (var j = 0; j < s.length; j++) {         p = s[j].pathPoints;         if (readjustAnchors(p) < 2) continue; // reduce anchors         op = !s[j].closed;         pnts = op ? [getDat(p[0])] : [];         redrawFlg = false;         adjRdirAtEnd = 0;          skipList = [(op || !isSelected(p[0]) || !isCorner(p, 0))];         for (i = 1; i < p.length; i++) {             skipList.push((!isSelected(p[i])                 || !isCorner(p, i)                 || (op && i == p.length - 1)));         }          for (i = 0; i < p.length; i++) {             nxi = parseIdx(p, i + 1);             if (nxi < 0) break;              pvi = parseIdx(p, i - 1);              q = [p[i].anchor, p[i].rightDirection,                 p[nxi].leftDirection, p[nxi].anchor];              ds = dist(q[0], q[3]) / 2;             if (arrEq(q[0], q[1]) && arrEq(q[2], q[3])) {  // straight side                 r = Math.min(ds, rr);                 g = getRad(q[0], q[3]);                 anc1 = getPnt(q[0], g, r);                 ldir1 = getPnt(anc1, g + Math.PI, r * hanLen);                  if (skipList[nxi]) {                     if (!skipList[i]) {                         pnts.push([anc1, anc1, ldir1, ptyp]);                         redrawFlg = true;                     }                     pnts.push(getDat(p[nxi]));                 } else {                     if (r < rr) {  // when the length of the side is less than rr * 2                         pnts.push([anc1,                             getPnt(anc1, getRad(ldir1, anc1), r * hanLen),                             ldir1,                             ptyp]);                     } else {                         if (!skipList[i]) pnts.push([anc1, anc1, ldir1, ptyp]);                         anc2 = getPnt(q[3], g + Math.PI, r);                         pnts.push([anc2,                             getPnt(anc2, g, r * hanLen),                             anc2,                             ptyp]);                     }                     redrawFlg = true;                 }             } else {  // not straight side                 d = getT4Len(q, 0) / 2;                 r = Math.min(d, rr);                 t = getT4Len(q, r);                 anc1 = bezier(q, t);                 rdir1 = defHan(t, q, 1);                 ldir1 = getPnt(anc1, getRad(rdir1, anc1), r * hanLen);                  if (skipList[nxi]) {                     if (skipList[i]) {                         pnts.push(getDat(p[nxi]));                     } else {                         pnts.push([anc1, rdir1, ldir1, ptyp]);                         with (p[nxi]) pnts.push([anchor,                             rightDirection,                             adjHan(anchor, leftDirection, 1 - t),                             ptyp]);                         redrawFlg = true;                     }                 } else { // skipList[nxi] = false                     if (r < rr) {  // the length of the side is less than rr * 2                         if (skipList[i]) {                             if (!op && i == 0) {                                 adjRdirAtEnd = t;                             } else {                                 pnts[pnts.length - 1][1] = adjHan(q[0], q[1], t);                             }                             pnts.push([anc1,                                 getPnt(anc1, getRad(ldir1, anc1), r * hanLen),                                 defHan(t, q, 0),                                 ptyp]);                         } else {                             pnts.push([anc1,                                 getPnt(anc1, getRad(ldir1, anc1), r * hanLen),                                 ldir1,                                 ptyp]);                         }                     } else {  // round the corner with the radius rr                         if (skipList[i]) {                             t = getT4Len(q, -r);                             anc2 = bezier(q, t);                              if (!op && i == 0) {                                 adjRdirAtEnd = t;                             } else {                                 pnts[pnts.length - 1][1] = adjHan(q[0], q[1], t);                             }                              ldir2 = defHan(t, q, 0);                             rdir2 = getPnt(anc2, getRad(ldir2, anc2), r * hanLen);                              pnts.push([anc2, rdir2, ldir2, ptyp]);                         } else {                             qb = [anc1, rdir1, adjHan(q[3], q[2], 1 - t), q[3]];                             t = getT4Len(qb, -r);                             anc2 = bezier(qb, t);                             ldir2 = defHan(t, qb, 0);                             rdir2 = getPnt(anc2, getRad(ldir2, anc2), r * hanLen);                             rdir1 = adjHan(anc1, rdir1, t);                              pnts.push([anc1, rdir1, ldir1, ptyp],                                 [anc2, rdir2, ldir2, ptyp]);                         }                     }                     redrawFlg = true;                 }             }         }         if (adjRdirAtEnd > 0) {             pnts[pnts.length - 1][1] = adjHan(p[0].anchor, p[0].rightDirection, adjRdirAtEnd);         }          if (redrawFlg) {             // redraw             for (i = p.length - 1; i > 0; i--) p[i].remove();              for (i = 0; i < pnts.length; i++) {                 pt = i > 0 ? p.add() : p[0];                 with (pt) {                     anchor = pnts[i][0];                     rightDirection = pnts[i][1];                     leftDirection = pnts[i][2];                     pointType = pnts[i][3];                 }             }         }     }     activeDocument.selection = s;     // alert(new Date() - tim); }  // ------------------------------------------------ function getRadius(pi, check_circle) {     with (pi) {         var gb = geometricBounds;         var w = (gb[2] - gb[0]);         var h = (gb[1] - gb[3]);         if (check_circle && Math.abs(w - h) > 1             && !confirm("There"s a difference between width and "                 + "height of foreground path. Continue?")) {             return -1;         }         return w / 2;     } }  // ------------------------------------------------ // return [x,y] of the distance "len" and the angle "rad"(in radian) // from "pt"=[x,y] function getPnt(pt, rad, len) {     return [pt[0] + Math.cos(rad) * len,         pt[1] + Math.sin(rad) * len]; }  // ------------------------------------------------ // return the [x, y] coordinate of the handle of the point on the bezier curve // that corresponds to the parameter "t" // n=0:leftDir, n=1:rightDir function defHan(t, q, n) {     return [t * (t * (q[n][0] - 2 * q[n + 1][0] + q[n + 2][0]) + 2 * (q[n + 1][0] - q[n][0])) + q[n][0],         t * (t * (q[n][1] - 2 * q[n + 1][1] + q[n + 2][1]) + 2 * (q[n + 1][1] - q[n][1])) + q[n][1]]; }  // ----------------------------------------------- // return the [x, y] coordinate on the bezier curve // that corresponds to the paramter "t" function bezier(q, t) {     var u = 1 - t;     return [u * u * u * q[0][0] + 3 * u * t * (u * q[1][0] + t * q[2][0]) + t * t * t * q[3][0],         u * u * u * q[0][1] + 3 * u * t * (u * q[1][1] + t * q[2][1]) + t * t * t * q[3][1]]; }  // ------------------------------------------------ // adjust the length of the handle "dir" // by the magnification ratio "m", // returns the modified [x, y] coordinate of the handle // "anc" is the anchor [x, y] function adjHan(anc, dir, m) {     return [anc[0] + (dir[0] - anc[0]) * m,         anc[1] + (dir[1] - anc[1]) * m]; }  // ------------------------------------------------ // return true if the pathPoints "p[idx]" is a corner function isCorner(p, idx) {     var pnt0 = getAnglePnt(p, idx, -1);     var pnt1 = getAnglePnt(p, idx, 1);     if (!pnt0 || !pnt1) return false;                    // at the end of a open-path     if (pnt0.length < 1 || pnt1.length < 1) return false;   // anchor is overlapping, so cannot determine the angle     var rad = getRad2(pnt0, p[idx].anchor, pnt1, true);     if (rad > Math.PI - 0.1) return false;   // set the angle tolerance here     return true; }  // ------------------------------------------------ // "p"=pathPoints, "idx1"=index of pathpoint // "dir" = -1, returns previous point [x,y] to get the angle of tangent at pathpoints[idx1] // "dir" =  1, returns next ... function getAnglePnt(p, idx1, dir) {     if (!dir) dir = -1;     var idx2 = parseIdx(p, idx1 + dir);     if (idx2 < 0) return null;  // at the end of a open-path     var p2 = p[idx2];     with (p[idx1]) {         if (dir < 0) {             if (arrEq(leftDirection, anchor)) {                 if (arrEq(p2.anchor, anchor)) return [];                 if (arrEq(p2.anchor, p2.rightDirection)                     || arrEq(p2.rightDirection, anchor)) return p2.anchor;                 else return p2.rightDirection;             } else {                 return leftDirection;             }         } else {             if (arrEq(anchor, rightDirection)) {                 if (arrEq(anchor, p2.anchor)) return [];                 if (arrEq(p2.anchor, p2.leftDirection)                     || arrEq(anchor, p2.leftDirection)) return p2.anchor;                 else return p2.leftDirection;             } else {                 return rightDirection;             }         }     } }  // -------------------------------------- // if the contents of both arrays are equal, return true (lengthes must be same) function arrEq(arr1, arr2) {     for (var i = 0; i < arr1.length; i++) {         if (arr1[i] != arr2[i]) return false;     }     return true; }  // ------------------------------------------------ // return the distance between p1=[x,y] and p2=[x,y] function dist(p1, p2) {     return Math.sqrt(Math.pow(p1[0] - p2[0], 2)         + Math.pow(p1[1] - p2[1], 2)); }  // ------------------------------------------------ // return the squared distance between p1=[x,y] and p2=[x,y] function dist2(p1, p2) {     return Math.pow(p1[0] - p2[0], 2)         + Math.pow(p1[1] - p2[1], 2); }  // -------------------------------------- // return the angle in radian // of the line drawn from p1=[x,y] from p2 function getRad(p1, p2) {     return Math.atan2(p2[1] - p1[1],         p2[0] - p1[0]); }  // -------------------------------------- // return the angle between two line segments // o-p1 and o-p2 ( 0 - Math.PI) function getRad2(p1, o, p2) {     var v1 = normalize(p1, o);     var v2 = normalize(p2, o);     return Math.acos(v1[0] * v2[0] + v1[1] * v2[1]); }  // ------------------------------------------------ function normalize(p, o) {     var d = dist(p, o);     return d == 0 ? [0, 0] : [(p[0] - o[0]) / d,         (p[1] - o[1]) / d]; }  // ------------------------------------------------ // return the bezier curve parameter "t" // at the point which the length of the bezier curve segment // (from the point start drawing) is "len" // when "len" is 0, return the length of whole this segment. function getT4Len(q, len) {     var m = [q[3][0] - q[0][0] + 3 * (q[1][0] - q[2][0]),         q[0][0] - 2 * q[1][0] + q[2][0],         q[1][0] - q[0][0]];     var n = [q[3][1] - q[0][1] + 3 * (q[1][1] - q[2][1]),         q[0][1] - 2 * q[1][1] + q[2][1],         q[1][1] - q[0][1]];     var k = [m[0] * m[0] + n[0] * n[0],         4 * (m[0] * m[1] + n[0] * n[1]),         2 * ((m[0] * m[2] + n[0] * n[2]) + 2 * (m[1] * m[1] + n[1] * n[1])),         4 * (m[1] * m[2] + n[1] * n[2]),         m[2] * m[2] + n[2] * n[2]];      var fullLen = getLength(k, 1);      if (len == 0) {         return fullLen;      } else if (len < 0) {         len += fullLen;         if (len < 0) return 0;      } else if (len > fullLen) {         return 1;     }      var t, d;     var t0 = 0;     var t1 = 1;     var torelance = 0.001;      for (var h = 1; h < 30; h++) {         t = t0 + (t1 - t0) / 2;         d = len - getLength(k, t);         if (Math.abs(d) < torelance) break;         else if (d < 0) t1 = t;         else t0 = t;     }     return t; }  // ------------------------------------------------ // return the length of bezier curve segment // in range of parameter from 0 to "t" function getLength(k, t) {     var h = t / 128;     var hh = h * 2;     var fc = function (t, k) {         return Math.sqrt(t * (t * (t * (t * k[0] + k[1]) + k[2]) + k[3]) + k[4]) || 0     };     var total = (fc(0, k) - fc(t, k)) / 2;     for (var i = h; i < t; i += hh) total += 2 * fc(i, k) + fc(i + h, k);     return total * hh; }  // ------------------------------------------------ // extract PathItems from the selection which length of PathPoints // is greater than "n" function getPathItemsInSelection(n, pathes) {     if (documents.length < 1) return;     var s = activeDocument.selection;     if (!(s instanceof Array) || s.length < 1) return;     extractPathes(s, n, pathes); }  // -------------------------------------- // extract PathItems from "s" (Array of PageItems -- ex. selection), // and put them into an Array "pathes".  If "pp_length_limit" is specified, // this function extracts PathItems which PathPoints length is greater // than this number. function extractPathes(s, pp_length_limit, pathes) {     for (var i = 0; i < s.length; i++) {         if (s[i].typename == "PathItem") {             if (pp_length_limit                 && s[i].pathPoints.length <= pp_length_limit) {                 continue;             }             pathes.push(s[i]);          } else if (s[i].typename == "GroupItem") {             // search for PathItems in GroupItem, recursively             extractPathes(s[i].pageItems, pp_length_limit, pathes);          } else if (s[i].typename == "CompoundPathItem") {             // searches for pathitems in CompoundPathItem, recursively             // ( ### Grouped PathItems in CompoundPathItem are ignored ### )             extractPathes(s[i].pathItems, pp_length_limit, pathes);         }     } }  // -------------------------------------- // merge nearly overlapped anchor points  // return the length of pathpoints after merging function readjustAnchors(p) {     // Settings ==========================      // merge the anchor points when the distance between     // 2 points is within ### square root ### of this value (in point)     var minDist = 0.0025;      // ===================================     if (p.length < 2) return 1;     var i;      if (p.parent.closed) {         for (i = p.length - 1; i >= 1; i--) {             if (dist2(p[0].anchor, p[i].anchor) < minDist) {                 p[0].leftDirection = p[i].leftDirection;                 p[i].remove();             } else {                 break;             }         }     }      for (i = p.length - 1; i >= 1; i--) {         if (dist2(p[i].anchor, p[i - 1].anchor) < minDist) {             p[i - 1].rightDirection = p[i].rightDirection;             p[i].remove();         }     }      return p.length; }  // ----------------------------------------------- // return pathpoint"s index. when the argument is out of bounds, // fixes it if the path is closed (ex. next of last index is 0), // or return -1 if the path is not closed. function parseIdx(p, n) { // PathPoints, number for index     var len = p.length;     if (p.parent.closed) {         return n >= 0 ? n % len : len - Math.abs(n % len);     } else {         return (n < 0 || n > len - 1) ? -1 : n;     } }  // ----------------------------------------------- function getDat(p) { // pathPoint     with (p) return [anchor, rightDirection, leftDirection, pointType]; }  // ----------------------------------------------- function isSelected(p) { // PathPoint     return p.selected == PathPointSelection.ANCHORPOINT; }
  合理的脚本代码可以有效的提高工作效率,减少重复劳动。
  作者联系方式

华为注册鲁班商标近日,据了解,在天眼查App显示,华为技术有限公司再次申请注册鲁班商标,注册号56255833,国际分类为科学仪器。目前商标状态为商标申请中。值得一提的是,此前华为已申请注册鲁班华能否说一说你一直不舍得抛弃的相机,为什么?玩了大半辈子摄影,手里积攒了十多部相机,其中有老式胶片机新型数码单反微单,还有小卡片机。现在还能服役的,只剩下4部了,这里面佳能7D已经使用10年,5DIII使用8年,索尼A7RI不用手机卡和wifi也能上网?(请关注本号,以免错过好文章)特斯拉最近是个热门话题,想必在维权事件之前很多人并不知道特斯拉是个什么玩意儿,可是现在特斯拉已经家喻户晓了,看来被维权可能也并不是坏事,就像明星的绯闻三星GalaxyA03s新品曝光,廉价入门机型据外媒gsmarena报道,三星GalaxyA02s的替代品部分配置信息曝光,预计被称为三星GalaxyA03s。外媒表示,三星GalaxyA03s将会配备6。5英寸LCD屏幕,采中兴曾经的巨头,如今成山寨机被下架这两天正值618电商节刚开始,各大平台和手机厂商都在进行活动大促,一个劲儿给自家品牌产品做广告,做销售,降售价忙得不亦乐乎。而就在前不久,同样是做直播销售的视频APP快手发布一则公英国彻底排除华为后,美国被公开警告,华为中兴被邀请现身说法最近,大家应该有所了解,因为瑞典的不中立,坚持将华为5G排除在外,于是最近国内的三大运营商的5G相关招标,华为中兴中了大部分份额,爱立信却颗粒无收。这不仅是我们的反击,也是实力所在建好通信塔打造数字塔,助力江苏数字化转型走在前列近年来,江苏数字经济呈现规模增长迅速发展势头强劲之态,据最新统计数据显示,日前江苏数字经济规模超4万亿元,位居全国第二。诞生于落实网络强国战略深化国企改革促进电信基础设施资源共享的我国快递业霸主诞生营收力压三通一达及顺丰,成功挤进全球前三我国电商行业的发展不仅带动了经济的增长,还带动了其他相关行业的发展,电子商务平台发展好了会对上下游企业都有很好的促进作用。就比如快递行业从无到有,再到如今的多元化发展,这个过程离不上手体验了三款顶级旗舰后,我选择下单一加9Pro从年初时,小编就一直想换掉自己手上的手机,无奈今年的好旗舰有太多,竟然有点挑花了眼(其实是钱不够)。此前计划了一两个月时间了,这次碰上618就准备直接一步到位。今天恰逢周末,上午抽胜利油田首批155辆,马上投入使用胜利油田首批投入使用的155辆新能源汽车整齐停放在车辆管理中心停车场计划到2023年末力争更新1500台新能源车辆绿色油田新能源节能减排提升降碳效益首批155辆新能源车辆车型通过计老美始料不及,华为海思惊喜不断重磅消息,老美差点儿吓坏了小心脏,到底发生了什么呢?老妹以为啊在自己强悍的阻挠之下,华为海思会被彻底打败。不料近期却突然传出了三大惊喜,究竟是哪三大惊喜呢?惊喜1为了帮助推广鸿蒙系
会计继续教育,暂停!有财政厅通知了2021年会计人员继续教育陆续开展中。近日,有财政厅发布通知暂停会计人员线下形式的继续教育还有财政局通知鼓励通过线上完成继续教育!详情如下。1hr陕西财政厅会计人员继续教育暂停陕西个人所得税,免征!今起,这33种情况通通不用再交个人所得税了个人所得税与我们企业和个人都息息相关,今天给大家整理了最全33种免征个人所得税知识点,大家读完这篇文章可以收藏发给朋友,以后遇到个税问题也能从容应对。1个人所得税最新税率表来了!建企业所得税,降了!小微企业税负将低至2。5,又可以少交税了刚刚,两会传来最新消息,企业所得税又要降了!即日起,这是最新最全税率表!小微企业重大利好税负或将低至2。5!刚刚,政府工作报告说了这项重大优惠!对小微企业和个体工商户年应纳税所得额涨钱了!4月1日起,月薪不到这个数,单位违法新年涨钱了!近日,江西黑龙江陕西等多个省份宣布上调2021年最低工资标准,还有一些地方也确定上涨并在酝酿上涨方案。打工人,看看你能涨多少钱?多地宣布上调最低工资标准部分地区明确表示涨钱了!4月1日起,月薪不到这个数,单位违法!多地发布通知新年涨钱了!近日,江西黑龙江陕西等多个省份宣布上调2021年最低工资标准,还有一些地方也确定上涨并在酝酿上涨方案。打工人,看看你能涨多少钱?多地宣布上调最低工资标准部分地区明确表示突发!个税变了!4月1日正式执行日前,税局正式发布通知,个税预征率调至1。5!具体内容,快一起来看看吧01hr个税1。5预征率4月1日起执行!划重点1在天津市范围内临时从事生产经营的零散税收纳税人在代开增值税发票多数英国人不愿减薪每周工作四天,只有10员工赞成工作四天据卫报,根据跨党派智库社会市场基金会(SMF)的研究,在收入同比减少情况下,80英国员工不赞成减少工作时间,只有10员工赞成。白领和高薪工作的人最愿意减薪减少工作时间,护理人员和酒独生子女不能直接继承父母房产?2021年起,房产继承有新规父母该如何分配房产?房产继承新规必须了解。2019年3月12日,不动产登记办理时间不动产权证。2021年起,继承父母房产,统统按新规处置,再闹也没用!继承父母房产新规新的民法典将从外边打印1块,在家打印1分这还不是选择米家喷墨打印机的理由?打印是工作生活和学习过程中不必可少的工具,但如果你没被打印这事为难过,我打死都不信。在大学校园附近上学和生活的小伙伴确实可以找到性价比较高的打印店,虽然质感一般,好赖可以用便宜的价东风标致全新4008的三大首选理由拿到驾照后,让人激动的就是买车了。然而,当各种车型参数,科技配置出现在眼前时,萌新们总会迷糊,到底什么车适合拿来练手呢?不妨,让我们按新手上路急需的培养车感为出发点,来筛选。毕竟汽东风标致全新4008的三大首选理由拿到驾照后,让人激动的就是买车了。然而,当各种车型参数,科技配置出现在眼前时,萌新们总会迷糊,到底什么车适合拿来练手呢?不妨,让我们按新手上路急需的培养车感为出发点,来筛选。毕竟汽