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

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; }
  合理的脚本代码可以有效的提高工作效率,减少重复劳动。
  作者联系方式

深度聊聊微信微信,马上11岁了编辑导语作为一名国名APP,微信是我们每天必不可少的使用工具。作为一款产品,它也即将迎来自己的11岁。本篇文章中,作者从微信的历史踏过的坑和未来发展三个方面,全面分析了微信的前世今综合分析什么样的净水器更适合家用?净水器在今天可以说已经是家庭必不可少的家电,它能够保证家庭饮水健康问题,避免因为水污染危害健康。但是面临各种各样的净水器品类,我们应该怎么选择呢?比如超滤机纯水机前置净水器软水机加官方直降1300元,256GB2K曲面屏IP68防水,优质旗舰濒临下架声明原创不易,禁止搬运,违者必究!这个月的手机市场,可以说是非常热闹,多个手机厂商纷纷推出了新机,甚至还在同一天有几款新机出现。就比方说在12月22日,realme小米以及一加手机k50配置曝光?k40官方降价k50曝光了一些消息,当然随着手机消息越来越多,k40开始降价了,这个是需要关注的。简单看看吧。k50系列是这么使用处理器了,k50联发科版本,普通版使用天玑8000处理器,天玑92021清华校友物联网科创100发布各有关单位根据12月17日公示后,收到的各界反馈,2021清华校友物联网科创100在第二届全球清华校友物联网创新年会上予以正式发布,名录如下序号项目名称公司名称公司介绍1hr医众影曝谷歌PixelWatch智能手表最早2022年春季发布根据外媒9to5google报道,谷歌即将推出其首款智能手表PixelWatch,预计会搭载三星Exynos手表专用芯片。外媒从谷歌一款App的代码中发现,近期出现了PIXELEX市值将达5000亿美元!西媒起底光刻机巨头阿斯麦据西班牙经济学家报网站近日报道,虽然很多人对其知之甚少,但荷兰阿斯麦(ASML)公司却是几乎所有行业都赖以生存的技术巨头。该公司成立于1984年,现估值为3290亿美元,是世界上唯拿到近10亿元融资后,毫末智行想让产品3年覆盖100万台车记者鲁智高宣布获得近10亿元A轮融资次日,毫末智行又搞了个大动作。12月23日,毫末智行发布了自动驾驶数据智能体系MANA(中文名雪湖)。该数据智能体系由TARS(数据原型系统)L百公里油耗仅1L,零百加速5。9秒,13。69万起售,秦ProDM全面解析既想要环保省油,又想要澎湃动力,还担心纯电车型的续航,在这种需求之下,插电式混合动力车型无疑是更好的选择。环顾当前的车市,合资品牌在新能源领域普遍没有多少积淀。秦ProDM,作为比再见了TCP(TCP性能提升)摘要三次握手性能提升四次挥手性能提示数据传输性能提升三次握手性能提升三次握手性能提升主要通过以下方面调整SYN报文的重传次数调整SYN半连接队列的长度调整SYNACK报文的重传次数EffectiveC读书笔记15让operator返回this的引用前言C的设计者BjarneStroustrup下了很大功夫想使用户自定义类型尽可能地和固定类型的工作方式相似。这就是为什么我们可以重载运算符,写类型转换函数,控制赋值和拷贝构造函数
拼夕夕100多的手机能买?拆解后才知道有坑,网友可它能上王者从比官网便宜700的iPhone13Pro全新机没翻车,到华为手机给其换姓,再到自营店铺被曝销售改装机,近段时间拼夕夕可谓是风波不断。而网友也在吃瓜中了解到,原来拼夕夕上还能买手机我的桌面新宠海盗船K70键盘和Sabre鼠标,打造立体式光效系统进入了视频时代,看到很多视频UP主的桌面灯光都是绚烂缤纷,十分羡慕!小熊虽说只是业余的自媒体创作者,不想落后太多,也想拥有一个有沉浸式氛围感灯效的桌面。说干就干,于是在近期就完成下Android系统重磅更新,可运行Win11子系统Google正式发布Android12几个月后,终于把Pixel专属的核心功能MaterialYou开始下放给其他手机厂商了,感动。而随之Android13(代号提拉米苏)第一个开米博蒸烤烘炸一体机首发!智能烹饪新方式,一物多用解锁更多美味过了十五才算过完年,很多地方都有这样的说法!刚过去的元宵佳节,远在他乡学习打工的你,也会怀念和家人团圆的日子,尤其是妈妈烧得一手好菜。有亲人陪伴的地方就是家,吃吃喝喝成了大家开心相氧化锂资源超百万吨!我国科学家在喜马拉雅地区发现超大型锂矿作者倪思洁锂矿,素有白色石油之称,是一种极其稀有的白色轻金属资源。目前,我国锂资源75依靠进口。随着全球新能源产业的发展,锂资源需求量急剧增加。日前,记者从中国科学院地质与地球物理华为是怎么吸引国内外顶尖科学家的?这个阶段中国的民众特别关心华为公司的一些现状,超级大国打压是不是影响到了华为正常的运转,作为一个普通的民众不可能了解太多的内幕消息,但从央视面对面节目对于任正非的专访可以可以很多端摄影是决定电商成败的生命线为什么电商摄影很重要?对于电商行业来说,最大的挑战就是需要客户无法再亲眼看到产品或在手中检查产品之前就花钱购买你的产品。为了在电商销售中取得成功,你需要让你的客户清楚地了解你的产品每日感悟人类的未来在哪里天文学家预测十亿年后地球会被红超巨星太阳吞噬掉届时地球存不存在还是个问题。随着人类对地球环境的破坏,如果不加以制止和有效治理,人类很难在地球上在延续下一个5000千年文明史,更别说25号宇宙老鼠实验对人类的警示讲一个非常有意思的科学实验,看完之后你或许就能明白一些问题了。1947年,有位大学教授约翰B。卡尔洪(JohnB。Calhoun)进行了一个人口密度为课题的实验。约翰B卡尔洪(Jo比特币短周期级别反弹趋势已结束比特币行情分析(2022年2月19日)(看准我,不迷路如果你关注我转发我点赞我和评论我,你会暴富,不信你试试!)昨日复盘芒格虽然对加密货币不友好,但是对中国股市还是非常有好的,我们国产手机电脑的心脏和灵魂,95掌握在美国企业手中按照IDC的数据,2021年全球PC出货量达到了3。488亿台,相比2020年增长14。8,也是最近10年以来最高的出货量了。而这3。488亿台销量中,国产电脑表现还是不错的,联想