aijs 盒子出血

news2024/10/6 20:33:42

效果演示

盒子出血演示

1.左下点

在这里插入图片描述

2.左上点

在这里插入图片描述

3.上左点

在这里插入图片描述

var doc = activeDocument;
var pt = 72 / 25.4;
var cx = 3 * pt;

var marks = [];
for (var i = 0; i < doc.selection.length; i++) {
    var shape = doc.selection[i];
    if (shape.typename == 'GroupItem' && shape.pageItems.length > 0) {
        if (shape.clipped) {
            //这里蒙版的判断有点懵逼   下面应该能获取2层
            var sh = shape.pageItems[0];
            if (sh.pageItems && sh.pageItems.length > 0) {
                sh = sh.pageItems[0];
            }
            marks.push(sh)
        }
    }
}

var results = []
for (var i = 0; i < marks.length; i++) {
    results.push(checkShapeBounds(marks[i], marks,0.1));
}

for(var i=0;i<marks.length;i++){
    var result = results[i];
    new Main(marks[i],
        result.left, result.leftBottom, result.leftTop,
        result.top, result.topLeft, result.topRight,
        result.right, result.rightTop, result.rightBottom,
        result.bottom, result.bottomLeft, result.bottomRight
    ).work();
}


//判断 图形周围是不是有图形
function checkShapeBounds(shape, shapes, tolerance) {
    var result = {
        left: false,
        leftBottom:false,
        leftTop:false,
        top: false,
        topLeft: false,
        topRight: false,
        bottom: false,
        bottomLeft: false,
        bottomRight: false,
        right: false,
        rightTop: false,
        rightTopCount: 0,
        rightBottom: false,
    };
    var bounds = shape.geometricBounds;
    /**
     * 线重合
     */
    for (var i = 0; i < shapes.length; i++) {
        var otherShape = shapes[i];
        str+=otherShape.geometricBounds[0]+","+otherShape.geometricBounds[1]+","+otherShape.geometricBounds[2]+","+otherShape.geometricBounds[3]+"\n"
        if (otherShape === shape) {
            continue; // 跳过当前形状
        }
        var otherBounds = otherShape.geometricBounds;
        var leftLine = Math.abs(bounds[0] - otherBounds[0]) < tolerance;
        var rightLine = Math.abs(bounds[2] - otherBounds[2]) < tolerance;
        var topLine = Math.abs(bounds[1] - otherBounds[1]) < tolerance;
        var bottomLine = Math.abs(bounds[3] - otherBounds[3]) < tolerance;

        if(topLine && bottomLine){
            if ( Math.abs(otherBounds[2] - bounds[0]) < tolerance) {
                result.left = true;
            }
            if (Math.abs(otherBounds[0] - bounds[2]) < tolerance) {
                result.right = true;
            }
        }
        if(leftLine&&rightLine){
            if (Math.abs(otherBounds[3] - bounds[1]) < tolerance) {
                result.top = true;
            }
            if (Math.abs(otherBounds[1] - bounds[3]) < tolerance) {
                result.bottom = true;
            }
        }
    }
    /**
     * 线 三边是否有内容
     */
    for (var i = 0; i < shapes.length; i++) {
        var otherShape = shapes[i];
        if (otherShape === shape) {
            continue; // 跳过当前形状
        }
        var otherBounds = otherShape.geometricBounds;
        var left = Math.abs(otherBounds[2] - bounds[0]) < tolerance;
        var right = Math.abs(otherBounds[0] - bounds[2]) < tolerance;
        var bottom = Math.abs(otherBounds[1] - bounds[3]) < tolerance;
        var top = Math.abs(otherBounds[3] - bounds[1]) < tolerance;

        if(result.left&&left&&top){
            result.topLeft= true;
        }
        if(result.left&&left&&bottom){
            result.bottomLeft= true;
        }

        if(result.right&&right&&top){
            result.topRight= true;
        }
        if(result.right&&right&&bottom){
            result.bottomRight= true;
        }


        if(result.bottom&&bottom&&right){
            result.rightBottom= true;
        }
        if(result.bottom&&bottom&&left){
            result.leftBottom= true;
        }

        if(result.top&&top&&right){
            result.rightTop= true;
        }
        if(result.top&&top&&left){
            result.leftTop= true;
        }

    }
    result.left =!result.left;
    result.top =!result.top;
    result.bottom =!result.bottom;
    result.right =!result.right;
    return result;
}



