commit b77a9d7a190fd548444e6557e56be09288ff17dc Author: artstich Date: Thu Aug 14 20:38:18 2025 +0800 FIX README ht历史记录优化 diff --git a/Example/NodeAlignPro_demo(API).json b/Example/NodeAlignPro_demo(API).json new file mode 100644 index 0000000..e77d3ed --- /dev/null +++ b/Example/NodeAlignPro_demo(API).json @@ -0,0 +1,119 @@ +{ + "3": { + "inputs": { + "seed": 462639134113331, + "steps": 20, + "cfg": 8, + "sampler_name": "euler", + "scheduler": "normal", + "denoise": 1, + "model": [ + "4", + 0 + ], + "positive": [ + "6", + 0 + ], + "negative": [ + "7", + 0 + ], + "latent_image": [ + "5", + 0 + ] + }, + "class_type": "KSampler", + "_meta": { + "title": "K采样器" + } + }, + "4": { + "inputs": { + "ckpt_name": "sd1.5_HT写实_麦橘\\MajicMixRealistic_麦橘写实_v7.safetensors" + }, + "class_type": "CheckpointLoaderSimple", + "_meta": { + "title": "Checkpoint加载器(简易)" + } + }, + "5": { + "inputs": { + "width": 512, + "height": 512, + "batch_size": 1 + }, + "class_type": "EmptyLatentImage", + "_meta": { + "title": "空Latent图像" + } + }, + "6": { + "inputs": { + "text": "High - definition, realistic, young woman, natural facial features, smooth skin, clear eyes, natural mouth, good natural lighting, good lighting effects,", + "speak_and_recognation": { + "__value__": [ + false, + true + ] + }, + "clip": [ + "4", + 1 + ] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP文本编码" + } + }, + "7": { + "inputs": { + "text": "text, watermark,\nDistortion, disproportionate, incorrectly spliced limbs, incorrect fingers, multiple heads, one body with multiple heads, incomplete limbs, elongated body, blurry, deformed, objects covering the face, facial artifacts, obscured eyes, covered mouth, incorrect splicing, malformed fingers, extra limbs, elongated neck, blurry face, graphical glitches, textured face errors, lowres, watermark, cropped, out of frame, bad proportions, disfigured, mutated, extra arms, fused fingers, missing lips, malformed ears, irregular iris, skin blemishes, unnatural lighting, strange colors on face, glitchy effects near mouth or eyes, artificial lighting artifacts\n", + "speak_and_recognation": { + "__value__": [ + false, + true + ] + }, + "clip": [ + "4", + 1 + ] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP文本编码" + } + }, + "8": { + "inputs": { + "samples": [ + "3", + 0 + ], + "vae": [ + "4", + 2 + ] + }, + "class_type": "VAEDecode", + "_meta": { + "title": "VAE解码" + } + }, + "9": { + "inputs": { + "filename_prefix": "ComfyUI_EasyKitHT_NodeAlignPro", + "images": [ + "8", + 0 + ] + }, + "class_type": "SaveImage", + "_meta": { + "title": "保存图像" + } + } +} \ No newline at end of file diff --git a/Example/NodeAlignPro_demo.json b/Example/NodeAlignPro_demo.json new file mode 100644 index 0000000..907a8b3 --- /dev/null +++ b/Example/NodeAlignPro_demo.json @@ -0,0 +1,422 @@ +{ + "id": "94462c7a-f815-4abe-978b-3668e6ce494e", + "revision": 0, + "last_node_id": 10, + "last_link_id": 9, + "nodes": [ + { + "id": 3, + "type": "KSampler", + "pos": [ + 305, + -60 + ], + "size": [ + 220, + 474 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "name": "model", + "type": "MODEL", + "link": 1 + }, + { + "name": "positive", + "type": "CONDITIONING", + "link": 4 + }, + { + "name": "negative", + "type": "CONDITIONING", + "link": 6 + }, + { + "name": "latent_image", + "type": "LATENT", + "link": 2 + } + ], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "slot_index": 0, + "links": [ + 7 + ] + } + ], + "properties": { + "cnr_id": "comfy-core", + "ver": "0.3.30", + "Node name for S&R": "KSampler" + }, + "widgets_values": [ + 462639134113331, + "fixed", + 20, + 8, + "euler", + "normal", + 1 + ], + "color": "#23236a", + "bgcolor": "#3c3c83" + }, + { + "id": 4, + "type": "CheckpointLoaderSimple", + "pos": [ + -510, + -60 + ], + "size": [ + 315, + 98 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "slot_index": 0, + "links": [ + 1 + ] + }, + { + "name": "CLIP", + "type": "CLIP", + "slot_index": 1, + "links": [ + 3, + 5 + ] + }, + { + "name": "VAE", + "type": "VAE", + "slot_index": 2, + "links": [ + 8 + ] + } + ], + "properties": { + "cnr_id": "comfy-core", + "ver": "0.3.30", + "Node name for S&R": "CheckpointLoaderSimple" + }, + "widgets_values": [ + "sd1.5_HT写实_麦橘\\MajicMixRealistic_麦橘写实_v7.safetensors" + ] + }, + { + "id": 5, + "type": "EmptyLatentImage", + "pos": [ + 50, + 210 + ], + "size": [ + 210, + 106 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "slot_index": 0, + "links": [ + 2 + ] + } + ], + "properties": { + "cnr_id": "comfy-core", + "ver": "0.3.30", + "Node name for S&R": "EmptyLatentImage" + }, + "widgets_values": [ + 512, + 512, + 1 + ], + "color": "#555504", + "bgcolor": "#6e6e1d" + }, + { + "id": 6, + "type": "CLIPTextEncode", + "pos": [ + -150, + -60 + ], + "size": [ + 410, + 200 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 3 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "slot_index": 0, + "links": [ + 4 + ] + } + ], + "properties": { + "cnr_id": "comfy-core", + "ver": "0.3.30", + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "High - definition, realistic, young woman, natural facial features, smooth skin, clear eyes, natural mouth, good natural lighting, good lighting effects,", + [ + false, + true + ] + ], + "color": "#124c12", + "bgcolor": "#2b652b" + }, + { + "id": 7, + "type": "CLIPTextEncode", + "pos": [ + -140, + 200 + ], + "size": [ + 350, + 200 + ], + "flags": { + "collapsed": true + }, + "order": 3, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 5 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "slot_index": 0, + "links": [ + 6 + ] + } + ], + "properties": { + "cnr_id": "comfy-core", + "ver": "0.3.30", + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "text, watermark,\nDistortion, disproportionate, incorrectly spliced limbs, incorrect fingers, multiple heads, one body with multiple heads, incomplete limbs, elongated body, blurry, deformed, objects covering the face, facial artifacts, obscured eyes, covered mouth, incorrect splicing, malformed fingers, extra limbs, elongated neck, blurry face, graphical glitches, textured face errors, lowres, watermark, cropped, out of frame, bad proportions, disfigured, mutated, extra arms, fused fingers, missing lips, malformed ears, irregular iris, skin blemishes, unnatural lighting, strange colors on face, glitchy effects near mouth or eyes, artificial lighting artifacts\n", + [ + false, + true + ] + ], + "color": "#901919", + "bgcolor": "#a93232" + }, + { + "id": 8, + "type": "VAEDecode", + "pos": [ + 570, + -60 + ], + "size": [ + 340, + 46 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "samples", + "type": "LATENT", + "link": 7 + }, + { + "name": "vae", + "type": "VAE", + "link": 8 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "slot_index": 0, + "links": [ + 9 + ] + } + ], + "properties": { + "cnr_id": "comfy-core", + "ver": "0.3.30", + "Node name for S&R": "VAEDecode" + }, + "widgets_values": [] + }, + { + "id": 9, + "type": "SaveImage", + "pos": [ + 570, + 50 + ], + "size": [ + 340, + 360 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 9 + } + ], + "outputs": [], + "properties": { + "cnr_id": "comfy-core", + "ver": "0.3.30", + "Node name for S&R": "SaveImage" + }, + "widgets_values": [ + "ComfyUI_EasyKitHT_NodeAlignPro" + ], + "color": "#124c12", + "bgcolor": "#2b652b" + } + ], + "links": [ + [ + 1, + 4, + 0, + 3, + 0, + "MODEL" + ], + [ + 2, + 5, + 0, + 3, + 3, + "LATENT" + ], + [ + 3, + 4, + 1, + 6, + 0, + "CLIP" + ], + [ + 4, + 6, + 0, + 3, + 1, + "CONDITIONING" + ], + [ + 5, + 4, + 1, + 7, + 0, + "CLIP" + ], + [ + 6, + 7, + 0, + 3, + 2, + "CONDITIONING" + ], + [ + 7, + 3, + 0, + 8, + 0, + "LATENT" + ], + [ + 8, + 4, + 2, + 8, + 1, + "VAE" + ], + [ + 9, + 8, + 0, + 9, + 0, + "IMAGE" + ] + ], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 1.0610764609500007, + "offset": [ + 590.8386486447955, + 307.4746517299033 + ] + }, + "frontendVersion": "1.17.11", + "ue_links": [], + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true + }, + "version": 0.4 +} \ No newline at end of file diff --git a/Example/NodeAlignPro_demo.png b/Example/NodeAlignPro_demo.png new file mode 100644 index 0000000..6e93dbb Binary files /dev/null and b/Example/NodeAlignPro_demo.png differ diff --git a/Example/hPic/HT20250429-优化UI重绘_元素_渲染_ArtsticH_NodeAlignPro.webp b/Example/hPic/HT20250429-优化UI重绘_元素_渲染_ArtsticH_NodeAlignPro.webp new file mode 100644 index 0000000..1fae8f2 Binary files /dev/null and b/Example/hPic/HT20250429-优化UI重绘_元素_渲染_ArtsticH_NodeAlignPro.webp differ diff --git a/Example/hPic/HT20250429-优化UI重绘_元素_渲染_ArtsticH_NodeAlignPro_对比.webp b/Example/hPic/HT20250429-优化UI重绘_元素_渲染_ArtsticH_NodeAlignPro_对比.webp new file mode 100644 index 0000000..d845da0 Binary files /dev/null and b/Example/hPic/HT20250429-优化UI重绘_元素_渲染_ArtsticH_NodeAlignPro_对比.webp differ diff --git a/Example/hPic/HT20250429-优化UI重绘_元素_线稿_ArtsticH_NodeAlignPro.webp b/Example/hPic/HT20250429-优化UI重绘_元素_线稿_ArtsticH_NodeAlignPro.webp new file mode 100644 index 0000000..c4f44a3 Binary files /dev/null and b/Example/hPic/HT20250429-优化UI重绘_元素_线稿_ArtsticH_NodeAlignPro.webp differ diff --git a/Example/hPic/HT20250430-件优化UI重绘_新增UI缩放适配_ArtsticH_NodeAlignPro.webp b/Example/hPic/HT20250430-件优化UI重绘_新增UI缩放适配_ArtsticH_NodeAlignPro.webp new file mode 100644 index 0000000..87d681b Binary files /dev/null and b/Example/hPic/HT20250430-件优化UI重绘_新增UI缩放适配_ArtsticH_NodeAlignPro.webp differ diff --git a/Example/hPic/HT20250501-联动【运行按钮】_ArtsticH_NodeAlignPro.webp b/Example/hPic/HT20250501-联动【运行按钮】_ArtsticH_NodeAlignPro.webp new file mode 100644 index 0000000..3cb4002 Binary files /dev/null and b/Example/hPic/HT20250501-联动【运行按钮】_ArtsticH_NodeAlignPro.webp differ diff --git a/Example/hPic/HT20250501-联动【运行按钮】_右键菜单适配_ArtsticH_NodeAlignPro.webp b/Example/hPic/HT20250501-联动【运行按钮】_右键菜单适配_ArtsticH_NodeAlignPro.webp new file mode 100644 index 0000000..5a55348 Binary files /dev/null and b/Example/hPic/HT20250501-联动【运行按钮】_右键菜单适配_ArtsticH_NodeAlignPro.webp differ diff --git a/HT20250501-ArtsticH_NodeAlignPro_demo.webp b/HT20250501-ArtsticH_NodeAlignPro_demo.webp new file mode 100644 index 0000000..706369e Binary files /dev/null and b/HT20250501-ArtsticH_NodeAlignPro_demo.webp differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e72bfdd --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b91b74 --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +# ComfyUI_EasyKitHT_NodeAlign Pro 🎨 + +[![GitHub stars](https://img.shields.io/github/stars/ArtsticH/ComfyUI_EasyKitHT_NodeAlignPro?style=for-the-badge)](https://github.com/ArtsticH/ComfyUI_EasyKitHT_NodeAlignPro/stargazers) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](LICENSE) [![切换中文](https://img.shields.io/badge/切换中文-README_ZH.md-blue?style=for-the-badge)](README_ZH.md) [![English](https://img.shields.io/badge/English-README.md-blue?style=for-the-badge)](README_ZH.md) + + +The newly designed ComfyUI node alignment and coloring plugin has completely redesigned and developed new UI icons and layouts. The layout of the alignment tool is more in line with the common operation logic and experience in the design industry. The position of the coloring tool is more reasonable, facilitating quick coloring. + + +## ✨ Core Features + +| Intelligent Alignment System | Enhanced Workflow | Efficient Interaction Design | 🔆 New UI Zoom Adaptation | +|---------------------------|---------------------------|---------------------------|---------------------------| +| ✅ 8 Basic Alignment Modes | 🎨 One-click Color Management Scheme | 🖱️ Floating Tool Panel | ✅ Added UI Zoom Button in the Right-click Menu | +| 📐 Dynamic Spacing Distribution Algorithm | 📏 Visual Layout Guide Lines | ⌨️ Custom Shortcut Key Configuration | 😁By default, clicking the "UI Zoom" button only
  zooms the plugin components | +| 👥 Multi-node Group Collaborative Operation | 👁️ Real-time Preview of Adjustment Effects | 💾 Layout Memory and Restoration System | ❕Click the "UI Zoom" button with Ctrl to globally
  zoom the page | + +⚠️Note:`HT20250430-New UI Zoom Adaptation` ((There is a slight bug causing "Incomplete display due to excessive global zoom", but "It does not affect basic usage" and will be fixed in the future. Therefore, you can currently use the basic UI zoom with confidence, that is, **directly click the "UI Zoom" button**). + +## 🖼️ Effect Demonstration + +![Operation_Demonstration](HT20250501-ArtsticH_NodeAlignPro_demo.webp) + +## ✅ Function Update Records + +![UI_Linkage-button](Example/hPic/HT20250501-联动【运行按钮】_右键菜单适配_ArtsticH_NodeAlignPro.webp) +![UI_Linkage-button-ContextMenu](Example/hPic/HT20250501-联动【运行按钮】_ArtsticH_NodeAlignPro.webp) +![UI_Element-zoomButton](Example/hPic/HT20250430-件优化UI重绘_新增UI缩放适配_ArtsticH_NodeAlignPro.webp) +![ArtsticH_Originaldesign_Line-drawing](Example/hPic/HT20250429-优化UI重绘_元素_渲染_ArtsticH_NodeAlignPro_对比.webp) + + + +--- + +## 🛠️ Installation Guide + +### Manual Installation +1. [Download the Latest Release](https://github.com/ArtsticH/ComfyUI_EasyKitHT_NodeAlignPro/releases) +2. Unzip it to the `ComfyUI/custom_nodes/` directory +3. Restart the ComfyUI service + +### Git Installation +```bash +git clone https://github.com/ArtsticH/ComfyUI_EasyKitHT_NodeAlignPro.git custom_nodes/ComfyUI_EasyKitHT_NodeAlignPro +``` +### Git update (Manual navigation to the ComfyUI_EasyKitHT_NodeAlignPro directory is required first) +```bash +git fetch --all +``` + +### 🚀 Quick Start +Example Workflow Configuration (for reference only) +```python +{ + "nodes": [ + { + "type": "ComfyUI_EasyKitHT_NodeAlignPro/AlignGroup", + "params": { + "alignment_mode": "vertical_center", + "spacing": 50, + "color_scheme": "cyan" + } + } + ] +} +``` + +## 📌 Function Details +- **Node Alignment** +Left/Right/Top/Bottom Alignment, Horizontal/Vertical Centering, Smart Spacing Distribution + +- **Node Coloring** +7 Preset Color Schemes: orange, yellow, green, cyan, blue, purple, Custom Color Picker, One-click Reset + + +## 🤝 Contribution Guide +- Welcome to participate in the improvement in the following ways: +`Submit Usage Feedback`、`New Issue`、`Improve Code Logic`、`Fork & PR`、`Complete Multilingual Documents`、`Share Creative Workflows` + +## 📜 License Agreement +- This project uses the MIT License. The development idea is based on the secondary development of[ComfyUI-NodeAligner](https://github.com/Tenney95/ComfyUI-NodeAligner) and [ComfyUI-Align](https://github.com/Moooonet/ComfyUI-Align). +- It mainly refactored the code and rewrote the UI, thus developing the lightweight[ComfyUI_EasyKitHT_NodeAlignPro](https://github.com/Tenney95/ComfyUI-NodeAligner)named`ComfyUI plugin`. +- The core functions are: `Node Alignment`and`Node Coloring`. + +👨💻 This is a project developed by a designer in his spare time. Welcome to feedback on usage issues. +⚠️ There may be exceptions in untested scenarios. Please report them through Issues. \ No newline at end of file diff --git a/README_ZH.md b/README_ZH.md new file mode 100644 index 0000000..b9a4160 --- /dev/null +++ b/README_ZH.md @@ -0,0 +1,85 @@ +# ComfyUI_EasyKitHT_NodeAlign Pro 🎨 + +[![GitHub stars](https://img.shields.io/github/stars/ArtsticH/ComfyUI_EasyKitHT_NodeAlignPro?style=for-the-badge)](https://github.com/ArtsticH/ComfyUI_EasyKitHT_NodeAlignPro/stargazers) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](LICENSE) [![切换中文](https://img.shields.io/badge/切换中文-README_ZH.md-blue?style=for-the-badge)](README_ZH.md) [![English](https://img.shields.io/badge/English-README.md-blue?style=for-the-badge)](README.md) + +全新设计的ComfyUI节点对齐与上色插件,完整重新设计开发了新的UI图标和布局。对齐工具的布局更符合设计行业通用的操作逻辑和体验,上色工具位置更合理,方便快速上色。 + + +## ✨ 核心功能 + +| 智能对齐系统 | 增强工作流 | 高效交互设计 | 🔆新增UI缩放适配 | +|---------------------------|---------------------------|---------------------------|---------------------------| +| ✅ 8种基础对齐模式 | 🎨 一键式颜色管理方案 | 🖱️ 悬浮式工具面板 | ✅右键菜单新增UI缩放按钮 | +| 📐 动态间距分布算法 | 📏 可视化布局辅助线 | ⌨️ 快捷键自定义配置 | 😁默认点击“UI缩放”按钮
  仅缩放插件组件 | +| 👥 多节点组协同操作 | 👁️ 实时预览调整效果 | 💾 布局记忆与恢复系统 | ❕按Ctrl点击“UI缩放”按钮
  页面全局缩放 | + +⚠️注:`HT20250430-新增UI缩放适配` (有轻微bug导致`全局缩放过大导致显示不全`,但`不影响基础使用`,后续会修复。 +因此目前你可以**放心的使用基础UI缩放**,即**直接点击“UI缩放”按钮**)。 + +## 🖼️ 效果演示 + +![操作演示](HT20250501-ArtsticH_NodeAlignPro_demo.webp) + +## ✅ 更新功能记录 + +![UI_联动【运行按钮】](Example/hPic/HT20250501-联动【运行按钮】_右键菜单适配_ArtsticH_NodeAlignPro.webp) +![UI_联动【运行按钮】](Example/hPic/HT20250501-联动【运行按钮】_ArtsticH_NodeAlignPro.webp) +![UI_件优化UI重绘_新增UI缩放适配](Example/hPic/HT20250430-件优化UI重绘_新增UI缩放适配_ArtsticH_NodeAlignPro.webp) +![ArtsticH_原创设计_基础线稿](Example/hPic/HT20250429-优化UI重绘_元素_渲染_ArtsticH_NodeAlignPro_对比.webp) + + + +--- + +## 🛠️ 安装指南 + +### 手动安装 +1. [下载最新Release](https://github.com/ArtsticH/ComfyUI_EasyKitHT_NodeAlignPro/releases) +2. 解压到 `ComfyUI/custom_nodes/` 目录 +3. 重启ComfyUI服务 + +### Git安装 +```bash +git clone https://github.com/ArtsticH/ComfyUI_EasyKitHT_NodeAlignPro.git custom_nodes/ComfyUI_EasyKitHT_NodeAlignPro +``` +### Git更新(需先手动导航至ComfyUI_EasyKitHT_NodeAlignPro目录内) +```bash +git fetch --all +``` +### 🚀 快速开始 +示例工作流配置(仅供参考) +```python +{ + "nodes": [ + { + "type": "ComfyUI_EasyKitHT_NodeAlignPro/AlignGroup", + "params": { + "alignment_mode": "vertical_center", + "spacing": 50, + "color_scheme": "cyan" + } + } + ] +} +``` + +## 📌 功能详解 +- **节点对齐** +**左对齐 / 右对齐 / 顶对齐 / 底对齐**、**水平居中 / 垂直居中**、**智能间距分布** + +- **节点上色** +**预设7色系:红、橙、黄、绿、青、蓝、紫**、**自定义取色器**、**快速清除颜色** + + +## 🤝 贡献指南 +- 欢迎通过以下方式参与改进: +`提交使用反馈`、`New Issue`、`改进代码逻辑`、`Fork & PR`、`完善多语言文档`、`分享创意工作流` + +## 📜 许可协议 +- 本项目采用 MIT License,开发思路基于[ComfyUI-NodeAligner](https://github.com/Tenney95/ComfyUI-NodeAligner) 和 [ComfyUI-Align](https://github.com/Moooonet/ComfyUI-Align) 二次开发。 +- 主要重构了代码,并重写了UI,从而开发了[ComfyUI_EasyKitHT_NodeAlignPro](https://github.com/Tenney95/ComfyUI-NodeAligner)这款轻量级`ComfyUI插件`。 +- 核心功能为:`节点对齐`与`节点上色`。 + + +👨💻 设计师业余开发项目,欢迎反馈使用问题 +⚠️ 可能存在未测试场景的异常,请通过Issues报告 \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..78ed34a --- /dev/null +++ b/__init__.py @@ -0,0 +1,8 @@ +import os +# 插件节点映射(可以不定义任何节点) +NODE_CLASS_MAPPINGS = {} + +# 前端文件路径 +current_directory = os.path.dirname(os.path.abspath(__file__)) +# 打印输出当前目录 +WEB_DIRECTORY = os.path.join(current_directory) diff --git a/node_info.js b/node_info.js new file mode 100644 index 0000000..b266d41 --- /dev/null +++ b/node_info.js @@ -0,0 +1,1328 @@ +import { + ColorSVGs + } from "./web/color_svgs.js"; + const buildSVG = (innerContent, { + t, + pId + }) => { + return ` + ${innerContent} + `; + }; + const Elements = { + rect: (x, y, width, height) => + ``, + vLine: (x, height = 24) => + ``, + hLine: (y, width = 24) => + ``, + dotMatrix: () => { + const dots = []; + const positions = [ + [11, 6], + [21, 6], + [11, 16], + [21, 16], + [11, 26], + [21, 26] + ]; + positions.forEach(([cx, cy], index) => { + dots.push(``); + }); + return dots.join(''); + } + }; + // ======================== 具体图标模板 ======================== + const Templates = { + // 拖动按钮 + hBtn_moveElement: () => { + const dotMatrixContent = Elements.dotMatrix().replace(/id="dot"/g, 'id="base-dot"'); + return ` + ${dotMatrixContent} + ${dotMatrixContent.replace(/id="base-dot"/g, 'use href="#base-dot"')} + `; + }, + // 左对齐 + hBtnA_alignLeft: () => ` + ${Elements.rect(10, 9, 12, 6)} + ${Elements.rect(10, 19, 18, 6)} + ${Elements.vLine(5, 24)}`, + // 竖向居中对齐 + hBtnB_alignCenterV: () => ` + ${Elements.rect(9, 9, 14, 6)} + ${Elements.rect(6, 19, 20, 6)} + ${Elements.vLine(15, 24)}`, + // 右对齐 + hBtnC_alignRight: () => ` + ${Elements.rect(11, 9, 12, 6)} + ${Elements.rect(5, 19, 18, 6)} + ${Elements.vLine(26, 24)}`, + // 顶部对齐 + hBtnD_alignTop: () => ` + ${Elements.rect(8, 9, 6, 12)} + ${Elements.rect(18, 9, 6, 18)} + ${Elements.hLine(5, 24)}`, + // 横向居中对齐 + hBtnE_alignCenterH: () => ` + ${Elements.rect(18, 6, 6, 20)} + ${Elements.rect(8, 9, 6, 14)} + ${Elements.hLine(15, 24)}`, + // 底部对齐 + hBtnF_alignButton: () => ` + ${Elements.rect(8, 11, 6, 12)} + ${Elements.rect(18, 5, 6, 18)} + ${Elements.hLine(26, 24)}`, + // 横向分布 基准线(y=7,长度24px) + hBtnG_distributionH: () => ` + ${Elements.rect(19, 5, 2, 7)} + ${Elements.rect(11, 5, 2, 7)} + ${Elements.rect(19, 13, 6, 11)} + ${Elements.rect(7, 13, 6, 15)} + ${Elements.hLine(7, 24)}`, + // 竖向分布 基准线(x=6,高度24px) + hBtnH_distributionV: () => ` + ${Elements.rect(12, 7, 11, 6)} + ${Elements.rect(4, 11, 7, 2)} + ${Elements.rect(4, 19, 7, 2)} + ${Elements.rect(12, 19, 16, 6)} + ${Elements.vLine(6, 24)}`, + // 等宽 + hBtnI_equalWidth: () => ` + ${Elements.rect(9, 9, 14, 6)} + ${Elements.rect(11, 19, 10, 6)} + ${Elements.vLine(4, 24)} + ${Elements.vLine(26, 24)} + ${Elements.rect(4, 21, 5, 2)} + ${Elements.rect(23, 21, 5, 2)}`, + // 等高 + hBtnJ_equalHeight: () => ` + ${Elements.rect(18, 9, 6, 14)} + ${Elements.rect(8, 11, 6, 10)} + ${Elements.hLine(4, 24)} + ${Elements.hLine(26, 24)} + ${Elements.rect(10, 4, 2, 5)} + ${Elements.rect(10, 23, 2, 5)}` + }; + // ======================== 最终导出的SVG常量 ======================== + const hSvg_moveElement = buildSVG(Templates.hBtn_moveElement(), { + t: '1745769856000', + pId: '8808' + }); + const hSvgA_alignLeft = buildSVG(Templates.hBtnA_alignLeft(), { + t: '1725534370541', + pId: '2104' + }); + const hSvgB_alignCenterV = buildSVG(Templates.hBtnB_alignCenterV(), { + t: '1725534363707', + pId: '1810' + }); + const hSvgC_alignRight = buildSVG(Templates.hBtnC_alignRight(), { + t: '1725534384109', + pId: '2398' + }); + const hSvgD_alignTop = buildSVG(Templates.hBtnD_alignTop(), { + t: '1725534367556', + pId: '1957' + }); + const hSvgE_alignCenterH = buildSVG(Templates.hBtnE_alignCenterH(), { + t: '1725534379860', + pId: '2251' + }); + const hSvgF_alignButton = buildSVG(Templates.hBtnF_alignButton(), { + t: '1725534360155', + pId: '1663' + }); + const hSvgG_distributionH = buildSVG(Templates.hBtnG_distributionH(), { + t: '1725534354023', + pId: '1516' + }); + const hSvgH_distributionV = buildSVG(Templates.hBtnH_distributionV(), { + t: '1725534350231', + pId: '1369' + }); + const hSvgI_equalWidth = buildSVG(Templates.hBtnI_equalWidth(), { + t: '1725606034670', + pId: '7216' + }); + const hSvgJ_equalHeight = buildSVG(Templates.hBtnJ_equalHeight(), { + t: '1725606224564', + pId: '7793' + }); + const ButtonManager = { + zoomLevels: [1, 1.5, 2, 0.5], + currentZoom: 1, + isSystemZoom: false, + isRunButtonAligned: false, + linkMode: 0, + linkColors: ['', '#60A5FA', '#355757', '#675535', '#32512A'], + linkOffset: -1, + syncRunButtonPosition() { + if (!this.isRunButtonAligned || this.linkMode === 0) return; + const alignKit = this.hMainToolbar; + const runKit = document.querySelector('.p-panel.actionbar'); + if (alignKit && runKit) { + const alignRect = alignKit.getBoundingClientRect(); + const runRect = runKit.getBoundingClientRect(); + const offset = this.linkOffset; + let left, top; + switch (this.linkMode) { + case 1: + left = alignRect.right + window.scrollX + offset; + top = alignRect.top + window.scrollY; + break; + case 2: + left = alignRect.left + window.scrollX; + top = alignRect.bottom + window.scrollY + offset; + break; + case 3: + left = alignRect.left + window.scrollX; + top = alignRect.top + window.scrollY - runRect.height - offset; + break; + case 4: + left = alignRect.left + window.scrollX - runRect.width - offset; + top = alignRect.top + window.scrollY; + break; + } + runKit.style.left = `${left}px`; + runKit.style.top = `${top}px`; + } + }, + ColorConfig: { + colors: { + red: '#a93232', + orange: '#79461d', + yellow: '#6e6e1d', + green: '#2b652b', + cyan: '#248382', + blue: '#246283', + purple: '#3c3c83', + custom: '#ffffff' + }, + colorMapping: { + titleDarken: -0.1, + noteTextLighten: 0.2 + } + }, + isInitialized: false, + hMainToolbar: null, + contextMenu: null, + isPermanent: true, + initialX: 0, + initialY: 0, + dragStartX: 0, + dragStartY: 0, + isDragging: false, + hasShownhTooltip: false, + isShow: true, + init() { + if (this.isInitialized) return; + this.isRunButtonAligned = false; + this.currentZoomIndex = 0; + this.systemWideZoom = false; + this.boundOnDragging = this.onDragging.bind(this); + this.boundOnDragEnd = this.onDragEnd.bind(this); + window.addEventListener('beforeunload', () => { + document.removeEventListener('mousedown', this.hideMenuHandler); + document.removeEventListener('keydown', this.escKeyHandler); + }); + const style = document.createElement('style'); + style.textContent = ` + /* 2025-04-28 07:56:21 ArtsticH-提取自 SVG 的全局通用样式 */ + .ht-1 { + fill: #6b6b70; /* 主图标颜色 */ + stroke-width: 0px; + } + .ht-2 { + fill: #525252; /* 拖动按钮圆点颜色 */ + stroke-width: 0px; + } + /* 修改运行按钮容器高度 */ + .p-panel.actionbar { + height: 48px !important; /* 原高度为32px,增加2px */ + min-height: 48px !important; /* 同步调整最小高度 */ + align-items: center; /* 确保内容垂直居中 */ + } + #pv_id_11_content { + /* 这是目标元素-ComfyUI官方原生的【运行按钮】 */ + /* 选择器: #comfyui-body-top > div.comfyui-menu.flex.items-center > div.p-panel.p-component.actionbar.w-fit */ + /* Xpath: //*[@id="comfyui-body-top"]/div[1]/div[4] */ + /* Xpath: /html/body/div[1]/main/div[1]/div[1]/div[1]/div[4] */ + } + #hNodeAlignKit { /* 【对齐按钮组样式】 */ + /* white-space: nowrap; 设置元素为绝对定位方式 position: absolute; */ + top: 20px; + right: 10px; + left: 10px; + bottom: unset; + display: flex; + flex-direction: row; + background: #18181B; + padding: 8px; + border-radius: 6px; + z-index: 9999; + width: fit-content; + height: 48px; + position: absolute; + border: 1px solid; + border-color: #3D3D43; + align-self: center; + box-sizing: border-box; + /* place-items: center; 子元素水平和垂直居中 */ + /* text-align: center; 让子元素水平居中 */ + max-width: 800; + min-width: 420; + } + /* 禁止子元素改变容器尺寸 */ + #hNodeAlignKit > * { + flex-shrink: 0; + } + .hC_alignBtn { + width: 32px; + height: 32px; + background-size: contain; + background-repeat: no-repeat; + background-position: center; + background-color: #18181B; + border: none; + cursor: pointer; + padding: 4px; + border-radius: 4px; + transition: background-color 0.3s ease; + align-self: center; + vertical-align: middle; + display: inline-flex; + align-items: center; + justify-content: center; + } + .hC_alignBtn:hover { + background-color: #222226; + } + /* ↓2025-04-28 01:09:28 Artstich新增移动按钮专属悬浮色-开始 fill: #232935 !important; */ + #hBtn_moveElement:hover { + background-color: #70A3F3 !important; + cursor: move; + } + /* ↓2025-04-28 18:00:05 新增SVG图标样式-开始 */ + /* .hC_alignBtn { border: 1px solid red !important; } 显示按钮大小位置示意测试 */ + .hC_alignBtn svg path { + pointer-events: none; /* 防止路径阻挡点击 */ + } + .hC_alignBtn:hover svg { + filter: drop-shadow(0 2px 4px rgba(255,255,255,0.2)); + } + /* #hBtn_moveElement:hover svg .ht-1 {fill: #232935 !important;} */ + #hNodeAlignKit #hBtn_moveElement:hover svg .ht-1 { /* 精准覆盖 SVG 内部类名 */ + fill: #232935 !important; /* 优先级覆盖内联样式-增加嵌套层级 */ + } + /* ↑2025-04-28 01:09:28 Artstich新增移动按钮专属悬浮色-结束 */ + .hC_dividerLine { + width: 1px; + height: 40px; + background-color: #27272B; + margin: 0px 10px; + border-radius: 9px; + cursor: move; + align-self: center; + } + .hC_dividerLine:active { + cursor: grabbing; + } + /* 提示样式 */ + #hTooltip { + position: absolute; + bottom: -20px; + right: 0; + background: #70A3F3; + color: white; + padding: 5px 10px; + border-radius: 6px; + display: none; + z-index: 1001; + white-space: nowrap; + font-size: 16px; + } + /* 2025-04-28 03:48:09 ArtsticH新增-右键菜单容器样式 */ + #hContext-Menu { + display: flex; /* flex布局 */ + white-space: nowrap; /* 防止换行、合并空白字符 */ + box-sizing: border-box; + background: #18181B; /* 设置提示框的背景颜色-测试定位用 #70A3F3; */ + align-items: center; /* 确保子元素垂直居中 */ + justify-content: center; /* 确保子元素水平居中 */ + width: auto; /* 改为自动宽度width: 1300;auto; */ + height: auto; /* 保持固定高度height: 32px; */ + border-radius: 6px; + z-index: 9999; + padding: 0 8px; /* 添加内边距 */ + gap: 6px; /* 按钮间距 */ + margin-top: -1px !important; /* 微调垂直偏移量 */ + margin-left: -644.28px;/* 微调水平偏移量 margin-left: -630.73px; */ + /* margin-left: -200px; 向左偏移 20px */ + /* display: inline-block; */ + /* vertical-align: middle; */ + /* align-self: center; 新增:确保单个按钮垂直居中 */ + /* place-items: center; 子元素水平和垂直居中 */ + /* text-align: center; 让子元素水平居中 */ + } + /* 2025-04-28 03:48:09 ArtsticH新增-右键菜单按钮样式-精准控制按钮垂直位置 */ + #hContext-Menu :is(input, button) { + height: 26; /* 高度auto;height: 26px; */ + min-height: 16px; /* 最小高度 */ + font-size: 14px; + background: #09090B; + border: 1px solid #3D3D43; + border-radius: 6px; + color: #fff; + padding: 4px 12px; /* 调整内边距 */ + margin: 0; /* 移除外边距。 按钮间距margin: 0 3px; */ + transition: all 0.1s ease; /* 过渡动画 transition: all 0.2s ease; */ + position: relative !important; + } + #hContext-Menu button { + min-height: 32px !important; + /* top: -233x !important; 微调垂直偏移量 */ + /* right: 35px !important; 微调水平偏移量 */ + } + #hContext-Menu input { + outline: none; + min-height: 32px !important; + top: -1.5px !important; /* 微调垂直偏移量 */ + /* right: 35px !important; 微调水平偏移量 */ + } + /* 2025-04-28 03:48:09 ArtsticH新增-悬停效果 */ + #hContext-Menu :is(input, button):hover { + background: #222226; /* 悬停背景色 background: #222226; */ + border-color: #70A3F3; /* 悬停边框色 border-color: #70A3F3; */ + transform: scale(1.1); /* 轻微放大 transform: scale(1.1); */ + } + /* 2025-04-28 03:48:09 ArtsticH新增-点击效果 */ + #hContext-Menu :is(input, button):active { + background: #2D2D32; /* 点击背景色 background: #2D2D32; */ + transform: scale(0.98); /* 轻微缩小 transform: scale(0.98); */ + } + #hContext-Menu input:hover { + outline: none; + transform: scale(1) !important; /* 轻微放大 transform: scale(1.1); */ + } + /* 2025-04-28 03:48:09 ArtsticH新增-点击效果 */ + #hContext-Menu input:active { + outline: none; + transform: scale(0.99) !important; /* 轻微缩小 transform: scale(0.98); */ + } + /* 2025-04-28 03:48:09 ArtsticH新增-文字标签和文字链接样式 */ + #hContext-Menu a.no-underline { + color: #A1A1AA; /* 文字颜色 color: #A1A1AA; */ + text-decoration: none; /* 去除下划线 text-decoration: none; */ + margin-right: 8px; /* 右侧间距 margin-right: 8px; */ + /* display: inline-block !important; */ + /* vertical-align: middle !important; */ + /* line-height: 32px !important; 与按钮高度一致 */ + /* margin-right: 8px !important; */ + } + /* UI缩放按钮专用样式 */ + #ui-scale-btn { + width: 82px !important; + min-width: 82px !important; + max-width: 82px !important; + white-space: nowrap; + overflow: hidden; + + box-sizing: border-box; + + padding: 4px 0px !important; + } + /* 覆盖通用按钮的宽度设置 */ + #hContext-Menu button#ui-scale-btn { + width: 80px !important; + flex-shrink: 0; /* 禁止在flex布局中收缩 */ + } + /* 2025-04-28 18:44:47 新增颜色按钮专用样式 */ + #hNodeAlignKit [id^="color"] { + width: 24px !important; + height: 24px !important; + padding: 0px !important; + margin: 0 2px !important; + background: none !important; + margin-top: 40px; /* 增加上边距,使颜色按钮位于基础按钮下方 */ + } + #hNodeAlignKit [id^="color"] svg { + display: block !important; + width: 100% !important; + height: 100% !important; + transition: transform 0.1s ease; + } + #hNodeAlignKit [id^="color"]:hover svg { + transform: scale(1.5); + filter: drop-shadow(0 2px 4px rgba(255,255,255,0.2)); + } + /* 2025-04-28 18:44:47 颜色按钮激活状态 */ + .hC_alignBtn.color-active { + box-shadow: 0 0 0 2px #70A3F3; + } + /* 颜色选择器图标特殊样式 */ + #colorPick svg { + position: relative; + background: rgba(0,0,0,1); /* rgba(7,7,8,0.8); background: rgba(100,100,100,0.3); */ + border-radius: 50%; /* border-radius: 6px; */ + transition: transform 0.1s ease; /* 2025-04-28 18:44:47 颜色选择器图标动画 */ + } + #colorPick:hover svg { + transform: rotate(15deg); + } + /* 清除按钮特殊样式 */ + #colorClear { + position: relative; + } + #colorClear::after { + content: "×"; + position: absolute; + color: #ff4444; + font-size: 20px; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + transition: font-size 0.1s ease; + } + #colorClear:hover::after { + font-size: 32px; + } + /* 2025-04-28 18:44:47 颜色按钮提示 .color-tooltip { */ + .color-hTooltip { + position: absolute; + bottom: -25px; + background: #333; + color: white; + padding: 2px 8px; + border-radius: 4px; + font-size: 12px; + white-space: nowrap; + } + `; + document.head.appendChild(style); + this.hMainToolbar = document.createElement('div'); + this.hMainToolbar.id = 'hNodeAlignKit'; + this.restorePosition(); + document.body.appendChild(this.hMainToolbar); + const buttons = this.getButtons(); + buttons.forEach(btn => { + if (btn.type === 'hC_dividerLine') { + const hC_dividerLine = document.createElement('div'); + hC_dividerLine.classList.add('hC_dividerLine'); + this.hMainToolbar.appendChild(hC_dividerLine); + } else { + const button = document.createElement('button'); + button.id = btn.id; + button.classList.add('hC_alignBtn'); + button.innerHTML = btn.svg; + button.addEventListener('click', (event) => { + btn.action.call(this, event); + event.stopPropagation(); + }); + this.hMainToolbar.appendChild(button); + } + }); + this.hMainToolbar.addEventListener('mousedown', (e) => { + const ishBtn_moveElement = e.target.closest('#hBtn_moveElement') !== null; + const ishC_dividerLine = e.target.classList.contains('hC_dividerLine'); + if (ishBtn_moveElement || ishC_dividerLine) { + this.onDragStart(e); + } + }); + this.isInitialized = true; + this.showContextMenu(); + const hTooltip = document.createElement('div'); + hTooltip.id = 'hTooltip'; + hTooltip.textContent = '右键可选按钮呈现模式'; + this.hMainToolbar.appendChild(hTooltip); + if (!this.hasShownhTooltip) { + this.hMainToolbar.addEventListener('mouseenter', () => { + if (!this.hasShownhTooltip) { + setTimeout(() => { + hTooltip.style.display = 'block'; + this.hasShownhTooltip = true; + }, 1000); + } + }); + this.hMainToolbar.addEventListener('mouseleave', () => { + hTooltip.remove(); + }); + } + let isPermanent = localStorage.getItem('NodeAlignerIsPermanent'); + if (isPermanent) { + this.isPermanent = localStorage.getItem('NodeAlignerIsPermanent') == '1'; + this.isPermanent ? this.show() : this.hide(); + } else { + this.show() + } + const linkRunBtn = this.contextMenu.querySelector('#link-run-btn'); + linkRunBtn.addEventListener('click', (e) => { + e.stopPropagation(); + this.linkMode = (this.linkMode + 1) % 5; + this.isRunButtonAligned = this.linkMode !== 0; + linkRunBtn.style.backgroundColor = this.linkColors[this.linkMode]; + if (this.isRunButtonAligned) { + this.syncRunButtonPosition(); + this.hMainToolbar.addEventListener('mousemove', this.syncRunButtonPosition.bind(this)); + } else { + this.hMainToolbar.removeEventListener('mousemove', this.syncRunButtonPosition.bind(this)); + } + }); + }, + createColorCircle(colorName) { + return ColorSVGs.circle(this.ColorConfig.colors[colorName]); + }, + createColorPickerIcon() { + return ` + + + + + + + + + + + + `; + }, + setNodesColor(event, colorType) { + try { + const app = this.getComfyUIAppInstance(); + if (!app) { + console.warn("ComfyUI实例获取失败"); + return; + } + const color = this.ColorConfig.colors[colorType]; + if (!color) { + console.warn(`未定义的颜色类型: ${colorType}`); + return; + } + const selectedNodes = this.getSelectedNodes(app); + const selectedGroups = this.getSelectedGroups(app); + if (selectedNodes.length + selectedGroups.length === 0) { + console.warn("未选择任何节点或组"); + return; + } + selectedNodes.forEach(node => { + if (node.is_system) return; + this.applyColorToNode(node, color); + }); + selectedGroups.forEach(group => { + group.color = color; + if (group.children) { + group.children.forEach(nodeID => { + const node = app.graph.getNodeById(nodeID); + if (node) this.applyColorToNode(node, color); + }); + } + }); + app.graph.setDirtyCanvas(true, true); + if (app.graph.afterChange) app.graph.afterChange(); + } catch (error) { + console.error("颜色设置失败:", error); + } + }, + resetNodesColor() { + try { + const app = this.getComfyUIAppInstance(); + if (!app) return; + const selected = [...this.getSelectedNodes(app), ...this.getSelectedGroups(app)]; + if (selected.length === 0) return; + selected.forEach(item => { + if (item.is_system) return; + if (item.pos !== undefined) { + item.color = undefined; + item.bgcolor = undefined; + if (item.setDirtyCanvas) item.setDirtyCanvas(true); + } else if (item.children) { + item.color = undefined; + item.children.forEach(nodeId => { + const node = app.graph.getNodeById(nodeId); + if (node) { + node.color = undefined; + node.bgcolor = undefined; + if (node.setDirtyCanvas) node.setDirtyCanvas(true); + } + }); + } + }); + app.graph.setDirtyCanvas(true, true); + if (app.graph.afterChange) app.graph.afterChange(); + } catch (error) { + console.error("颜色重置失败:", error); + } + }, + openNativeColorPicker() { + try { + const app = this.getComfyUIAppInstance(); + if (!app) { + console.warn("ComfyUI实例获取失败"); + return; + } + const selectedNodes = this.getSelectedNodes(app); + const selectedGroups = this.getSelectedGroups(app); + if (selectedNodes.length + selectedGroups.length === 0) { + console.warn("请先选择节点或组"); + return; + } + const input = document.createElement('input'); + input.type = 'color'; + input.style.cssText = ` + position: fixed; + opacity: 0; + pointer-events: none; + top: -100px; + `; + const lastColor = selectedNodes[0]?.bgcolor || selectedGroups[0]?.color || '#3355aa'; + input.value = this.rgbToHex(lastColor); + input.addEventListener('change', (e) => { + const color = e.target.value; + selectedNodes.forEach(node => { + if (node.is_system) return; + this.applyColorToNode(node, color); + }); + selectedGroups.forEach(group => { + group.color = color; + if (group.children) { + group.children.forEach(nodeID => { + const node = app.graph.getNodeById(nodeID); + if (node) this.applyColorToNode(node, color); + }); + } + }); + app.graph.setDirtyCanvas(true, true); + if (app.graph.afterChange) app.graph.afterChange(); + document.body.removeChild(input); + }); + document.body.appendChild(input); + input.click(); + } catch (error) { + console.error("颜色选择器打开失败:", error); + } + }, + rgbToHex(rgb) { + if (!rgb) return '#000000'; + if (rgb.startsWith('#')) return rgb; + const match = rgb.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/); + if (match) { + return '#' + + (1 << 24 | + parseInt(match[1]) << 16 | + parseInt(match[2]) << 8 | + parseInt(match[3]) + ).toString(16).slice(1); + } + return '#000000'; + }, + getComfyUIAppInstance() { + return { + canvas: LGraphCanvas.active_canvas, + graph: LGraphCanvas.active_canvas.graph + }; + }, + getButtons() { + return [{ + id: 'hBtn_moveElement', + svg: hSvg_moveElement + }, + { + type: 'hC_dividerLine' + }, + { + id: 'hBtnA_alignLeft', + svg: hSvgA_alignLeft, + action: this.hBtnA_alignLeft.bind(this) + }, + { + id: 'hBtnB_alignCenterV', + svg: hSvgB_alignCenterV, + action: this.hBtnB_alignCenterV.bind(this) + }, + { + id: 'hBtnC_alignRight', + svg: hSvgC_alignRight, + action: this.hBtnC_alignRight.bind(this) + }, + { + type: 'hC_dividerLine' + }, + { + id: 'hBtnD_alignTop', + svg: hSvgD_alignTop, + action: this.hBtnD_alignTop.bind(this) + }, + { + id: 'hBtnE_alignCenterH', + svg: hSvgE_alignCenterH, + action: this.hBtnE_alignCenterH.bind(this) + }, + { + id: 'hBtnF_alignButton', + svg: hSvgF_alignButton, + action: this.hBtnF_alignButton.bind(this) + }, + { + type: 'hC_dividerLine' + }, + { + id: 'hBtnG_distributionH', + svg: hSvgG_distributionH, + action: this.hBtnG_distributionH.bind(this) + }, + { + id: 'hBtnH_distributionV', + svg: hSvgH_distributionV, + action: this.hBtnH_distributionV.bind(this) + }, + { + type: 'hC_dividerLine' + }, + { + id: 'hBtnI_equalWidth', + svg: hSvgI_equalWidth, + action: this.hBtnI_equalWidth.bind(this) + }, + { + id: 'hBtnJ_equalHeight', + svg: hSvgJ_equalHeight, + action: this.hBtnJ_equalHeight.bind(this) + }, + { + type: 'hC_dividerLine' + }, + { + id: 'colorRed', + svg: this.createColorCircle('red'), + action: (e) => this.setNodesColor(e, 'red') + }, + { + id: 'colorOrange', + svg: this.createColorCircle('orange'), + action: (e) => this.setNodesColor(e, 'orange') + }, + { + id: 'colorYellow', + svg: this.createColorCircle('yellow'), + action: (e) => this.setNodesColor(e, 'yellow') + }, + { + id: 'colorGreen', + svg: this.createColorCircle('green'), + action: (e) => this.setNodesColor(e, 'green') + }, + { + id: 'colorCyan', + svg: this.createColorCircle('cyan'), + action: (e) => this.setNodesColor(e, 'cyan') + }, + { + id: 'colorBlue', + svg: this.createColorCircle('blue'), + action: (e) => this.setNodesColor(e, 'blue') + }, + { + id: 'colorPurple', + svg: this.createColorCircle('purple'), + action: (e) => this.setNodesColor(e, 'purple') + }, + { + id: 'colorClear', + svg: this.createColorCircle('clear'), + action: this.resetNodesColor.bind(this) + }, + { + id: 'colorPick', + svg: this.createColorPickerIcon(), + action: () => this.openNativeColorPicker() + }, + { + id: 'hBtn_moveElement', + svg: hSvg_moveElement + }, + ]; + }, + showContextMenu() { + this.contextMenu = document.createElement('div'); + this.contextMenu.id = 'hContext-Menu'; + this.contextMenu.style.display = 'none'; + this.contextMenu.innerHTML = ` + + + + + + + `; + this.hMainToolbar.appendChild(this.contextMenu); + this.hMainToolbar.addEventListener('contextmenu', (event) => { + event.preventDefault(); + const isMenuVisible = this.contextMenu.style.display === 'block'; + const isClickInsideMenu = this.contextMenu.contains(event.target); + if (isMenuVisible) { + if (!isClickInsideMenu) { + this.contextMenu.style.display = 'none'; + } + } else { + this.contextMenu.style.display = 'block'; + this.contextMenu.style.left = `${event.pageX}px`; + this.contextMenu.style.top = `${event.pageY}px`; + } + }); + document.addEventListener('mousedown', (e) => { + if (this.contextMenu.style.display === 'block' && + !this.contextMenu.contains(e.target) && + !this.hMainToolbar.contains(e.target)) { + this.contextMenu.style.display = 'none'; + } + }); + this.contextMenu.addEventListener('contextmenu', (e) => { + e.preventDefault(); + this.contextMenu.style.display = 'none'; + }); + this.contextMenu.querySelector('#pin-mode').addEventListener('click', () => { + this.contextMenu.style.display = 'none'; + this.isPermanent = true; + localStorage.setItem('NodeAlignerIsPermanent', '1'); + this.restorePosition(); + }); + this.contextMenu.querySelector('#toggle-on-select').addEventListener('click', () => { + this.hMainToolbar.style.display = 'none'; + this.contextMenu.style.display = 'none'; + this.isPermanent = false; + localStorage.setItem('NodeAlignerIsPermanent', '0'); + }); + this.contextMenu.querySelector('#ui-scale-btn').addEventListener('click', (e) => { + this.systemWideZoom = e.ctrlKey; + this.toggleUIScale(e); + e.stopPropagation(); + }); + }, + show() { + this.isShow = true; + this.hMainToolbar.style.display = 'flex'; + }, + hide() { + this.isShow = false; + this.hMainToolbar.style.display = 'none'; + }, + setPosition(x, y) { + this.hMainToolbar.style.left = `${x}px`; + this.hMainToolbar.style.top = `${y}px`; + }, + toggleUIScale(e) { + const isCtrlPressed = e ? e.ctrlKey : this.systemWideZoom; + this.currentZoomIndex = (this.currentZoomIndex + 1) % this.zoomLevels.length; + const scale = this.zoomLevels[this.currentZoomIndex]; + if (isCtrlPressed) { + document.body.style.zoom = scale; + this.hMainToolbar.style.transform = ''; + } else { + this.hMainToolbar.style.transform = `scale(${scale})`; + document.body.style.zoom = ''; + } + // 直接更新按钮文本 + const scaleBtn = this.contextMenu.querySelector('#ui-scale-btn'); + if (scaleBtn) { + scaleBtn.textContent = `UI缩放${scale}x`; + } + }, + onDragStart(e) { + if (this.isDragging) return; + const ishBtn_moveElement = e.target.closest('#hBtn_moveElement') !== null; + const ishC_dividerLine = e.target.classList.contains('hC_dividerLine'); + if (!(ishBtn_moveElement || ishC_dividerLine)) return; + this.isDragging = true; + this.initialX = e.clientX; + this.initialY = e.clientY; + this.dragStartX = this.hMainToolbar.offsetLeft; + this.dragStartY = this.hMainToolbar.offsetTop; + document.addEventListener('mousemove', this.boundOnDragging); + document.addEventListener('mouseup', this.boundOnDragEnd); + this.isDragging = true; + }, + onDragging(e) { + if (this.isDragging) { + const originalWidth = this.hMainToolbar.offsetWidth; + const deltaX = e.clientX - this.initialX; + const deltaY = e.clientY - this.initialY; + let newLeft = this.dragStartX + deltaX; + let newTop = this.dragStartY + deltaY; + const containerRect = this.hMainToolbar.getBoundingClientRect(); + const windowWidth = window.innerWidth; + const windowHeight = window.innerHeight; + if (newLeft < 0) { + newLeft = 0; + } else if (newLeft + containerRect.width > windowWidth) { + newLeft = windowWidth - containerRect.width; + } + if (newTop < 0) { + newTop = 0; + } else if (newTop + containerRect.height > windowHeight) { + newTop = windowHeight - containerRect.height; + } + this.hMainToolbar.style.width = `${originalWidth}px`; + this.hMainToolbar.style.left = `${newLeft}px`; + this.hMainToolbar.style.top = `${newTop}px`; + this.hMainToolbar.style.left = `${newLeft}px`; + this.hMainToolbar.style.top = `${newTop}px`; + } + }, + validateAndAdjustPosition(pos) { + const containerRect = this.hMainToolbar.getBoundingClientRect(); + const windowWidth = window.innerWidth; + const windowHeight = window.innerHeight; + const safeLeft = Math.max(0, Math.min(pos.left, windowWidth - containerRect.width)); + const safeTop = Math.max(0, Math.min(pos.top, windowHeight - containerRect.height)); + if (Math.abs(pos.left - safeLeft) > 20 || Math.abs(pos.top - safeTop) > 20) { + return this.getCentralPosition(); + } + return { + left: safeLeft, + top: safeTop + }; + }, + getCentralPosition() { + return { + left: Math.max(0, window.innerWidth / 2 - this.hMainToolbar.offsetWidth / 2), + top: 20 + }; + }, + onDragEnd() { + this.isDragging = false; + document.removeEventListener('mousemove', this.boundOnDragging); + document.removeEventListener('mouseup', this.boundOnDragEnd); + const rect = this.hMainToolbar.getBoundingClientRect(); + const originalPos = { + left: rect.left, + top: rect.top + }; + const safePos = this.validateAndAdjustPosition(originalPos); + this.hMainToolbar.style.left = `${safePos.left}px`; + this.hMainToolbar.style.top = `${safePos.top}px`; + localStorage.setItem('NodeAlignerhMainToolbarPosition', JSON.stringify({ + left: safePos.left, + top: safePos.top + })); + this.hMainToolbar.style.width = 'fit-content'; + this.syncRunButtonPosition(); + }, + restorePosition() { + try { + const savedPosition = JSON.parse(localStorage.getItem('NodeAlignerhMainToolbarPosition')); + if (!savedPosition) { + this.setCentralPosition(); + return; + } + let pos = { + left: savedPosition.left || window.innerWidth / 2 - this.hMainToolbar.offsetWidth / 2, + top: savedPosition.top || 20 + }; + const validatedPos = this.validateAndAdjustPosition(pos); + this.hMainToolbar.style.left = `${validatedPos.left}px`; + this.hMainToolbar.style.top = `${validatedPos.top}px`; + localStorage.setItem('NodeAlignerhMainToolbarPosition', JSON.stringify(validatedPos)); + if (this.isRunButtonAligned) { + this.syncRunButtonPosition(); + } + const linkRunBtn = this.contextMenu?.querySelector('#link-run-btn'); + if (linkRunBtn) { + linkRunBtn.style.backgroundColor = this.linkColors[this.linkMode]; + } + } catch (e) { + console.warn('位置信息异常,重置到默认位置:', e); + this.setCentralPosition(); + } + }, + setCentralPosition() { + const pos = this.getCentralPosition(); + this.hMainToolbar.style.left = `${pos.left}px`; + this.hMainToolbar.style.top = `${pos.top}px`; + localStorage.setItem('NodeAlignerhMainToolbarPosition', JSON.stringify(pos)); + }, + getSelectedNodes() { + if (!LGraphCanvas.active_canvas) return []; + const selectedNodesObj = LGraphCanvas.active_canvas.selected_nodes; + return selectedNodesObj ? Object.values(selectedNodesObj) : []; + }, + adjustColorBrightness(hex, percent) { + hex = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b); + const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); + if (!result) return '#000000'; + let r = parseInt(result[1], 16); + let g = parseInt(result[2], 16); + let b = parseInt(result[3], 16); + const amount = Math.round(2.55 * percent * 100); + r = Math.min(255, Math.max(0, r + amount)); + g = Math.min(255, Math.max(0, g + amount)); + b = Math.min(255, Math.max(0, b + amount)); + return '#' + + (r | 1 << 8).toString(16).slice(1) + + (g | 1 << 8).toString(16).slice(1) + + (b | 1 << 8).toString(16).slice(1); + }, + applyColorToNode(node, color) { + if (!node || typeof node !== 'object') return; + try { + node.color = this.adjustColorBrightness(color, -0.1); + node.bgcolor = color; + if (node.setDirtyCanvas) { + node.setDirtyCanvas(true); + } + if (node.type === "Note") { + node.properties.text_color = this.adjustColorBrightness(color, 0.2); + } + } catch (error) { + console.error(`应用颜色到节点失败:`, error); + } + }, + getSelectedGroups(app) { + try { + if (app.canvas?.selected_group) { + return [app.canvas.selected_group]; + } + const groups = []; + if (app.graph?.groups) { + for (const group of app.graph.groups) { + if (group.selected) { + groups.push(group); + } + } + } + return groups; + } catch (error) { + console.error("获取选中组失败:", error); + return []; + } + }, + groupNodesByCoordinate(nodes, axis, tolerance = 1000) { + if (nodes.length < 4) { + return [nodes]; + } + const groups = []; + const otherAxis = 1 - axis; + nodes.sort((a, b) => a.pos[axis] - b.pos[axis]); + const gaps = []; + for (let i = 1; i < nodes.length; i++) { + gaps.push(nodes[i].pos[axis] - (nodes[i - 1].pos[axis] + nodes[i - 1].size[axis])); + } + const avgGap = gaps.reduce((sum, gap) => sum + gap, 0) / gaps.length; + const stdDevGap = Math.sqrt(gaps.reduce((sum, gap) => sum + Math.pow(gap - avgGap, 2), 0) / gaps.length); + const threshold = avgGap + stdDevGap; + let currentGroup = [nodes[0]]; + for (let i = 1; i < nodes.length; i++) { + const gap = nodes[i].pos[axis] - (nodes[i - 1].pos[axis] + nodes[i - 1].size[axis]); + const otherAxisDiff = Math.abs(nodes[i].pos[otherAxis] - nodes[i - 1].pos[otherAxis]); + if (gap <= threshold && otherAxisDiff <= tolerance) { + currentGroup.push(nodes[i]); + } else { + groups.push(currentGroup); + currentGroup = [nodes[i]]; + } + } + groups.push(currentGroup); + return groups; + }, + hBtnA_alignLeft() { + const selectedNodes = this.getSelectedNodes(); + if (selectedNodes.length === 0) { + const canvas = LGraphCanvas.active_canvas; + if (canvas) { + canvas.ds.offset = [80, 140]; + canvas.ds.scale = 1; + canvas.setDirty(true, true); + } + } else { + const groups = this.groupNodesByCoordinate(selectedNodes, 0); + groups.forEach(group => { + const leftMost = Math.min(...group.map(node => node.pos[0])); + group.forEach(node => { + node.pos[0] = leftMost; + }); + }); + } + LGraphCanvas.active_canvas.setDirty(true, true); + }, + hBtnC_alignRight() { + const selectedNodes = this.getSelectedNodes(); + if (selectedNodes.length > 0) { + const groups = this.groupNodesByCoordinate(selectedNodes, 0); + groups.forEach(group => { + const rightMost = Math.max(...group.map(node => node.pos[0] + node.size[0])); + group.forEach(node => { + node.pos[0] = rightMost - node.size[0]; + }); + }); + } + LGraphCanvas.active_canvas.setDirty(true, true); + }, + hBtnD_alignTop() { + const selectedNodes = this.getSelectedNodes(); + if (selectedNodes.length > 0) { + const groups = this.groupNodesByCoordinate(selectedNodes, 1); + groups.forEach(group => { + const topMost = Math.min(...group.map(node => node.pos[1])); + group.forEach(node => { + node.pos[1] = topMost; + }); + }); + } + LGraphCanvas.active_canvas.setDirty(true, true); + }, + hBtnF_alignButton() { + const selectedNodes = this.getSelectedNodes(); + if (selectedNodes.length > 0) { + const groups = this.groupNodesByCoordinate(selectedNodes, 1); + groups.forEach(group => { + const bottomMost = Math.max(...group.map(node => node.pos[1] + node.size[1])); + group.forEach(node => { + node.pos[1] = bottomMost - node.size[1]; + }); + }); + } + LGraphCanvas.active_canvas.setDirty(true, true); + }, + hBtnE_alignCenterH() { + const selectedNodes = this.getSelectedNodes(); + if (selectedNodes.length > 0) { + const groups = this.groupNodesByCoordinate(selectedNodes, 1); + groups.forEach(group => { + const centerY = this.calculateCenterInGroup(group, 1); + group.forEach(node => { + node.pos[1] = centerY - node.size[1] / 2; + }); + }); + } + LGraphCanvas.active_canvas.setDirty(true, true); + }, + hBtnB_alignCenterV() { + const selectedNodes = this.getSelectedNodes(); + if (selectedNodes.length > 0) { + const groups = this.groupNodesByCoordinate(selectedNodes, 0); + groups.forEach(group => { + const centerX = this.calculateCenterInGroup(group, 0); + group.forEach(node => { + node.pos[0] = centerX - node.size[0] / 2; + }); + }); + } + LGraphCanvas.active_canvas.setDirty(true, true); + }, + calculateCenterInGroup(group, axis) { + const minCoord = Math.min(...group.map(node => node.pos[axis])); + const maxCoord = Math.max(...group.map(node => node.pos[axis] + node.size[axis])); + return (minCoord + maxCoord) / 2; + }, + hBtnG_distributionH() { + const nodes = this.getSelectedNodes(); + const axis = 0; + if (nodes.length > 1) { + nodes.sort((a, b) => a.pos[axis] - b.pos[axis]); + const min = Math.min(...nodes.map(node => node.pos[axis])); + const max = Math.max(...nodes.map(node => node.pos[axis] + node.size[axis])); + const totalSize = nodes.reduce((sum, node) => sum + node.size[axis], 0); + const spacing = (max - min - totalSize) / (nodes.length - 1); + let current = min; + nodes.forEach(node => { + node.pos[axis] = current; + current += node.size[axis] + spacing; + }); + LGraphCanvas.active_canvas.setDirty(true, true); + } + }, + hBtnH_distributionV() { + const nodes = this.getSelectedNodes(); + if (nodes.length > 1) { + const axis = 1; + const otherAxis = 0; + const tolerance = 100; + const minSpacing = 20; + const columns = []; + nodes.forEach(node => { + let foundColumn = null; + for (let column of columns) { + const columnX = column[0].pos[otherAxis]; + if (Math.abs(columnX - node.pos[otherAxis]) <= tolerance) { + foundColumn = column; + break; + } + } + if (foundColumn) { + foundColumn.push(node); + } else { + columns.push([node]); + } + }); + const columnHeights = columns.map(column => { + const minY = Math.min(...column.map(node => node.pos[axis])); + const maxY = Math.max(...column.map(node => node.pos[axis] + node.size[axis])); + return maxY - minY; + }); + const maxColumnHeight = Math.max(...columnHeights); + columns.forEach((column, columnIndex) => { + if (column.length > 1) { + column.sort((a, b) => a.pos[axis] - b.pos[axis]); + const minY = Math.min(...column.map(node => node.pos[axis])); + const totalSize = column.reduce((sum, node) => sum + node.size[axis], 0); + let spacing = (maxColumnHeight - totalSize) / (column.length - 1); + spacing = Math.max(spacing, minSpacing); + let currentY = column[0].pos[axis]; + column.forEach((node, idx) => { + if (idx === 0) { + currentY += node.size[axis] + spacing; + } else { + node.pos[axis] = currentY; + currentY += node.size[axis] + spacing; + } + node.pos[otherAxis] = column[0].pos[otherAxis]; + }); + } else if (column.length === 1) { + const node = column[0]; + } + }); + LGraphCanvas.active_canvas.setDirty(true, true); + } + }, + hBtnI_equalWidth() { + this.equalSize(0); + }, + hBtnJ_equalHeight() { + this.equalSize(1); + }, + equalSize(axis) { + const nodes = this.getSelectedNodes(); + if (nodes.length > 0) { + const maxSize = Math.max(...nodes.map(node => node.size[axis])); + nodes.forEach(node => { + node.size[axis] = maxSize; + }); + LGraphCanvas.active_canvas.setDirty(true, true); + } + } + }; + + function pollForCanvas() { + const canvas = document.querySelector('canvas#graph-canvas'); + if (canvas) { + ButtonManager.init(); + canvas.addEventListener('click', function(event) { + if (!ButtonManager.isPermanent) { + const selectedNodes = ButtonManager.getSelectedNodes(); + if (selectedNodes.length >= 2) { + ButtonManager.show(); + ButtonManager.setPosition(event.layerX - 240, event.layerY - 20); + } else { + ButtonManager.hide(); + } + } + }); + } else { + setTimeout(pollForCanvas, 1000); + } + } + pollForCanvas(); \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f0e873f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,14 @@ +[project] +name = "ComfyUI_EasyKitHT_NodeAlignPro" +description = "ComfyUI_EasyKitHT_NodeAlignPro is a lightweight ComfyUI node alignment and node coloring tool for refactoring and rewriting the UI based on the open-source projects Comfyui-Align and Comfyui-Nodealigner." +version = "1.0.1" +license = {file = "LICENSE"} + +[project.urls] +Repository = "https://github.com/ArtsticH/ComfyUI_EasyKitHT_NodeAlignPro" +# Used by Comfy Registry https://comfyregistry.org + +[tool.comfy] +PublisherId = "" +DisplayName = "ComfyUI_EasyKitHT_NodeAlignPro" +Icon = "" diff --git a/web/color_svgs.js b/web/color_svgs.js new file mode 100644 index 0000000..455c43f --- /dev/null +++ b/web/color_svgs.js @@ -0,0 +1,16 @@ +// ComfyUI_EasyKitHT_NodeAlignPro/web/color_svgs.js +export const ColorSVGs = { + circle: (color) => ` + + + + `, + + colorPicker: ` + + + + ` + +}; \ No newline at end of file