/**
 * 下面是 7个 位置的 代码
 var main = new Main(shape, true, false, false, false, false, false, false, false, false, true, false, false).work();//1
 var main = new Main(shape, false, false, false, true, true, true, false, false, true, true, true, true).work();//2
 var main = new Main(shape, false, false, false, false, false, false, false, false, false, false, false, false).work();//3
 var main = new Main(shape, false, false, false, true, true, false, false, false, false, true, true, false).work();//4
 var main = new Main(shape, true, true, false, true, false, false, true, false, true, false, false, false).work();//5
 var main = new Main(shape, true, true, false, true, false, false, true, false, true, false, false, false).work();//6
 var main = new Main(shape, true, false, true, false, false, false, true, true, false, true, false, false).work();//7
 * @param shape
 * @param left
 * @param leftBottom
 * @param leftTop
 * @param top
 * @param topLeft
 * @param topRight
 * @param right
 * @param rightTop
 * @param rightBottom
 * @param bottom
 * @param bottomLeft
 * @param bottomRight
 * @constructor
 */
function Main(shape, left, leftBottom, leftTop, top, topLeft, topRight, right, rightTop, rightBottom, bottom, bottomLeft, bottomRight) {
    var rect = new Rect(shape.geometricBounds);
    this.left = left;
    this.leftTop = leftTop;
    this.leftBottom = leftBottom;
    this.top = top;
    this.topLeft = topLeft;
    this.topRight = topRight;
    this.right = right;
    this.rightBottom = rightBottom;
    this.rightTop = rightTop;
    this.bottom = bottom;
    this.bottomLeft = bottomLeft;
    this.bottomRight = bottomRight;
    this.x1 = rect.x1;
    this.y1 = rect.y1;
    this.x2 = rect.x2;
    this.y2 = rect.y2;
    this.paths = [];
    this.shape = shape;

    function computeNode() {
        //左下
        if (this.left) {
            if (this.leftBottom) {
                this.paths.push([this.x1, this.y1])
                this.paths.push([this.x1 - cx, this.y1 + cx])
            } else {
                if (this.bottom) {
                    if (!this.bottomLeft) {
                        this.paths.push([this.x1 - cx, this.y1 - cx])
                    }
                } else {
                    this.paths.push([this.x1 - cx, this.y1])
                }
            }
        } else {
            if (this.bottom && !this.bottomLeft) {
                this.paths.push([this.x1, this.y1 - cx])
            } else {
                this.paths.push([this.x1, this.y1])
            }

        }
        //左上
        if (this.left) {
            if (this.leftTop) {
                this.paths.push([this.x1 - cx, this.y2 - cx])
                this.paths.push([this.x1, this.y2])
            } else {
                if (this.top) {
                    if (!this.topLeft) {
                        this.paths.push([this.x1 - cx, this.y2 + cx])
                    }
                } else {
                    this.paths.push([this.x1 - cx, this.y2])
                }
            }
        } else {
            if (this.top && !this.topLeft) {
                this.paths.push([this.x1, this.y2 + cx])
            } else {
                this.paths.push([this.x1, this.y2])
            }

        }
        //上左
        if (this.top) {
            if (this.topLeft) {
                this.paths.push([this.x1, this.y2])
                this.paths.push([this.x1 + cx, this.y2 + cx])

            } else {
                if (this.left) {
                    if (!this.leftTop) {
                        this.paths.push([this.x1 - cx, this.y2 + cx])
                    }
                } else {
                    this.paths.push([this.x1, this.y2 + cx])
                }
            }
        } else {
            if (this.left && !this.leftTop) {
                this.paths.push([this.x1 - cx, this.y2])
            } else {
                this.paths.push([this.x1, this.y2])
            }

        }
        //上右
        if (this.top) {
            if (this.topRight) {
                this.paths.push([this.x2 - cx, this.y2 + cx])
                this.paths.push([this.x2, this.y2])
            } else {
                if (this.right) {
                    if (!this.rightTop) {
                        this.paths.push([this.x2 + cx, this.y2 + cx])
                    }
                } else {
                    this.paths.push([this.x2, this.y2 + cx])
                }
            }
        } else {
            if (this.right && !this.rightTop) {
                this.paths.push([this.x2 + cx, this.y2])
            } else {
                this.paths.push([this.x2, this.y2])
            }

        }

        //右上
        if (this.right) {
            if (this.rightTop) {
                this.paths.push([this.x2, this.y2])
                this.paths.push([this.x2 + cx, this.y2 - cx])

            } else {
                if (this.top) {
                    if (!this.topRight) {
                        this.paths.push([this.x2 + cx, this.y2 + cx])
                    }
                } else {
                    this.paths.push([this.x2 + cx, this.y2])
                }
            }
        } else {
            if (this.top && !this.topRight) {
                this.paths.push([this.x2, this.y2 + cx])
            } else {
                this.paths.push([this.x2, this.y2])
            }

        }

        //右下
        if (this.right) {
            if (this.rightBottom) {
                this.paths.push([this.x2 + cx, this.y1 + cx])
                this.paths.push([this.x2, this.y1])
            } else {
                if (this.bottom) {
                    if (!this.bottomRight) {
                        this.paths.push([this.x2 + cx, this.y1 - cx])
                    }
                } else {
                    this.paths.push([this.x2 + cx, this.y1])
                }
            }
        } else {
            if (this.bottom && !this.bottomRight) {
                this.paths.push([this.x2, this.y1 - cx])
            } else {
                this.paths.push([this.x2, this.y1])
            }

        }

        //下右
        if (this.bottom) {
            if (this.bottomRight) {
                this.paths.push([this.x2, this.y1])
                this.paths.push([this.x2 - cx, this.y1 - cx])

            } else {
                if (this.right) {
                    if (!this.rightBottom) {
                        this.paths.push([this.x2 + cx, this.y1 - cx])
                    }
                } else {
                    this.paths.push([this.x2, this.y1 - cx])
                }
            }
        } else {
            if (this.right && !this.rightBottom) {
                this.paths.push([this.x2 + cx, this.y1])
            } else {
                this.paths.push([this.x2, this.y1])
            }

        }

        //下左
        if (this.bottom) {
            if (this.bottomLeft) {
                this.paths.push([this.x1 + cx, this.y1 - cx])
                this.paths.push([this.x1, this.y1])
            } else {
                if (this.left) {
                    if (!this.leftBottom) {
                        this.paths.push([this.x1 - cx, this.y1 - cx])
                    }
                } else {
                    this.paths.push([this.x1, this.y1 - cx])
                }
            }
        } else {
            if (this.left && !this.leftBottom) {
                this.paths.push([this.x1 - cx, this.y1])
            } else {
                this.paths.push([this.x1, this.y1])
            }
        }
    }

    function addNodesToMask() {
// 添加节点到其他节点上
        for (var i = sh.pathPoints.length; i < this.paths.length; i++) {
            this.shape.pathPoints.add();
        }
        //修改节点的坐标
        for (var i = 0; i < this.paths.length; i++) {
            this.shape.pathPoints[i].anchor = this.paths[i];
            this.shape.pathPoints[i].leftDirection = this.paths[i];
            this.shape.pathPoints[i].rightDirection = this.paths[i];
        }
    }

    this.work = function () {
        computeNode.call(this);
        addNodesToMask.call(this);
    }
    function Rect(bounds) {
        this.x1 = bounds[0];
        this.y1 = bounds[3];
        this.x2 = bounds[2];
        this.y2 = bounds[1];
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/851676.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

2023年深度学习最新研究成果

LLMs领域 AGI领域 无剑芯片设计平台 三级标题 四级标题 五级标题 六级标题

使用fopen等标准C库来操作文件

fopen 需要的头文件&#xff1a; #include <stdio.h> 函数原型&#xff1a; FILE *fopen(const char *pathname, const char *mode); 参数&#xff1a; pathname: 文件路径mode: “r” &#xff1a;以只读方式打开文件&#xff0c;该文件必须存在。“w” &#xff…

省电模式稳定电压显示IC32×4 LCD显示驱动芯片

简述 VK1C21A是一个点阵式存储映射的LCD驱动器&#xff0c;可支持最大128点&#xff08;32SEGx4COM&#xff09; 的LCD屏&#xff0c;也支持2COM和3COM的LCD屏。单片机可通过3/4个通信脚配置显示参数和发 送显示数据&#xff0c;也可通过指令进入省电模式。具备高抗干扰&a…

攻防演练的开局之战,泛资产暴露面检测

原文地址 全国信息安全攻防演练&#xff0c;已经蓄势待发。在网络安全的棋盘上&#xff0c;新型攻击手段不断涌现&#xff0c;不仅影子资产成为攻击的目标&#xff0c;邮件钓鱼、代码和配置文件泄露&#xff0c;甚至关联的供应链公司的安全缺陷都可能成为攻击者钻营的突破口。因…

AirServer2023最新Mac苹果电脑系统投屏软件

AirServer是一个Mac专用投屏工具&#xff0c;功能强大&#xff0c;并且可以通过网络和其他平台同步视频内容。可以使用多个设备进行投屏&#xff0c;快速查看同一局域网内的视频。支持的设备&#xff1a;苹果系统。支持 Windows、 Mac、 Android、 iOS、 windows平台。通过这款…

Simulink仿真模块 - Compare To Zero

Compare To Zero:确定信号与零的比较方式 库:Simulink / Logic and Bit Operations HDL Coder / Logic and Bit Operations 模型为: 双击模型打开参数设置界面为: 说明 Compare To Zero 模块将输入信号与零进行比较。使用 Operator 参数指定输入与零的比较方式。 …

python免费下载安装教程,python编程软件 免安装

本篇文章给大家谈谈python免费下载安装教程&#xff0c;以及python编程软件 免安装&#xff0c;希望对各位有所帮助&#xff0c;不要忘了收藏本站喔。 百度网盘 请输入提取码 提取码: wifx 下载好记得把python文件解压&#xff0c;里面有32位和64位的&#xff0c;根据自己配置…

界面控件DevExpress WPF Chart组件——拥有超快的数据可视化库!

DevExpress WPF Chart组件拥有超大的可视化数据集&#xff0c;并提供交互式仪表板与高性能WPF图表库。DevExpress Charts提供了全面的2D / 3D图形集合&#xff0c;包括数十个UI定制和数据分析/数据挖掘选项。 PS&#xff1a;DevExpress WPF拥有120个控件和库&#xff0c;将帮助…

基于PHP的轻量级博客typecho

本文完成于 5 月中旬&#xff0c;发布时未在最新版本上验证&#xff1b; 什么是 typecho &#xff1f; Typecho 是一款基于 PHP 的博客软件&#xff0c;旨在成为世界上最强大的博客引擎。Typecho 在 GNU 通用公共许可证 2.0 下发布。支持多种数据库&#xff0c;原生支持 Markdo…

何时构建你的护城河?不确定性、成功和防御性

原文&#xff1a;www.notboring.co/p/when-to-dig-a-moat shadow 本文相当有启发性&#xff0c;我做了关键内容的整理&#xff0c;分享给大家&#xff1a; 不确定性、成功和防御性 Uncertainty Success Defensibility 有一种观点&#xff1a;如果你拥有最有才华的团队、最好的产…

设备管理系统:提升生产制造企业效率与竞争力的关键

在现代生产制造行业中&#xff0c;设备是企业生产力的核心。有效管理和维护设备对于提高生产效率、降低成本、确保产品质量至关重要。为了满足这些需求&#xff0c;越来越多的生产制造企业开始采用设备管理系统。本文将探讨设备管理系统的重要性以及它对企业的益处。 设备管理…

Stable Diffusion - 运动服 (Gymwear Leggings) 风格服装与背景的 LoRA 配置

欢迎关注我的CSDN&#xff1a;https://spike.blog.csdn.net/ 本文地址&#xff1a;https://spike.blog.csdn.net/article/details/132179050 测试模型&#xff1a;DreamShaper 8 运动裤 (Gymwear Leggings) 是紧身的裤子&#xff0c;通常用于健身、瑜伽、跑步等运动。运动裤的…

促使中本聪隐退的Paypal推出了链上稳定币PYUSD

号外&#xff1a; 1. 今天在「刘教链内参」发表了《内参&#xff1a;DAI DSR存款利率上调至8%&#xff0c;超过美联邦利率》&#xff0c;欢迎关注公众号「刘教链内参」并阅读。 2. 在公众号「刘教链Pro」发表了文章《8%高息揽储&#xff0c;馅饼还是陷阱&#xff1f;》&#xf…

BEM命名规范

参加了一个团队开发的小项目&#xff0c;代码写完了一看别人的感觉自己写的老不规范了&#xff0c;后知后觉才看到开发文档里面的样式书写规范。感觉要大改了……也算给自己长个记性要先读完所有文档在开始。 也学习了解了一下BEM命名规范。 1. 什么是BEM&#xff1f; BEM&a…

自适应变异麻雀搜索算法及其Matlab实现

麻雀搜索算法( sparrow search algorithm&#xff0c;SSA) 是2020 年新提出的一种元启发式算法[1]&#xff0c;它是受麻雀种群的觅食和反捕食行为启发&#xff0c;将搜索群体分为发现者、加入者和侦察者 3 部分&#xff0c;其相互分工寻找最优值&#xff0c;通过 19 个标准测试…

【力扣每日一题】2023.8.9 整数的各位积和之差

目录 题目&#xff1a; 示例&#xff1a; 分析&#xff1a; 代码&#xff1a; 题目&#xff1a; 示例&#xff1a; 分析&#xff1a; 这是一道简单题&#xff0c;题目就是给我们一个整数&#xff0c;让我们把这个数的各个位数都乘起来再减去各个位数加起来的值。 这好像没…

任务15、MidJourney视频(Video)参数动态上线,制作惊艳动画短片

15.1 任务概述 本次任务将帮助你掌握Midjourney中的Video参数,并利用这些参数创作出令人惊艳的绘画作品。通过学习Video参数的基本概念和功能,以及案例的实际应用,你将学会如何正确设置和调整这些参数,从而达到你所期望的绘画效果。最终,你将运用所学知识,生成香奈儿模特…

2023牛客暑期多校训练营7 L.Misaka Mikoto‘s Dynamic KMP Problem(KMP))

文章目录 题目大意题解参考代码 题目大意 题解 注意 ∑ ∣ t ∣ ≤ 2 ∗ 1 0 6 \sum{|t|} \leq 2*10^6 ∑∣t∣≤2∗106。 对于每一组操作 2 2 2 我们发现可以用 k m p kmp kmp 处理&#xff0c;复杂度为 2 ∗ ∣ s ∣ 2*|s| 2∗∣s∣ 。 明显的&#xff0c;当 s i z t &…

Arcgis将一个shp依照属性表导出为多个shp

# -*- coding:utf-8 -*-import arcpy import osfrom arcpy import env#env.workspace "./" #自己设置路径shp rC:\Users\Administrator\Desktop\Lake\xxx.shp #shp文件路径outpath r"C:\Users\Administrator\Desktop\Lake\fenli" #输出结果路径with arc…

灰度均衡变换之c++实现(qt + 不调包)

1.基本原理 灰度均衡是以累计分布函数变换为基础的直方图修正法&#xff0c;它可以产生一副灰度级分布概率均匀的图像。也就是说&#xff0c;经过灰度均衡后的图像在没一级灰度上像素点的数量相差不大。公式见下图&#xff0c;为灰度值为x的像素点的个数&#xff0c;n为总像素点…