├── .gitignore ├── LICENCE.md ├── Noise, Patterns and Textures.manifest ├── Noise, Patterns and Textures.py ├── README.md ├── ext ├── __pycache__ │ └── png.cpython-38.pyc ├── bin │ ├── prichunkpng │ ├── priditherpng │ ├── priforgepng │ ├── prigreypng │ ├── pripalpng │ ├── pripamtopng │ ├── pripnglsch │ ├── pripngtopam │ └── priweavepng ├── png.py └── pypng-0.0.21.dist-info │ ├── INSTALLER │ ├── LICENCE │ ├── METADATA │ ├── RECORD │ ├── REQUESTED │ ├── WHEEL │ └── top_level.txt ├── helpers ├── mathHelper.py ├── meshHelper.py └── pngHelper.py ├── noises ├── grungeMapNoise.py ├── perlinNoise.py ├── randomNoise.py ├── valueNoise.py └── worleyNoise.py └── resources ├── Body1.mtl ├── Body1.obj ├── button ├── .DS_Store ├── 16x16-disabled.png ├── 16x16-normal.png ├── 32x32-normal.png ├── 64x64-normal.png └── toolClip.png ├── exampleGrungeMaps ├── GrungeMap_001.png ├── GrungeMap_002.png ├── GrungeMap_003.png ├── GrungeMap_004.png ├── GrungeMap_005.png ├── GrungeMap_006.png ├── GrungeMap_007.png ├── GrungeMap_008.png ├── GrungeMap_009.png ├── GrungeMap_010.png ├── GrungeMap_011.png ├── GrungeMap_012.png ├── GrungeMap_013.png ├── GrungeMap_014.png ├── GrungeMap_015.png ├── australia.png ├── heightmap.png ├── ireland.png ├── liquid.png └── mountain.png ├── fileDialogButton ├── 16x16-disabled.png ├── 16x16-normal.png ├── 32x32-disabled.png ├── 32x32-normal.png └── 64x64-normal.png ├── newButton ├── 16x16-normal.png ├── 32x32-normal.png ├── 64x64-normal.png └── old.png ├── planeButtons ├── xY │ ├── 16x16-disabled.png │ ├── 16x16-normal.png │ ├── 32x32-disabled.png │ ├── 32x32-normal.png │ └── 64x64-normal.png ├── xZ │ ├── 16x16-disabled.png │ ├── 16x16-normal.png │ ├── 32x32-disabled.png │ ├── 32x32-normal.png │ └── 64x64-normal.png └── yZ │ ├── 16x16-disabled.png │ ├── 16x16-normal.png │ ├── 32x32-disabled.png │ ├── 32x32-normal.png │ └── 64x64-normal.png └── readme ├── australiaScreen.png ├── heads.png ├── newheads.png ├── paint.png ├── preview.png ├── sphere.png ├── sphereNoise.png ├── sphereRender.PNG ├── usage.gif ├── valueNoisePlane.png ├── well.png └── working.png /.gitignore: -------------------------------------------------------------------------------- 1 | # local files and folders 2 | .* -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /Noise, Patterns and Textures.manifest: -------------------------------------------------------------------------------- 1 | { 2 | "autodeskProduct": "Fusion360", 3 | "type": "addin", 4 | "id": "8dda2846-42fb-4678-ae6a-8221ae8951bb", 5 | "author": "Leon Müller", 6 | "description": { 7 | "": "" 8 | }, 9 | "version": "0.1", 10 | "runOnStartup": true, 11 | "supportedOS": "windows|mac", 12 | "editEnabled": true 13 | } -------------------------------------------------------------------------------- /Noise, Patterns and Textures.py: -------------------------------------------------------------------------------- 1 | #Author- Leon Müller 2 | #Description- A Fusion360 Add-In that lets you add noise, patterns, and textures to your MeshBodies. 3 | 4 | from tokenize import Double 5 | import adsk.core, adsk.fusion, adsk.cam, traceback, os, sys, random, time 6 | 7 | from .helpers import mathHelper 8 | from .helpers import meshHelper 9 | from .helpers import pngHelper 10 | from .helpers.meshHelper import Body, calculateAppropriateNoiseLevel, calculateAverageFaceSize #our own body class 11 | 12 | from .noises.valueNoise import * 13 | from .noises.perlinNoise import * 14 | from .noises.randomNoise import * 15 | from .noises.worleyNoise import * 16 | from .noises.grungeMapNoise import * 17 | 18 | handlers = [] 19 | defaultCommandInputs = ['advancedGroup','seedField','degree','dropList','body_input', 'previewBox','algDesc'] 20 | groupCommandChildren = ['stepHeightField', 'stepPaddingField'] 21 | groupCommands = ['advancedGroup', 'stepGroup'] 22 | panelString = 'ParaMeshModifyPanel' 23 | lastChangedInput = '' 24 | 25 | lastStepGroupValue = False 26 | lastAdvancedGroupValue = False 27 | 28 | previewIsActive = False 29 | currentGrungeMap: GrungeMap = None 30 | currentPreview = [] 31 | currentPreviewMesh = [] 32 | 33 | 34 | 35 | def run(context): 36 | ui = None 37 | try: 38 | app = adsk.core.Application.get() 39 | ui = app.userInterface 40 | 41 | #global progressDialog 42 | #progressDialog = ui.createProgressDialog() 43 | #pngHelper.readPng() 44 | 45 | # Get the CommandDefinitions collection. 46 | cmdDefs = ui.commandDefinitions 47 | # Create a button command definition. 48 | buttonSample = cmdDefs.addButtonDefinition('NoiseButton', 49 | 'Noise, Patterns and Textures', 50 | 'Lets you add noise, patterns, and textures to your MeshBodies.\n Provides a selection of algorithms and paramaterized settings.', 51 | './resources/newButton') 52 | buttonSample.toolClipFilename = 'resources/button/toolClip.png' 53 | # Connect to the command created event. 54 | sampleCommandCreated = SampleCommandCreatedEventHandler() 55 | buttonSample.commandCreated.add(sampleCommandCreated) 56 | handlers.append(sampleCommandCreated) 57 | 58 | 59 | # Get the ADD-INS panel in the model workspace. 60 | 61 | addInsPanel = ui.allToolbarPanels.itemById(panelString) 62 | # Add the button to the bottom of the panel. 63 | buttonControl = addInsPanel.controls.addCommand(buttonSample) 64 | # Make the button available in the panel. 65 | buttonControl.isPromotedByDefault = True 66 | buttonControl.isPromoted = True 67 | 68 | except: 69 | if ui: 70 | ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 71 | 72 | # Event handler for the commandCreated event. (The Add-In view is opened) 73 | class SampleCommandCreatedEventHandler(adsk.core.CommandCreatedEventHandler): 74 | def __init__(self): 75 | super().__init__() 76 | def notify(self, args): 77 | app = adsk.core.Application.get() 78 | ui = app.userInterface 79 | eventArgs = adsk.core.CommandCreatedEventArgs.cast(args) 80 | cmd = eventArgs.command 81 | 82 | # Get the CommandInputs collection to create new command inputs. 83 | inputs = cmd.commandInputs 84 | 85 | global previewIsActive, currentPreview, currentPreviewMesh, lastStepGroupValue, lastAdvancedGroupValue 86 | previewIsActive = False 87 | currentPreview = [] 88 | currentPreviewMesh = [] 89 | lastAdvancedGroupValue = False 90 | lastStepGroupValue = False 91 | 92 | cmd.okButtonText = "Generate" 93 | #cmd.setDialogInitialSize(100,100) 94 | cmd.isExecutedWhenPreEmpted = False 95 | #cmd.helpFile = '/Users/lmueller/Library/Application Support/Autodesk/Autodesk Fusion 360/API/AddIns/Noisy Surfaces/resources/helpPages/buttonHelp.html' 96 | # Create selection input 97 | body_input = inputs.addSelectionInput('body_input', 'Select MeshBody', 'Select MeshBody to apply noise to') 98 | # select only meshbodies 99 | body_input.addSelectionFilter('MeshBodies') 100 | body_input.tooltip = "Select the target MeshBodies" 101 | # I can select more than one body 102 | body_input.setSelectionLimits(0) 103 | dropDown = inputs.addDropDownCommandInput('dropList', 'Algorithm', adsk.core.DropDownStyles.TextListDropDownStyle) 104 | dropDown.tooltip = "Choose a noise algorithm" 105 | dropDown.listItems.add('Value Noise', True, '') 106 | dropDown.listItems.add('Perlin Noise', False, '') 107 | dropDown.listItems.add('Worley Noise', False, '') 108 | dropDown.listItems.add('Random Noise', False, '') 109 | dropDown.listItems.add('Adaptive Noise', False, '') 110 | dropDown.listItems.add('Grunge Map', False, '') 111 | #dropDown.isFullWidth(False) 112 | 113 | algDescriptionBox = inputs.addTextBoxCommandInput('algDesc', 'Description', "This is only a test of the functionality of the box",3,True) 114 | algDescriptionBox.text = "Generates noise based on a continous function. The dimension of the function can be specified as well as the resolution." 115 | #test = inputs.addIntegerSliderListCommandInput('test', 'test', list(range(2,20))+list(range(20,100,5))) 116 | 117 | 118 | #degree = inputs.addValueInput('degree', 'Noise Level', '', adsk.core.ValueInput.createByReal(0.25)) 119 | degree = inputs.addFloatSliderCommandInput('degree', 'Level', "", 0, 3) 120 | degree.spinStep = 0.25 121 | degree.valueOne = 1 122 | degree.tooltip = "Sets the level of noise" 123 | #numberField.isEnabled = False 124 | #Create a check box 125 | inverseBox = inputs.addBoolValueInput('inverseBox', 'Inverse', True, '', False) 126 | inverseBox.isVisible = False 127 | inverseBox.tooltip = "Inverts the result" 128 | #Create 3 Dimension button row 129 | dim3Buttons = inputs.addRadioButtonGroupCommandInput('dim3Buttons', 'Dimension') 130 | #dim3Buttons.isVisible = False 131 | dim3Buttons.listItems.add('1D', False) 132 | dim3Buttons.listItems.add('2D', False) 133 | dim3Buttons.listItems.add('3D', True) 134 | #Create 2 Dimension button row 135 | dim2Buttons = inputs.addRadioButtonGroupCommandInput('dim2Buttons', 'Dimension') 136 | dim2Buttons.isVisible = False 137 | dim2Buttons.listItems.add('2D', False) 138 | dim2Buttons.listItems.add('3D', True) 139 | 140 | smoothBox = inputs.addBoolValueInput('smoothBox', 'Smooth', True, '', True) 141 | #smoothBox.isVisible = False 142 | smoothBox.tooltip = "Smoothes the result" 143 | 144 | resolutionField = inputs.addIntegerSpinnerCommandInput('resolutionField', 'Resolution', 2, 1000, 1, 10) 145 | resolutionField.tooltip = "Sets the resolution of the applied noise function. \nThe higher the resolution, the more features are visible." 146 | #resolutionField.isVisible = False 147 | 148 | resolutionYField = inputs.addIntegerSpinnerCommandInput('resolutionYField', 'ResolutionY', 2, 1000, 1, 10) 149 | resolutionYField.tooltip = "Sets the y-resolution of the applied noise function. \nThe higher the resolution, the more features are visible." 150 | 151 | resolutionZField = inputs.addIntegerSpinnerCommandInput('resolutionZField', 'ResolutionZ', 2, 1000, 1, 10) 152 | resolutionZField.tooltip = "Sets the z-resolution of the applied noise function. \nThe higher the resolution, the more features are visible." 153 | 154 | # Plane input for 2D noise 155 | #planeInput = inputs.addSelectionInput('planeInput', 'Plane', 'Select Plane to apply noise to.') 156 | #planeInput.addSelectionFilter('ConstructionPlanes') 157 | #planeInput.setSelectionLimits(0,1) 158 | planeInput = inputs.addButtonRowCommandInput('planeInput', 'Plane', False) 159 | planeInput.listItems.add("xY", True, 'resources/planeButtons/xY') 160 | planeInput.listItems.add("xZ", False, 'resources/planeButtons/xZ') 161 | planeInput.listItems.add("yZ", False, 'resources/planeButtons/yZ') 162 | planeInput.isVisible = False 163 | planeInput.tooltip = "Choose an origin plane that the map is projected onto" 164 | ## Experimental Image Input 165 | fileDialogButton = inputs.addBoolValueInput('fileDialogButton', 'Choose Grunge Map', False, 'resources/fileDialogButton') 166 | fileDialogButton.isVisible = False 167 | fileDialogButton.tooltip = "Choose a PNG Grunge Map." 168 | imageField = inputs.addImageCommandInput('imageField', '', './resources/exampleGrungeMaps/GrungeMap_008.png') 169 | #imageField.isFullWidth = True 170 | imageField.isVisible = False 171 | 172 | # All Command inputs for the step function settings 173 | # Create group input. 174 | groupStepInput = inputs.addGroupCommandInput('stepGroup', 'Activate Step Function') 175 | groupStepInput.isExpanded = False 176 | groupStepInput.isEnabledCheckBoxDisplayed = True 177 | groupStepInput.isEnabledCheckBoxChecked = False 178 | groupStepInput.isVisible = False 179 | groupStepChildInputs = groupStepInput.children 180 | #stepHeightField = groupStepChildInputs.addValueInput('stepHeightField', 'Step Height','mm',adsk.core.ValueInput.createByReal(0.5)) 181 | stepPaddingField = groupStepChildInputs.addValueInput('stepPaddingField', 'Padding', 'mm',adsk.core.ValueInput.createByReal(0.1)) 182 | 183 | groupAdvancedInput = inputs.addGroupCommandInput('advancedGroup', 'Advanced Settings') 184 | groupAdvancedInput.isExpanded = False 185 | groupAdvancedChildInputs = groupAdvancedInput.children 186 | seedField = groupAdvancedChildInputs.addStringValueInput('seedField', 'Seed', '') 187 | seedField.tooltip = "Optinal: Sets a seed for the RNG.\n The same seed will always produce the same result." 188 | #frequencyField = groupAdvancedChildInputs.addFloatSliderCommandInput('frequencyField', 'Frequency', '', 0, 1, False) 189 | #frequencyField.spinStep = 0.1 190 | #frequencyField.setText("0","1") 191 | #frequencyField.valueOne = 1 192 | frequencyField = groupAdvancedChildInputs.addValueInput('frequencyField', 'Frequency', '', adsk.core.ValueInput.createByReal(1)) 193 | frequencyField.isVisible = False 194 | #Create signed checkbox 195 | signedBox = groupAdvancedChildInputs.addBoolValueInput('signedBox', 'Signed', True, '', True) 196 | signedBox.tooltip = "Sets wether the noise can be negative" 197 | #signedBox.isVisible = False 198 | 199 | #Create Preview Checkbox 200 | previewBox = inputs.addBoolValueInput('previewBox', 'Preview', True, '', False) 201 | previewBox.tooltip = "Displays a preview of the result with the current settings" 202 | 203 | # Connect to the execute event. 204 | onExecute = SampleCommandExecuteHandler() 205 | cmd.execute.add(onExecute) 206 | handlers.append(onExecute) 207 | #ui.messageBox('Creating the command???') 208 | 209 | # Connect to the inputChanged event. 210 | onInputChanged = SampleCommandInputChangedHandler() 211 | cmd.inputChanged.add(onInputChanged) 212 | handlers.append(onInputChanged) 213 | 214 | #Connect to the execute preview event 215 | onExecutePreview = SampleCommandExecutePreviewHandler() 216 | cmd.executePreview.add(onExecutePreview) 217 | handlers.append(onExecutePreview) 218 | 219 | # Event handler for the inputChanged event. 220 | class SampleCommandInputChangedHandler(adsk.core.InputChangedEventHandler): 221 | def __init__(self): 222 | super().__init__() 223 | def notify(self, args): 224 | try: 225 | app = adsk.core.Application.get() 226 | ui = app.userInterface 227 | product = app.activeProduct #the fusion tab that is active 228 | rootComp = product.rootComponent # the root component of the active product 229 | eventArgs = adsk.core.InputChangedEventArgs.cast(args) 230 | inputs = eventArgs.firingEvent.sender.commandInputs 231 | # Check the value of the check box. 232 | changedInput = eventArgs.input 233 | global lastChangedInput, currentGrungeMap 234 | global previewIsActive, currentPreview, currentPreviewMesh 235 | lastChangedInput = changedInput.id 236 | if changedInput.id == 'previewBox': 237 | previewIsActive = not previewIsActive 238 | currentPreview = [] 239 | currentPreviewMesh = [] 240 | elif changedInput.id == 'dropList': 241 | for i in inputs: 242 | if not i.id in defaultCommandInputs and not i.id in groupCommandChildren: 243 | i.isVisible = False 244 | elif i.id in defaultCommandInputs or i.id in groupCommandChildren: 245 | i.isVisible = True 246 | inverseBox = inputs.itemById('inverseBox') 247 | dim3Buttons = inputs.itemById('dim3Buttons') 248 | dim2Buttons = inputs.itemById('dim2Buttons') 249 | signedBox = inputs.itemById('signedBox') 250 | smoothBox = inputs.itemById('smoothBox') 251 | stepGroup = inputs.itemById('stepGroup') 252 | advancedGroup = inputs.itemById('advancedGroup') 253 | resolutionField = inputs.itemById('resolutionField') 254 | resolutionYField = inputs.itemById('resolutionYField') 255 | resolutionZField = inputs.itemById('resolutionZField') 256 | frequencyField = inputs.itemById('frequencyField') 257 | imageField = inputs.itemById('imageField') 258 | fileDialogButton = inputs.itemById('fileDialogButton') 259 | planeInput = inputs.itemById('planeInput') 260 | algDescriptionBox = inputs.itemById('algDesc') 261 | 262 | previewBox = inputs.itemById('previewBox') 263 | previewBox.value =False 264 | previewIsActive = False 265 | currentPreview = [] 266 | currentPreviewMesh = [] 267 | 268 | # Change the visibility of the scale value input. 269 | if changedInput.selectedItem.name == 'Adaptive Noise': 270 | inverseBox.isVisible = True 271 | algDescriptionBox.text = "A randomly generated noise that preserves the more granular/detailed areas of the mesh. If the 'inverse' box is checked, the less detailed areas of the mesh will be preserved." 272 | elif changedInput.selectedItem.name == 'Value Noise': 273 | dim3Buttons.isVisible = True 274 | signedBox.isVisible = True 275 | smoothBox.isVisible = True 276 | resolutionField.isVisible = True 277 | resolutionYField.isVisible = True 278 | resolutionZField.isVisible = True 279 | #frequencyField.isVisible = True 280 | algDescriptionBox.text = "Generates noise based on a continous function. The dimension of the function can be specified as well as the resolution." 281 | elif changedInput.selectedItem.name == 'Perlin Noise': 282 | dim2Buttons.isVisible = True 283 | signedBox.isVisible = True 284 | smoothBox.isVisible = True 285 | resolutionField.isVisible = True 286 | #frequencyField.isVisible = True 287 | algDescriptionBox.text = "Generates noise based on a continous function. The dimension of the function can be specified as well as the resolution." 288 | elif changedInput.selectedItem.name == 'Worley Noise': 289 | dim2Buttons.isVisible = True 290 | resolutionField.isVisible = True 291 | stepGroup.isVisible = True 292 | algDescriptionBox.text = "Generates noise based on distances to randomly distributed points across the mesh. The number of feature points can be set with 'resolution'." 293 | elif changedInput.selectedItem.name == 'Grunge Map': 294 | #rootComp.isOriginFolderLightBulbOn = True 295 | planeInput.isVisible = True 296 | inverseBox.isVisible = True 297 | advancedGroup.isVisible = False 298 | smoothBox.isVisible = True 299 | imageField.isVisible = True 300 | fileDialogButton.isVisible = True 301 | currentGrungeMap = pngHelper.readPng(imageField.imageFile) 302 | algDescriptionBox.text = "Generates noise based on a PNG image Grunge Map." 303 | elif changedInput.selectedItem.name == 'Random Noise': 304 | algDescriptionBox.text = "A randomly generated noise." 305 | elif changedInput.id == 'fileDialogButton': 306 | fileDialog = ui.createFileDialog() 307 | fileDialog.isMultiSelectEnabled = False 308 | #print(os.path.dirname(os.path.abspath(__file__))+'/resources/exampleGrungeMaps') 309 | fileDialog.initialDirectory = os.path.dirname(os.path.abspath(__file__))+'/resources/exampleGrungeMaps' 310 | fileDialog.title = 'Choose Grunge Map Image' 311 | fileDialog.filter = '*.png' 312 | result = fileDialog.showOpen() 313 | #Set the new image if one was selected 314 | if result == 0: 315 | filename = fileDialog.filename 316 | imageField = inputs.itemById('imageField') 317 | imageField.imageFile = filename 318 | currentGrungeMap = pngHelper.readPng(filename) 319 | elif changedInput.id == 'body_input': 320 | bodyInput = inputs.itemById('body_input') 321 | degreeField = inputs.itemById('degree') 322 | if bodyInput.selectionCount > 0: 323 | selection = bodyInput.selection(0).entity 324 | mesh = selection.mesh 325 | body = meshHelper.fusionPolygonMeshToBody(mesh) 326 | degreeField.valueOne = calculateAppropriateNoiseLevel(body) 327 | else: 328 | currentPreview = [] 329 | currentPreviewMesh = [] 330 | 331 | 332 | app.activeViewport.refresh() 333 | except: 334 | if ui: 335 | ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 336 | 337 | 338 | # Event handler for the executePreview event. 339 | class SampleCommandExecutePreviewHandler(adsk.core.CommandEventHandler): 340 | def __init__(self): 341 | super().__init__() 342 | 343 | def notify(self, args): 344 | app = adsk.core.Application.get() 345 | ui = app.userInterface 346 | 347 | try: 348 | progressDialog = ui.createProgressDialog() 349 | progressDialog.hide() 350 | 351 | eventArgs = adsk.core.CommandEventArgs.cast(args) 352 | inputs = eventArgs.command.commandInputs 353 | stepActive = inputs.itemById('stepGroup').isEnabledCheckBoxChecked 354 | advancedActive = inputs.itemById('advancedGroup').isExpanded 355 | 356 | global currentPreview, currentPreviewMesh, lastStepGroupValue, lastAdvancedGroupValue 357 | # The if - block is accessed if a group command input was expanded or collapsed without value changes 358 | # The elif is accessed else 359 | if lastChangedInput in groupCommands and previewIsActive and stepActive == lastStepGroupValue: 360 | selectionList = [] 361 | for i in range(inputs.itemById('body_input').selectionCount): 362 | selectionList.append(inputs.itemById('body_input').selection(i).entity) 363 | for selection in selectionList: 364 | selection.isLightBulbOn = False 365 | mesh = selection.mesh 366 | if len(currentPreview) > 0: 367 | for body, mesh in zip(currentPreview, currentPreviewMesh): 368 | showMeshPreview(body,mesh) 369 | elif previewIsActive and (not lastChangedInput == 'advancedGroup') and (not lastChangedInput == 'dropList'): 370 | if not stepActive == lastStepGroupValue: 371 | lastStepGroupValue = stepActive 372 | if not advancedActive == lastAdvancedGroupValue: 373 | lastAdvancedGroupValue = advancedActive 374 | 375 | product = app.activeProduct #the fusion tab that is active 376 | rootComp = product.rootComponent # the root component of the active product 377 | meshBodies = rootComp.meshBodies 378 | algorithm, seed, degree, dimension3, dimension2, signed, smooth, resolution, resolutionY, resolutionZ, frequency, inverse, stepActive, stepPadding, planeString = getInputs(inputs) 379 | 380 | currentPreview = [] 381 | currentPreviewMesh = [] 382 | 383 | selectionList = [] 384 | for i in range(inputs.itemById('body_input').selectionCount): 385 | selectionList.append(inputs.itemById('body_input').selection(i).entity) 386 | for selection in selectionList: 387 | mesh = selection.mesh 388 | body = meshHelper.fusionPolygonMeshToBody(mesh) 389 | 390 | computeNoise(progressDialog, algorithm, seed, degree, dimension3, dimension2, signed, smooth, resolution, resolutionY, resolutionZ, frequency, inverse, stepActive, stepPadding, planeString, body) 391 | 392 | selection.isLightBulbOn = False 393 | currentPreview.append(body) 394 | currentPreviewMesh.append(mesh) 395 | showMeshPreview(body,mesh) 396 | app.activeViewport.refresh() 397 | except ValueError as err: 398 | if 'CanceledProgress'in err.args: 399 | currentPreview = [] 400 | currentPreviewMesh = [] 401 | progressDialog.hide() 402 | else: 403 | ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 404 | except: 405 | ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 406 | 407 | 408 | 409 | 410 | # Event handler for the execute event. 411 | class SampleCommandExecuteHandler(adsk.core.CommandEventHandler): 412 | def __init__(self): 413 | super().__init__() 414 | 415 | def notify(self, args): 416 | app = adsk.core.Application.get() 417 | ui = app.userInterface 418 | 419 | try: 420 | progressDialog = ui.createProgressDialog() 421 | progressDialog.hide() 422 | 423 | product = app.activeProduct #the fusion tab that is active 424 | rootComp = product.rootComponent # the root component of the active product 425 | meshBodies = rootComp.meshBodies 426 | eventArgs = adsk.core.CommandEventArgs.cast(args) 427 | # Get the values from the command inputs. 428 | inputs = eventArgs.command.commandInputs 429 | algorithm, seed, degree, dimension3, dimension2, signed, smooth, resolution, resolutionY, resolutionZ, frequency, inverse, stepActive, stepPadding, planeString = getInputs(inputs) 430 | 431 | selectionList = [] 432 | for i in range(inputs.itemById('body_input').selectionCount): 433 | selectionList.append(inputs.itemById('body_input').selection(i).entity) 434 | for i, selection in enumerate(selectionList): 435 | mesh = selection.mesh 436 | body = meshHelper.fusionPolygonMeshToBody(mesh) 437 | 438 | if len(currentPreview) > 0: 439 | body = currentPreview[i] 440 | else: 441 | computeNoise(progressDialog, algorithm, seed, degree, dimension3, dimension2, signed, smooth, resolution, resolutionY, resolutionZ, frequency, inverse, stepActive, stepPadding, planeString, body) 442 | 443 | # Hide the original meshBody, add and name the new one 444 | selection.isLightBulbOn = False 445 | meshBody = meshBodies.addByTriangleMeshData([x for y in body.vertices for x in y],mesh.triangleNodeIndices,[],[]) 446 | meshBody.name = selection.name + "-" + algorithm 447 | except ValueError as err: 448 | if 'CanceledProgress'in err.args: 449 | pass 450 | else: 451 | ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 452 | except: 453 | ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 454 | 455 | def getInputs(inputs): 456 | algorithm = inputs.itemById('dropList').selectedItem.name 457 | seed = (inputs.itemById('seedField').value).strip() 458 | if seed == '': 459 | seed = None 460 | degree = inputs.itemById('degree').valueOne 461 | dimension3 = inputs.itemById('dim3Buttons').selectedItem.name 462 | dimension2 = inputs.itemById('dim2Buttons').selectedItem.name 463 | signed = inputs.itemById('signedBox').value 464 | smooth = inputs.itemById('smoothBox').value 465 | resolution = inputs.itemById('resolutionField').value 466 | resolutionY = inputs.itemById('resolutionYField').value 467 | resolutionZ = inputs.itemById('resolutionZField').value 468 | frequency = inputs.itemById('frequencyField').value 469 | inverse = inputs.itemById('inverseBox').value 470 | stepActive = inputs.itemById('stepGroup').isEnabledCheckBoxChecked 471 | stepPadding = inputs.itemById('stepPaddingField').value 472 | 473 | #Get the construction plane and turn it into a string 474 | planeInput = inputs.itemById('planeInput') 475 | planeString = None 476 | if planeInput.selectedItem.name == "xY": 477 | planeString = 'xY' 478 | elif planeInput.selectedItem.name == "xZ": 479 | planeString = 'xZ' 480 | elif planeInput.selectedItem.name == "yZ": 481 | planeString = 'yZ' 482 | return algorithm,seed,degree,dimension3,dimension2,signed,smooth,resolution,resolutionY,resolutionZ,frequency,inverse,stepActive,stepPadding,planeString 483 | 484 | def computeNoise(progressDialog, algorithm, seed, degree, dimension3, dimension2, signed, smooth, resolution, resolutionY, resolutionZ, frequency, inverse, stepActive, stepPadding, planeString, body): 485 | progressDialog.show('Computing Noise...', 'Percentage: %p% - %v/%m steps completed',0,len(body.vertices),2) 486 | if algorithm == 'Adaptive Noise': 487 | progressDialog.show('Computing Noise...', 'Percentage: %p% - %v/%m steps completed',0,len(body.facets),2) 488 | adaptiveVertexDistortion(body, degree, inverse, seed, progressDialog) 489 | elif algorithm == 'Random Noise': 490 | randomDistortion(body, degree, seed) 491 | elif algorithm == 'Value Noise': 492 | if dimension3 == '1D': 493 | valueNoise1D(body,resolution,degree,frequency,signed,smooth,seed,progressDialog) 494 | elif dimension3 == '2D': 495 | valueNoise2D(body,resolution,resolutionY,degree,frequency,signed,smooth,seed, progressDialog) 496 | elif dimension3 == '3D': 497 | valueNoise3D(body,resolution,resolutionY,resolutionZ,degree,frequency,signed,smooth,seed, progressDialog) 498 | elif algorithm == 'Perlin Noise': 499 | if dimension2 == '2D': 500 | perlinNoise2D(body,resolution,degree,frequency,signed,smooth,seed,progressDialog) 501 | elif dimension2 == '3D': 502 | perlinNoise3D(body,resolution,degree,frequency,signed,smooth,seed,progressDialog) 503 | elif algorithm == 'Worley Noise': 504 | if dimension2 == '2D': 505 | worleyNoise2D(body, resolution, degree, stepActive, stepPadding, seed=seed, progressDialog=progressDialog) 506 | elif dimension2 == '3D': 507 | worleyNoise3D(body, resolution, degree, stepActive, stepPadding, seed=seed, progressDialog=progressDialog) 508 | elif algorithm == 'Grunge Map': 509 | grungeMapNoise(body,currentGrungeMap,degree,inverse,smooth, planeString, progressDialog) 510 | 511 | def showMeshPreview(body:Body, mesh:adsk.fusion.MeshBody): 512 | try: 513 | app = adsk.core.Application.get() 514 | ui = app.userInterface 515 | product = app.activeProduct 516 | rootComp = product.rootComponent 517 | graphics = rootComp.customGraphicsGroups.add() 518 | graphics.id = 'MeshPreview' 519 | coords = adsk.fusion.CustomGraphicsCoordinates.create([x for y in body.vertices for x in y]) 520 | lines = graphics.addLines(coords, mesh.triangleNodeIndices, False, []) 521 | lines.weight = 1 522 | meshGraphics = graphics.addMesh(coords, mesh.triangleNodeIndices, [], []) 523 | #color = adsk.core.Color.create(219, 213, 26,100) 524 | #colorEffect = adsk.fusion.CustomGraphicsShowThroughColorEffect.create(color, 0.25) 525 | #colorEffect = adsk.fusion.CustomGraphicsSolidColorEffect.create(color) 526 | #mesh.color = colorEffect 527 | except: 528 | if ui: 529 | ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 530 | 531 | def addToTimeline(): 532 | app = adsk.core.Application.get() 533 | ui = app.userInterface 534 | product = app.activeProduct 535 | timeline = product.timeline 536 | groups = timeline.timelineGroups 537 | group = groups.add(1,2) 538 | 539 | 540 | def stop(context): 541 | ui = None 542 | try: 543 | app = adsk.core.Application.get() 544 | ui = app.userInterface 545 | # Delete the button definition. 546 | buttonExample = ui.commandDefinitions.itemById('NoiseButton') 547 | if buttonExample: 548 | buttonExample.deleteMe() 549 | 550 | # Get panel the control is in. 551 | addInsPanel = ui.allToolbarPanels.itemById(panelString) 552 | 553 | # Get and delete the button control. 554 | buttonControl = addInsPanel.controls.itemById('NoiseButton') 555 | if buttonControl: 556 | buttonControl.deleteMe() 557 | 558 | except: 559 | if ui: 560 | ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 561 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fusion360 Noise, Patterns and Textures 2 | 3 | A Fusion360 Add-In that allows users to add randomly generated noise and patterns to their bodies and surfaces for a more natural, rough look and feel. There are numerous options for customizing surface noises and distorting any object in Fusion. Applicable to any MeshBody. 4 | Textures can be added to surfaces from images and grunge maps. 5 | 6 | ![TrailerImage](/resources/readme/heads.png) 7 | 8 | # Installation 9 | 10 | Download the zip folder of this project by clicking the green "<> Code" button at the top of this page and selecting "Download ZIP". 11 | 12 | Follow the instructions for manually installing an Add-In: https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/How-to-install-an-ADD-IN-and-Script-in-Fusion-360.html 13 | 14 | ### IMPORTANT: 15 | A detail in the instruction -- which can be easily overlooked -- is that the folder has to have the exact same name as the main script of the Plugin. Rename the directory from "Fusion360PatternsAndTextures" (or whatever it is called on your machine) to "Noise, Patterns and Textures". 16 | 17 | Afterward, the Scripts and Add-Ins submenu now displays the Add-In, which can be executed. 18 | The Add-In button to can be found in the mesh tab under the "MODIFY" tool category. 19 | 20 | # Examples 21 | 22 | ![TrailerImage](/resources/readme/usage.gif) 23 | ![TrailerImage](/resources/readme/preview.png) 24 | ![TrailerImage](/resources/readme/valueNoisePlane.png) 25 | ![TrailerImage](/resources/readme/working.png) 26 | ![TrailerImage](/resources/readme/australiaScreen.png) 27 | ![TrailerImage](/resources/readme/sphere.png) 28 | ![TrailerImage](/resources/readme/sphereRender.png) 29 | ![TrailerImage](/resources/readme/well.png) 30 | ![TrailerImage](/resources/readme/paint.png) 31 | ![TrailerImage](/resources/readme/newheads.png) 32 | 33 | -------------------------------------------------------------------------------- /ext/__pycache__/png.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/ext/__pycache__/png.cpython-38.pyc -------------------------------------------------------------------------------- /ext/bin/prichunkpng: -------------------------------------------------------------------------------- 1 | #!/Users/lmueller/opt/anaconda3/bin/python 2 | # prichunkpng 3 | # Chunk editing tool. 4 | 5 | """ 6 | Make a new PNG by adding, delete, or replacing particular chunks. 7 | """ 8 | 9 | import argparse 10 | import collections 11 | 12 | # https://docs.python.org/2.7/library/io.html 13 | import io 14 | import re 15 | import string 16 | import struct 17 | import sys 18 | import zlib 19 | 20 | # Local module. 21 | import png 22 | 23 | 24 | Chunk = collections.namedtuple("Chunk", "type content") 25 | 26 | 27 | class ArgumentError(Exception): 28 | """A user problem with the command arguments.""" 29 | 30 | 31 | def process(out, args): 32 | """Process the PNG file args.input to the output, chunk by chunk. 33 | Chunks can be inserted, removed, replaced, or sometimes edited. 34 | Chunks are specified by their 4 byte Chunk Type; 35 | see https://www.w3.org/TR/2003/REC-PNG-20031110/#5Chunk-layout . 36 | The chunks in args.delete will be removed from the stream. 37 | The chunks in args.chunk will be inserted into the stream 38 | with their contents taken from the named files. 39 | 40 | Other options on the args object will create particular 41 | ancillary chunks. 42 | 43 | .gamma -> gAMA chunk 44 | .sigbit -> sBIT chunk 45 | 46 | Chunk types need not be official PNG chunks at all. 47 | Non-standard chunks can be created. 48 | """ 49 | 50 | # Convert options to chunks in the args.chunk list 51 | if args.gamma: 52 | v = int(round(1e5 * args.gamma)) 53 | bs = io.BytesIO(struct.pack(">I", v)) 54 | args.chunk.insert(0, Chunk(b"gAMA", bs)) 55 | if args.sigbit: 56 | v = struct.pack("%dB" % len(args.sigbit), *args.sigbit) 57 | bs = io.BytesIO(v) 58 | args.chunk.insert(0, Chunk(b"sBIT", bs)) 59 | if args.iccprofile: 60 | # http://www.w3.org/TR/PNG/#11iCCP 61 | v = b"a color profile\x00\x00" + zlib.compress(args.iccprofile.read()) 62 | bs = io.BytesIO(v) 63 | args.chunk.insert(0, Chunk(b"iCCP", bs)) 64 | if args.transparent: 65 | # https://www.w3.org/TR/2003/REC-PNG-20031110/#11tRNS 66 | v = struct.pack(">%dH" % len(args.transparent), *args.transparent) 67 | bs = io.BytesIO(v) 68 | args.chunk.insert(0, Chunk(b"tRNS", bs)) 69 | if args.background: 70 | # https://www.w3.org/TR/2003/REC-PNG-20031110/#11bKGD 71 | v = struct.pack(">%dH" % len(args.background), *args.background) 72 | bs = io.BytesIO(v) 73 | args.chunk.insert(0, Chunk(b"bKGD", bs)) 74 | if args.physical: 75 | # https://www.w3.org/TR/PNG/#11pHYs 76 | numbers = re.findall(r"(\d+\.?\d*)", args.physical) 77 | if len(numbers) not in {1, 2}: 78 | raise ArgumentError("One or two numbers are required for --physical") 79 | xppu = float(numbers[0]) 80 | if len(numbers) == 1: 81 | yppu = xppu 82 | else: 83 | yppu = float(numbers[1]) 84 | 85 | unit_spec = 0 86 | if args.physical.endswith("dpi"): 87 | # Convert from DPI to Pixels Per Metre 88 | # 1 inch is 0.0254 metres 89 | l = 0.0254 90 | xppu /= l 91 | yppu /= l 92 | unit_spec = 1 93 | elif args.physical.endswith("ppm"): 94 | unit_spec = 1 95 | 96 | v = struct.pack("!LLB", round(xppu), round(yppu), unit_spec) 97 | bs = io.BytesIO(v) 98 | args.chunk.insert(0, Chunk(b"pHYs", bs)) 99 | 100 | # Create: 101 | # - a set of chunks to delete 102 | # - a dict of chunks to replace 103 | # - a list of chunk to add 104 | 105 | delete = set(args.delete) 106 | # The set of chunks to replace are those where the specification says 107 | # that there should be at most one of them. 108 | replacing = set([b"gAMA", b"pHYs", b"sBIT", b"PLTE", b"tRNS", b"sPLT", b"IHDR"]) 109 | replace = dict() 110 | add = [] 111 | 112 | for chunk in args.chunk: 113 | if chunk.type in replacing: 114 | replace[chunk.type] = chunk 115 | else: 116 | add.append(chunk) 117 | 118 | input = png.Reader(file=args.input) 119 | 120 | return png.write_chunks(out, edit_chunks(input.chunks(), delete, replace, add)) 121 | 122 | 123 | def edit_chunks(chunks, delete, replace, add): 124 | """ 125 | Iterate over chunks, yielding edited chunks. 126 | Subtle: the new chunks have to have their contents .read(). 127 | """ 128 | for type, v in chunks: 129 | if type in delete: 130 | continue 131 | if type in replace: 132 | yield type, replace[type].content.read() 133 | del replace[type] 134 | continue 135 | 136 | if b"IDAT" <= type <= b"IDAT" and replace: 137 | # If there are any chunks on the replace list by 138 | # the time we reach IDAT, add then all now. 139 | # put them all on the add list. 140 | for chunk in replace.values(): 141 | yield chunk.type, chunk.content.read() 142 | replace = dict() 143 | 144 | if b"IDAT" <= type <= b"IDAT" and add: 145 | # We reached IDAT; add all remaining chunks now. 146 | for chunk in add: 147 | yield chunk.type, chunk.content.read() 148 | add = [] 149 | 150 | yield type, v 151 | 152 | 153 | def chunk_name(s): 154 | """ 155 | Type check a chunk name option value. 156 | """ 157 | 158 | # See https://www.w3.org/TR/2003/REC-PNG-20031110/#table51 159 | valid = len(s) == 4 and set(s) <= set(string.ascii_letters) 160 | if not valid: 161 | raise ValueError("Chunk name must be 4 ASCII letters") 162 | return s.encode("ascii") 163 | 164 | 165 | def comma_list(s): 166 | """ 167 | Convert s, a command separated list of whole numbers, 168 | into a sequence of int. 169 | """ 170 | 171 | return tuple(int(v) for v in s.split(",")) 172 | 173 | 174 | def hex_color(s): 175 | """ 176 | Type check and convert a hex color. 177 | """ 178 | 179 | if s.startswith("#"): 180 | s = s[1:] 181 | valid = len(s) in [1, 2, 3, 4, 6, 12] and set(s) <= set(string.hexdigits) 182 | if not valid: 183 | raise ValueError("colour must be 1,2,3,4,6, or 12 hex-digits") 184 | 185 | # For the 4-bit RGB, expand to 8-bit, by repeating digits. 186 | if len(s) == 3: 187 | s = "".join(c + c for c in s) 188 | 189 | if len(s) in [1, 2, 4]: 190 | # Single grey value. 191 | return (int(s, 16),) 192 | 193 | if len(s) in [6, 12]: 194 | w = len(s) // 3 195 | return tuple(int(s[i : i + w], 16) for i in range(0, len(s), w)) 196 | 197 | 198 | def main(argv=None): 199 | if argv is None: 200 | argv = sys.argv 201 | 202 | argv = argv[1:] 203 | 204 | parser = argparse.ArgumentParser() 205 | parser.add_argument("--gamma", type=float, help="Gamma value for gAMA chunk") 206 | parser.add_argument( 207 | "--physical", 208 | type=str, 209 | metavar="x[,y][dpi|ppm]", 210 | help="specify intended pixel size or aspect ratio", 211 | ) 212 | parser.add_argument( 213 | "--sigbit", 214 | type=comma_list, 215 | metavar="D[,D[,D[,D]]]", 216 | help="Number of significant bits in each channel", 217 | ) 218 | parser.add_argument( 219 | "--iccprofile", 220 | metavar="file.iccp", 221 | type=argparse.FileType("rb"), 222 | help="add an ICC Profile from a file", 223 | ) 224 | parser.add_argument( 225 | "--transparent", 226 | type=hex_color, 227 | metavar="#RRGGBB", 228 | help="Specify the colour that is transparent (tRNS chunk)", 229 | ) 230 | parser.add_argument( 231 | "--background", 232 | type=hex_color, 233 | metavar="#RRGGBB", 234 | help="background colour for bKGD chunk", 235 | ) 236 | parser.add_argument( 237 | "--delete", 238 | action="append", 239 | default=[], 240 | type=chunk_name, 241 | help="delete the chunk", 242 | ) 243 | parser.add_argument( 244 | "--chunk", 245 | action="append", 246 | nargs=2, 247 | default=[], 248 | type=str, 249 | help="insert chunk, taking contents from file", 250 | ) 251 | parser.add_argument( 252 | "input", nargs="?", default="-", type=png.cli_open, metavar="PNG" 253 | ) 254 | 255 | args = parser.parse_args(argv) 256 | 257 | # Reprocess the chunk arguments, converting each pair into a Chunk. 258 | args.chunk = [ 259 | Chunk(chunk_name(type), open(path, "rb")) for type, path in args.chunk 260 | ] 261 | 262 | return process(png.binary_stdout(), args) 263 | 264 | 265 | if __name__ == "__main__": 266 | main() 267 | -------------------------------------------------------------------------------- /ext/bin/priditherpng: -------------------------------------------------------------------------------- 1 | #!/Users/lmueller/opt/anaconda3/bin/python 2 | 3 | # pipdither 4 | # Error Diffusing image dithering. 5 | # Now with serpentine scanning. 6 | 7 | # See http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT 8 | 9 | # http://www.python.org/doc/2.4.4/lib/module-bisect.html 10 | from bisect import bisect_left 11 | 12 | 13 | import png 14 | 15 | 16 | def dither( 17 | out, 18 | input, 19 | bitdepth=1, 20 | linear=False, 21 | defaultgamma=1.0, 22 | targetgamma=None, 23 | cutoff=0.5, # see :cutoff:default 24 | ): 25 | """Dither the input PNG `inp` into an image with a smaller bit depth 26 | and write the result image onto `out`. `bitdepth` specifies the bit 27 | depth of the new image. 28 | 29 | Normally the source image gamma is honoured (the image is 30 | converted into a linear light space before being dithered), but 31 | if the `linear` argument is true then the image is treated as 32 | being linear already: no gamma conversion is done (this is 33 | quicker, and if you don't care much about accuracy, it won't 34 | matter much). 35 | 36 | Images with no gamma indication (no ``gAMA`` chunk) are normally 37 | treated as linear (gamma = 1.0), but often it can be better 38 | to assume a different gamma value: For example continuous tone 39 | photographs intended for presentation on the web often carry 40 | an implicit assumption of being encoded with a gamma of about 41 | 0.45 (because that's what you get if you just "blat the pixels" 42 | onto a PC framebuffer), so ``defaultgamma=0.45`` might be a 43 | good idea. `defaultgamma` does not override a gamma value 44 | specified in the file itself: It is only used when the file 45 | does not specify a gamma. 46 | 47 | If you (pointlessly) specify both `linear` and `defaultgamma`, 48 | `linear` wins. 49 | 50 | The gamma of the output image is, by default, the same as the input 51 | image. The `targetgamma` argument can be used to specify a 52 | different gamma for the output image. This effectively recodes the 53 | image to a different gamma, dithering as we go. The gamma specified 54 | is the exponent used to encode the output file (and appears in the 55 | output PNG's ``gAMA`` chunk); it is usually less than 1. 56 | 57 | """ 58 | 59 | # Encoding is what happened when the PNG was made (and also what 60 | # happens when we output the PNG). Decoding is what we do to the 61 | # source PNG in order to process it. 62 | 63 | # The dithering algorithm is not completely general; it 64 | # can only do bit depth reduction, not arbitrary palette changes. 65 | import operator 66 | 67 | maxval = 2 ** bitdepth - 1 68 | r = png.Reader(file=input) 69 | 70 | _, _, pixels, info = r.asDirect() 71 | planes = info["planes"] 72 | # :todo: make an Exception 73 | assert planes == 1 74 | width = info["size"][0] 75 | sourcemaxval = 2 ** info["bitdepth"] - 1 76 | 77 | if linear: 78 | gamma = 1 79 | else: 80 | gamma = info.get("gamma") or defaultgamma 81 | 82 | # Calculate an effective gamma for input and output; 83 | # then build tables using those. 84 | 85 | # `gamma` (whether it was obtained from the input file or an 86 | # assumed value) is the encoding gamma. 87 | # We need the decoding gamma, which is the reciprocal. 88 | decode = 1.0 / gamma 89 | 90 | # `targetdecode` is the assumed gamma that is going to be used 91 | # to decoding the target PNG. 92 | # Note that even though we will _encode_ the target PNG we 93 | # still need the decoding gamma, because 94 | # the table we use maps from PNG pixel value to linear light level. 95 | if targetgamma is None: 96 | targetdecode = decode 97 | else: 98 | targetdecode = 1.0 / targetgamma 99 | 100 | incode = build_decode_table(sourcemaxval, decode) 101 | 102 | # For encoding, we still build a decode table, because we 103 | # use it inverted (searching with bisect). 104 | outcode = build_decode_table(maxval, targetdecode) 105 | 106 | # The table used for choosing output codes. These values represent 107 | # the cutoff points between two adjacent output codes. 108 | # The cutoff parameter can be varied between 0 and 1 to 109 | # preferentially choose lighter (when cutoff > 0.5) or 110 | # darker (when cutoff < 0.5) values. 111 | # :cutoff:default: The default for this used to be 0.75, but 112 | # testing by drj on 2021-07-30 showed that this produces 113 | # banding when dithering left-to-right gradients; 114 | # test with: 115 | # priforgepng grl | priditherpng | kitty icat 116 | choosecode = list(zip(outcode[1:], outcode)) 117 | p = cutoff 118 | choosecode = [x[0] * p + x[1] * (1.0 - p) for x in choosecode] 119 | 120 | rows = repeat_header(pixels) 121 | dithered_rows = run_dither(incode, choosecode, outcode, width, rows) 122 | dithered_rows = remove_header(dithered_rows) 123 | 124 | info["bitdepth"] = bitdepth 125 | info["gamma"] = 1.0 / targetdecode 126 | w = png.Writer(**info) 127 | w.write(out, dithered_rows) 128 | 129 | 130 | def build_decode_table(maxval, gamma): 131 | """Build a lookup table for decoding; 132 | table converts from pixel values to linear space. 133 | """ 134 | 135 | assert maxval == int(maxval) 136 | assert maxval > 0 137 | 138 | f = 1.0 / maxval 139 | table = [f * v for v in range(maxval + 1)] 140 | if gamma != 1.0: 141 | table = [v ** gamma for v in table] 142 | return table 143 | 144 | 145 | def run_dither(incode, choosecode, outcode, width, rows): 146 | """ 147 | Run an serpentine dither. 148 | Using the incode and choosecode tables. 149 | """ 150 | 151 | # Errors diffused downwards (into next row) 152 | ed = [0.0] * width 153 | flipped = False 154 | for row in rows: 155 | # Convert to linear... 156 | row = [incode[v] for v in row] 157 | # Add errors... 158 | row = [e + v for e, v in zip(ed, row)] 159 | 160 | if flipped: 161 | row = row[::-1] 162 | targetrow = [0] * width 163 | 164 | for i, v in enumerate(row): 165 | # `it` will be the index of the chosen target colour; 166 | it = bisect_left(choosecode, v) 167 | targetrow[i] = it 168 | t = outcode[it] 169 | # err is the error that needs distributing. 170 | err = v - t 171 | 172 | # Sierra "Filter Lite" distributes * 2 173 | # as per this diagram. 1 1 174 | ef = err * 0.5 175 | # :todo: consider making rows one wider at each end and 176 | # removing "if"s 177 | if i + 1 < width: 178 | row[i + 1] += ef 179 | ef *= 0.5 180 | ed[i] = ef 181 | if i: 182 | ed[i - 1] += ef 183 | 184 | if flipped: 185 | ed = ed[::-1] 186 | targetrow = targetrow[::-1] 187 | yield targetrow 188 | flipped = not flipped 189 | 190 | 191 | WARMUP_ROWS = 32 192 | 193 | 194 | def repeat_header(rows): 195 | """Repeat the first row, to "warm up" the error register.""" 196 | for row in rows: 197 | yield row 198 | for _ in range(WARMUP_ROWS): 199 | yield row 200 | break 201 | yield from rows 202 | 203 | 204 | def remove_header(rows): 205 | """Remove the same number of rows that repeat_header added.""" 206 | 207 | for _ in range(WARMUP_ROWS): 208 | next(rows) 209 | yield from rows 210 | 211 | 212 | def main(argv=None): 213 | import sys 214 | 215 | # https://docs.python.org/3.5/library/argparse.html 216 | import argparse 217 | 218 | parser = argparse.ArgumentParser() 219 | 220 | if argv is None: 221 | argv = sys.argv 222 | 223 | progname, *args = argv 224 | 225 | parser.add_argument("--bitdepth", type=int, default=1, help="bitdepth of output") 226 | parser.add_argument( 227 | "--cutoff", 228 | type=float, 229 | default=0.5, 230 | help="cutoff to select adjacent output values", 231 | ) 232 | parser.add_argument( 233 | "--defaultgamma", 234 | type=float, 235 | default=1.0, 236 | help="gamma value to use when no gamma in input", 237 | ) 238 | parser.add_argument("--linear", action="store_true", help="force linear input") 239 | parser.add_argument( 240 | "--targetgamma", 241 | type=float, 242 | help="gamma to use in output (target), defaults to input gamma", 243 | ) 244 | parser.add_argument( 245 | "input", nargs="?", default="-", type=png.cli_open, metavar="PNG" 246 | ) 247 | 248 | ns = parser.parse_args(args) 249 | 250 | return dither(png.binary_stdout(), **vars(ns)) 251 | 252 | 253 | if __name__ == "__main__": 254 | main() 255 | -------------------------------------------------------------------------------- /ext/bin/priforgepng: -------------------------------------------------------------------------------- 1 | #!/Users/lmueller/opt/anaconda3/bin/python 2 | # priforgepng 3 | 4 | """Forge PNG image from raw computation.""" 5 | 6 | from array import array 7 | from fractions import Fraction 8 | 9 | import argparse 10 | import re 11 | import sys 12 | 13 | import png 14 | 15 | 16 | def gen_glr(x): 17 | """Gradient Left to Right""" 18 | return x 19 | 20 | 21 | def gen_grl(x): 22 | """Gradient Right to Left""" 23 | return 1 - x 24 | 25 | 26 | def gen_gtb(x, y): 27 | """Gradient Top to Bottom""" 28 | return y 29 | 30 | 31 | def gen_gbt(x, y): 32 | """Gradient Bottom to Top""" 33 | return 1.0 - y 34 | 35 | 36 | def gen_rtl(x, y): 37 | """Radial gradient, centred at Top-Left""" 38 | return max(1 - (float(x) ** 2 + float(y) ** 2) ** 0.5, 0.0) 39 | 40 | 41 | def gen_rctr(x, y): 42 | """Radial gradient, centred at Centre""" 43 | return gen_rtl(float(x) - 0.5, float(y) - 0.5) 44 | 45 | 46 | def gen_rtr(x, y): 47 | """Radial gradient, centred at Top-Right""" 48 | return gen_rtl(1.0 - float(x), y) 49 | 50 | 51 | def gen_rbl(x, y): 52 | """Radial gradient, centred at Bottom-Left""" 53 | return gen_rtl(x, 1.0 - float(y)) 54 | 55 | 56 | def gen_rbr(x, y): 57 | """Radial gradient, centred at Bottom-Right""" 58 | return gen_rtl(1.0 - float(x), 1.0 - float(y)) 59 | 60 | 61 | def stripe(x, n): 62 | return int(x * n) & 1 63 | 64 | 65 | def gen_vs2(x): 66 | """2 Vertical Stripes""" 67 | return stripe(x, 2) 68 | 69 | 70 | def gen_vs4(x): 71 | """4 Vertical Stripes""" 72 | return stripe(x, 4) 73 | 74 | 75 | def gen_vs10(x): 76 | """10 Vertical Stripes""" 77 | return stripe(x, 10) 78 | 79 | 80 | def gen_hs2(x, y): 81 | """2 Horizontal Stripes""" 82 | return stripe(float(y), 2) 83 | 84 | 85 | def gen_hs4(x, y): 86 | """4 Horizontal Stripes""" 87 | return stripe(float(y), 4) 88 | 89 | 90 | def gen_hs10(x, y): 91 | """10 Horizontal Stripes""" 92 | return stripe(float(y), 10) 93 | 94 | 95 | def gen_slr(x, y): 96 | """10 diagonal stripes, rising from Left to Right""" 97 | return stripe(x + y, 10) 98 | 99 | 100 | def gen_srl(x, y): 101 | """10 diagonal stripes, rising from Right to Left""" 102 | return stripe(1 + x - y, 10) 103 | 104 | 105 | def checker(x, y, n): 106 | return stripe(x, n) ^ stripe(y, n) 107 | 108 | 109 | def gen_ck8(x, y): 110 | """8 by 8 checkerboard""" 111 | return checker(x, y, 8) 112 | 113 | 114 | def gen_ck15(x, y): 115 | """15 by 15 checkerboard""" 116 | return checker(x, y, 15) 117 | 118 | 119 | def gen_zero(x): 120 | """All zero (black)""" 121 | return 0 122 | 123 | 124 | def gen_one(x): 125 | """All one (white)""" 126 | return 1 127 | 128 | 129 | def yield_fun_rows(size, bitdepth, pattern): 130 | """ 131 | Create a single channel (monochrome) test pattern. 132 | Yield each row in turn. 133 | """ 134 | 135 | width, height = size 136 | 137 | maxval = 2 ** bitdepth - 1 138 | if maxval > 255: 139 | typecode = "H" 140 | else: 141 | typecode = "B" 142 | pfun = pattern_function(pattern) 143 | 144 | # The coordinates are an integer + 0.5, 145 | # effectively sampling each pixel at its centre. 146 | # This is morally better, and produces all 256 sample values 147 | # in a 256-pixel wide gradient. 148 | 149 | # We make a list of x coordinates here and re-use it, 150 | # because Fraction instances are slow to allocate. 151 | xs = [Fraction(x, 2 * width) for x in range(1, 2 * width, 2)] 152 | 153 | # The general case is a function in x and y, 154 | # but if the function only takes an x argument, 155 | # it's handled in a special case that is a lot faster. 156 | if n_args(pfun) == 2: 157 | for y in range(height): 158 | a = array(typecode) 159 | fy = Fraction(Fraction(y + 0.5), height) 160 | for fx in xs: 161 | a.append(int(round(maxval * pfun(fx, fy)))) 162 | yield a 163 | return 164 | 165 | # For functions in x only, it's a _lot_ faster 166 | # to generate a single row and repeatedly yield it 167 | a = array(typecode) 168 | for fx in xs: 169 | a.append(int(round(maxval * pfun(x=fx)))) 170 | for y in range(height): 171 | yield a 172 | return 173 | 174 | 175 | def generate(args): 176 | """ 177 | Create a PNG test image and write the file to stdout. 178 | 179 | `args` should be an argparse Namespace instance or similar. 180 | """ 181 | 182 | size = args.size 183 | bitdepth = args.depth 184 | 185 | out = png.binary_stdout() 186 | 187 | for pattern in args.pattern: 188 | rows = yield_fun_rows(size, bitdepth, pattern) 189 | writer = png.Writer( 190 | size[0], size[1], bitdepth=bitdepth, greyscale=True, alpha=False 191 | ) 192 | writer.write(out, rows) 193 | 194 | 195 | def n_args(fun): 196 | """Number of arguments in fun's argument list.""" 197 | return fun.__code__.co_argcount 198 | 199 | 200 | def pattern_function(pattern): 201 | """From `pattern`, a string, 202 | return the function for that pattern. 203 | """ 204 | 205 | lpat = pattern.lower() 206 | for name, fun in globals().items(): 207 | parts = name.split("_") 208 | if parts[0] != "gen": 209 | continue 210 | if parts[1] == lpat: 211 | return fun 212 | 213 | 214 | def patterns(): 215 | """ 216 | List the patterns. 217 | """ 218 | 219 | for name, fun in globals().items(): 220 | parts = name.split("_") 221 | if parts[0] == "gen": 222 | yield parts[1], fun.__doc__ 223 | 224 | 225 | def dimensions(s): 226 | """ 227 | Typecheck the --size option, which should be 228 | one or two comma separated numbers. 229 | Example: "64,40". 230 | """ 231 | 232 | tupl = re.findall(r"\d+", s) 233 | if len(tupl) not in (1, 2): 234 | raise ValueError("%r should be width or width,height" % s) 235 | if len(tupl) == 1: 236 | tupl *= 2 237 | assert len(tupl) == 2 238 | return list(map(int, tupl)) 239 | 240 | 241 | def main(argv=None): 242 | if argv is None: 243 | argv = sys.argv 244 | parser = argparse.ArgumentParser(description="Forge greyscale PNG patterns") 245 | 246 | parser.add_argument( 247 | "-l", "--list", action="store_true", help="print list of patterns and exit" 248 | ) 249 | parser.add_argument( 250 | "-d", "--depth", default=8, type=int, metavar="N", help="N bits per pixel" 251 | ) 252 | parser.add_argument( 253 | "-s", 254 | "--size", 255 | default=[256, 256], 256 | type=dimensions, 257 | metavar="w[,h]", 258 | help="width and height of the image in pixels", 259 | ) 260 | parser.add_argument("pattern", nargs="*", help="name of pattern") 261 | 262 | args = parser.parse_args(argv[1:]) 263 | 264 | if args.list: 265 | for name, doc in sorted(patterns()): 266 | print(name, doc, sep="\t") 267 | return 268 | 269 | if not args.pattern: 270 | parser.error("--list or pattern is required") 271 | return generate(args) 272 | 273 | 274 | if __name__ == "__main__": 275 | main() 276 | -------------------------------------------------------------------------------- /ext/bin/prigreypng: -------------------------------------------------------------------------------- 1 | #!/Users/lmueller/opt/anaconda3/bin/python 2 | 3 | # prigreypng 4 | 5 | # Convert image to grey (L, or LA), but only if that involves no colour change. 6 | 7 | import argparse 8 | import array 9 | 10 | 11 | import png 12 | 13 | 14 | def as_grey(out, inp): 15 | """ 16 | Convert image to greyscale, but only when no colour change. 17 | This works by using the input G channel (green) as 18 | the output L channel (luminance) and 19 | checking that every pixel is grey as we go. 20 | A non-grey pixel will raise an error. 21 | """ 22 | 23 | r = png.Reader(file=inp) 24 | _, _, rows, info = r.asDirect() 25 | if info["greyscale"]: 26 | w = png.Writer(**info) 27 | return w.write(out, rows) 28 | 29 | planes = info["planes"] 30 | targetplanes = planes - 2 31 | alpha = info["alpha"] 32 | width, height = info["size"] 33 | typecode = "BH"[info["bitdepth"] > 8] 34 | 35 | # Values per target row 36 | vpr = width * targetplanes 37 | 38 | def iterasgrey(): 39 | for i, row in enumerate(rows): 40 | row = array.array(typecode, row) 41 | targetrow = array.array(typecode, [0] * vpr) 42 | # Copy G (and possibly A) channel. 43 | green = row[0::planes] 44 | if alpha: 45 | targetrow[0::2] = green 46 | targetrow[1::2] = row[3::4] 47 | else: 48 | targetrow = green 49 | # Check R and B channel match. 50 | if green != row[0::planes] or green != row[2::planes]: 51 | raise ValueError("Row %i contains non-grey pixel." % i) 52 | yield targetrow 53 | 54 | info["greyscale"] = True 55 | del info["planes"] 56 | w = png.Writer(**info) 57 | return w.write(out, iterasgrey()) 58 | 59 | 60 | def main(argv=None): 61 | parser = argparse.ArgumentParser() 62 | parser.add_argument( 63 | "input", nargs="?", default="-", type=png.cli_open, metavar="PNG" 64 | ) 65 | args = parser.parse_args() 66 | return as_grey(png.binary_stdout(), args.input) 67 | 68 | 69 | if __name__ == "__main__": 70 | import sys 71 | 72 | sys.exit(main()) 73 | -------------------------------------------------------------------------------- /ext/bin/pripalpng: -------------------------------------------------------------------------------- 1 | #!/Users/lmueller/opt/anaconda3/bin/python 2 | # pripalpng 3 | # Convert to Palette PNG 4 | 5 | import argparse 6 | import collections 7 | 8 | # https://docs.python.org/2.7/library/io.html 9 | import io 10 | import string 11 | import zlib 12 | 13 | # Local module. 14 | import png 15 | 16 | 17 | def make_inverse_palette(rows, channels): 18 | """ 19 | The inverse palette maps from tuple to palette index. 20 | """ 21 | 22 | palette = {} 23 | 24 | for row in rows: 25 | for pixel in png.group(row, channels): 26 | if pixel in palette: 27 | continue 28 | palette[pixel] = len(palette) 29 | return palette 30 | 31 | 32 | def palette_convert(out, inp, palette_file): 33 | """ 34 | Convert PNG image in `inp` to use a palette, colour type 3, 35 | and write converted image to `out`. 36 | 37 | `palette_file` is a file descriptor for the palette to use. 38 | 39 | If `palette_file` is None, then `inp` is used as the palette. 40 | """ 41 | 42 | if palette_file is None: 43 | inp, palette_file = palette_file, inp 44 | 45 | reader = png.Reader(file=palette_file) 46 | w, h, rows, info = asRGBorA8(reader) 47 | channels = info["planes"] 48 | if not inp: 49 | rows = list(rows) 50 | 51 | palette_map = make_inverse_palette(rows, channels) 52 | 53 | if inp: 54 | reader = png.Reader(file=inp) 55 | w, h, rows, info = asRGBorA8(reader) 56 | channels = info["planes"] 57 | 58 | # Default for colours not in palette is to use last entry. 59 | last = len(palette_map) - 1 60 | 61 | def map_pixel(p): 62 | return palette_map.get(p, last) 63 | 64 | def convert_rows(): 65 | for row in rows: 66 | yield [map_pixel(p) for p in png.group(row, channels)] 67 | 68 | # Make a palette by sorting the pixels according to their index. 69 | palette = sorted(palette_map.keys(), key=palette_map.get) 70 | pal_info = dict(size=info["size"], palette=palette) 71 | 72 | w = png.Writer(**pal_info) 73 | w.write(out, convert_rows()) 74 | 75 | 76 | def asRGBorA8(reader): 77 | """ 78 | Return (width, height, rows, info) converting to RGB, 79 | or RGBA if original has an alpha channel. 80 | """ 81 | _, _, _, info = reader.read() 82 | if info["alpha"]: 83 | return reader.asRGBA8() 84 | else: 85 | return reader.asRGB8() 86 | 87 | 88 | def main(argv=None): 89 | import sys 90 | import re 91 | 92 | if argv is None: 93 | argv = sys.argv 94 | 95 | argv = argv[1:] 96 | 97 | parser = argparse.ArgumentParser() 98 | parser.add_argument("--palette", type=png.cli_open) 99 | parser.add_argument( 100 | "input", nargs="?", default="-", type=png.cli_open, metavar="PNG" 101 | ) 102 | 103 | args = parser.parse_args(argv) 104 | 105 | palette_convert(png.binary_stdout(), args.input, args.palette) 106 | 107 | 108 | if __name__ == "__main__": 109 | main() 110 | -------------------------------------------------------------------------------- /ext/bin/pripamtopng: -------------------------------------------------------------------------------- 1 | #!/Users/lmueller/opt/anaconda3/bin/python 2 | 3 | # pripamtopng 4 | # 5 | # Python Raster Image PAM to PNG 6 | 7 | import array 8 | import struct 9 | import sys 10 | 11 | import png 12 | 13 | 14 | def read_pam_header(infile): 15 | """ 16 | Read (the rest of a) PAM header. 17 | `infile` should be positioned immediately after the initial 'P7' line 18 | (at the beginning of the second line). 19 | Returns are as for `read_pnm_header`. 20 | """ 21 | 22 | # Unlike PBM, PGM, and PPM, we can read the header a line at a time. 23 | header = dict() 24 | while True: 25 | line = infile.readline().strip() 26 | if line == b"ENDHDR": 27 | break 28 | if not line: 29 | raise EOFError("PAM ended prematurely") 30 | if line[0] == b"#": 31 | continue 32 | line = line.split(None, 1) 33 | key = line[0] 34 | if key not in header: 35 | header[key] = line[1] 36 | else: 37 | header[key] += b" " + line[1] 38 | 39 | required = [b"WIDTH", b"HEIGHT", b"DEPTH", b"MAXVAL"] 40 | required_str = b", ".join(required).decode("ascii") 41 | result = [] 42 | for token in required: 43 | if token not in header: 44 | raise png.Error("PAM file must specify " + required_str) 45 | try: 46 | x = int(header[token]) 47 | except ValueError: 48 | raise png.Error(required_str + " must all be valid integers") 49 | if x <= 0: 50 | raise png.Error(required_str + " must all be positive integers") 51 | result.append(x) 52 | 53 | return ("P7",) + tuple(result) 54 | 55 | 56 | def read_pnm_header(infile): 57 | """ 58 | Read a PNM header, returning (format,width,height,depth,maxval). 59 | Also reads a PAM header (by using a helper function). 60 | `width` and `height` are in pixels. 61 | `depth` is the number of channels in the image; 62 | for PBM and PGM it is synthesized as 1, for PPM as 3; 63 | for PAM images it is read from the header. 64 | `maxval` is synthesized (as 1) for PBM images. 65 | """ 66 | 67 | # Generally, see http://netpbm.sourceforge.net/doc/ppm.html 68 | # and http://netpbm.sourceforge.net/doc/pam.html 69 | 70 | supported = (b"P5", b"P6", b"P7") 71 | 72 | # Technically 'P7' must be followed by a newline, 73 | # so by using rstrip() we are being liberal in what we accept. 74 | # I think this is acceptable. 75 | type = infile.read(3).rstrip() 76 | if type not in supported: 77 | raise NotImplementedError("file format %s not supported" % type) 78 | if type == b"P7": 79 | # PAM header parsing is completely different. 80 | return read_pam_header(infile) 81 | 82 | # Expected number of tokens in header (3 for P4, 4 for P6) 83 | expected = 4 84 | pbm = (b"P1", b"P4") 85 | if type in pbm: 86 | expected = 3 87 | header = [type] 88 | 89 | # We must read the rest of the header byte by byte because 90 | # the final whitespace character may not be a newline. 91 | # Of course all PNM files in the wild use a newline at this point, 92 | # but we are strong and so we avoid 93 | # the temptation to use readline. 94 | bs = bytearray() 95 | backs = bytearray() 96 | 97 | def next(): 98 | if backs: 99 | c = bytes(backs[0:1]) 100 | del backs[0] 101 | else: 102 | c = infile.read(1) 103 | if not c: 104 | raise png.Error("premature EOF reading PNM header") 105 | bs.extend(c) 106 | return c 107 | 108 | def backup(): 109 | """Push last byte of token onto front of backs.""" 110 | backs.insert(0, bs[-1]) 111 | del bs[-1] 112 | 113 | def ignore(): 114 | del bs[:] 115 | 116 | def tokens(): 117 | ls = lexInit 118 | while True: 119 | token, ls = ls() 120 | if token: 121 | yield token 122 | 123 | def lexInit(): 124 | c = next() 125 | # Skip comments 126 | if b"#" <= c <= b"#": 127 | while c not in b"\n\r": 128 | c = next() 129 | ignore() 130 | return None, lexInit 131 | # Skip whitespace (that precedes a token) 132 | if c.isspace(): 133 | ignore() 134 | return None, lexInit 135 | if not c.isdigit(): 136 | raise png.Error("unexpected byte %r found in header" % c) 137 | return None, lexNumber 138 | 139 | def lexNumber(): 140 | # According to the specification it is legal to have comments 141 | # that appear in the middle of a token. 142 | # I've never seen it; and, 143 | # it's a bit awkward to code good lexers in Python (no goto). 144 | # So we break on such cases. 145 | c = next() 146 | while c.isdigit(): 147 | c = next() 148 | backup() 149 | token = bs[:] 150 | ignore() 151 | return token, lexInit 152 | 153 | for token in tokens(): 154 | # All "tokens" are decimal integers, so convert them here. 155 | header.append(int(token)) 156 | if len(header) == expected: 157 | break 158 | 159 | final = next() 160 | if not final.isspace(): 161 | raise png.Error("expected header to end with whitespace, not %r" % final) 162 | 163 | if type in pbm: 164 | # synthesize a MAXVAL 165 | header.append(1) 166 | depth = (1, 3)[type == b"P6"] 167 | return header[0], header[1], header[2], depth, header[3] 168 | 169 | 170 | def convert_pnm(w, infile, outfile): 171 | """ 172 | Convert a PNM file containing raw pixel data into 173 | a PNG file with the parameters set in the writer object. 174 | Works for (binary) PGM, PPM, and PAM formats. 175 | """ 176 | 177 | rows = scan_rows_from_file(infile, w.width, w.height, w.planes, w.bitdepth) 178 | w.write(outfile, rows) 179 | 180 | 181 | def scan_rows_from_file(infile, width, height, planes, bitdepth): 182 | """ 183 | Generate a sequence of rows from the input file `infile`. 184 | The input file should be in a "Netpbm-like" binary format. 185 | The input file should be positioned at the beginning of the first pixel. 186 | The number of pixels to read is taken from 187 | the image dimensions (`width`, `height`, `planes`); 188 | the number of bytes per value is implied by `bitdepth`. 189 | Each row is yielded as a single sequence of values. 190 | """ 191 | 192 | # Values per row 193 | vpr = width * planes 194 | # Bytes per row 195 | bpr = vpr 196 | if bitdepth > 8: 197 | assert bitdepth == 16 198 | bpr *= 2 199 | fmt = ">%dH" % vpr 200 | 201 | def line(): 202 | return array.array("H", struct.unpack(fmt, infile.read(bpr))) 203 | 204 | else: 205 | 206 | def line(): 207 | return array.array("B", infile.read(bpr)) 208 | 209 | for y in range(height): 210 | yield line() 211 | 212 | 213 | def parse_args(args): 214 | """ 215 | Create a parser and parse the command line arguments. 216 | """ 217 | from argparse import ArgumentParser 218 | 219 | parser = ArgumentParser() 220 | version = "%(prog)s " + png.__version__ 221 | parser.add_argument("--version", action="version", version=version) 222 | parser.add_argument( 223 | "-c", 224 | "--compression", 225 | type=int, 226 | metavar="level", 227 | help="zlib compression level (0-9)", 228 | ) 229 | parser.add_argument( 230 | "input", 231 | nargs="?", 232 | default="-", 233 | type=png.cli_open, 234 | metavar="PAM/PNM", 235 | help="input PAM/PNM file to convert", 236 | ) 237 | args = parser.parse_args(args) 238 | return args 239 | 240 | 241 | def main(argv=None): 242 | if argv is None: 243 | argv = sys.argv 244 | 245 | args = parse_args(argv[1:]) 246 | 247 | # Prepare input and output files 248 | infile = args.input 249 | 250 | # Call after parsing, so that --version and --help work. 251 | outfile = png.binary_stdout() 252 | 253 | # Encode PNM to PNG 254 | format, width, height, depth, maxval = read_pnm_header(infile) 255 | 256 | # The NetPBM depth (number of channels) completely 257 | # determines the PNG format. 258 | # Observe: 259 | # - L, LA, RGB, RGBA are the 4 modes supported by PNG; 260 | # - they correspond to 1, 2, 3, 4 channels respectively. 261 | # We use the number of channels in the source image to 262 | # determine which one we have. 263 | # We ignore the NetPBM image type and the PAM TUPLTYPE. 264 | greyscale = depth <= 2 265 | pamalpha = depth in (2, 4) 266 | supported = [2 ** x - 1 for x in range(1, 17)] 267 | try: 268 | mi = supported.index(maxval) 269 | except ValueError: 270 | raise NotImplementedError( 271 | "input maxval (%s) not in supported list %s" % (maxval, str(supported)) 272 | ) 273 | bitdepth = mi + 1 274 | writer = png.Writer( 275 | width, 276 | height, 277 | greyscale=greyscale, 278 | bitdepth=bitdepth, 279 | alpha=pamalpha, 280 | compression=args.compression, 281 | ) 282 | convert_pnm(writer, infile, outfile) 283 | 284 | 285 | if __name__ == "__main__": 286 | try: 287 | sys.exit(main()) 288 | except png.Error as e: 289 | print(e, file=sys.stderr) 290 | sys.exit(99) 291 | -------------------------------------------------------------------------------- /ext/bin/pripnglsch: -------------------------------------------------------------------------------- 1 | #!/Users/lmueller/opt/anaconda3/bin/python 2 | # pripnglsch 3 | # PNG List Chunks 4 | 5 | import png 6 | 7 | 8 | def list_chunks(out, inp): 9 | r = png.Reader(file=inp) 10 | for t, v in r.chunks(): 11 | add = "" 12 | if len(v) <= 28: 13 | add = " " + v.hex() 14 | else: 15 | add = " " + v[:26].hex() + "..." 16 | t = t.decode("ascii") 17 | print("%s %10d%s" % (t, len(v), add), file=out) 18 | 19 | 20 | def main(argv=None): 21 | import argparse 22 | import sys 23 | 24 | parser = argparse.ArgumentParser() 25 | parser.add_argument( 26 | "input", nargs="?", default="-", type=png.cli_open, metavar="PNG" 27 | ) 28 | args = parser.parse_args() 29 | return list_chunks(sys.stdout, args.input) 30 | 31 | 32 | if __name__ == "__main__": 33 | main() 34 | -------------------------------------------------------------------------------- /ext/bin/pripngtopam: -------------------------------------------------------------------------------- 1 | #!/Users/lmueller/opt/anaconda3/bin/python 2 | 3 | import struct 4 | 5 | import png 6 | 7 | 8 | def write_pnm(file, plain, rows, meta): 9 | """ 10 | Write a Netpbm PNM (or PAM) file. 11 | *file* output file object; 12 | *plain* (a bool) true if writing plain format (not possible for PAM); 13 | *rows* an iterator for the rows; 14 | *meta* the info dictionary. 15 | """ 16 | 17 | meta = dict(meta) 18 | meta["maxval"] = 2 ** meta["bitdepth"] - 1 19 | meta["width"], meta["height"] = meta["size"] 20 | 21 | # Number of planes determines both image formats: 22 | # 1 : L to PGM 23 | # 2 : LA to PAM 24 | # 3 : RGB to PPM 25 | # 4 : RGBA to PAM 26 | planes = meta["planes"] 27 | 28 | # Assume inputs are from a PNG file. 29 | assert planes in (1, 2, 3, 4) 30 | if planes in (1, 3): 31 | if 1 == planes: 32 | # PGM 33 | # Even if maxval is 1 we use PGM instead of PBM, 34 | # to avoid converting data. 35 | magic = "P5" 36 | if plain: 37 | magic = "P2" 38 | else: 39 | # PPM 40 | magic = "P6" 41 | if plain: 42 | magic = "P3" 43 | header = "{magic} {width:d} {height:d} {maxval:d}\n".format(magic=magic, **meta) 44 | if planes in (2, 4): 45 | # PAM 46 | # See http://netpbm.sourceforge.net/doc/pam.html 47 | if plain: 48 | raise Exception("PAM (%d-plane) does not support plain format" % planes) 49 | if 2 == planes: 50 | tupltype = "GRAYSCALE_ALPHA" 51 | else: 52 | tupltype = "RGB_ALPHA" 53 | header = ( 54 | "P7\nWIDTH {width:d}\nHEIGHT {height:d}\n" 55 | "DEPTH {planes:d}\nMAXVAL {maxval:d}\n" 56 | "TUPLTYPE {tupltype}\nENDHDR\n".format(tupltype=tupltype, **meta) 57 | ) 58 | file.write(header.encode("ascii")) 59 | 60 | # Values per row 61 | vpr = planes * meta["width"] 62 | 63 | if plain: 64 | for row in rows: 65 | row_b = b" ".join([b"%d" % v for v in row]) 66 | file.write(row_b) 67 | file.write(b"\n") 68 | else: 69 | # format for struct.pack 70 | fmt = ">%d" % vpr 71 | if meta["maxval"] > 0xFF: 72 | fmt = fmt + "H" 73 | else: 74 | fmt = fmt + "B" 75 | for row in rows: 76 | file.write(struct.pack(fmt, *row)) 77 | 78 | file.flush() 79 | 80 | 81 | def main(argv=None): 82 | import argparse 83 | 84 | parser = argparse.ArgumentParser(description="Convert PNG to PAM") 85 | parser.add_argument("--plain", action="store_true") 86 | parser.add_argument( 87 | "input", nargs="?", default="-", type=png.cli_open, metavar="PNG" 88 | ) 89 | 90 | args = parser.parse_args() 91 | 92 | # Encode PNG to PNM (or PAM) 93 | image = png.Reader(file=args.input) 94 | _, _, rows, info = image.asDirect() 95 | write_pnm(png.binary_stdout(), args.plain, rows, info) 96 | 97 | 98 | if __name__ == "__main__": 99 | import sys 100 | 101 | sys.exit(main()) 102 | -------------------------------------------------------------------------------- /ext/bin/priweavepng: -------------------------------------------------------------------------------- 1 | #!/Users/lmueller/opt/anaconda3/bin/python 2 | 3 | # priweavepng 4 | # Weave selected channels from input PNG files into 5 | # a multi-channel output PNG. 6 | 7 | import collections 8 | import re 9 | 10 | from array import array 11 | 12 | import png 13 | 14 | """ 15 | priweavepng file1.png [file2.png ...] 16 | 17 | The `priweavepng` tool combines channels from the input images and 18 | weaves a selection of those channels into an output image. 19 | 20 | Conceptually an intermediate image is formed consisting of 21 | all channels of all input images in the order given on the command line 22 | and in the order of each channel in its image. 23 | Then from 1 to 4 channels are selected and 24 | an image is output with those channels. 25 | The limit on the number of selected channels is 26 | imposed by the PNG image format. 27 | 28 | The `-c n` option selects channel `n`. 29 | Further channels can be selected either by repeating the `-c` option, 30 | or using a comma separated list. 31 | For example `-c 3,2,1` will select channels 3, 2, and 1 in that order; 32 | if the input is an RGB PNG, this will swop the Red and Blue channels. 33 | The order is significant, the order in which the options are given is 34 | the order of the output channels. 35 | It is permissible, and sometimes useful 36 | (for example, grey to colour expansion, see below), 37 | to repeat the same channel. 38 | 39 | If no `-c` option is used the default is 40 | to select all of the input channels, up to the first 4. 41 | 42 | `priweavepng` does not care about the meaning of the channels 43 | and treats them as a matrix of values. 44 | 45 | The numer of output channels determines the colour mode of the PNG file: 46 | L (1-channel, Grey), LA (2-channel, Grey+Alpha), 47 | RGB (3-channel, Red+Green+Blue), RGBA (4-channel, Red+Green+Blue+Alpha). 48 | 49 | The `priweavepng` tool can be used for a variety of 50 | channel building, swopping, and extraction effects: 51 | 52 | Combine 3 grayscale images into RGB colour: 53 | priweavepng grey1.png grey2.png grey3.png 54 | 55 | Swop Red and Blue channels in colour image: 56 | priweavepng -c 3 -c 2 -c 1 rgb.png 57 | 58 | Extract Green channel as a greyscale image: 59 | priweavepng -c 2 rgb.png 60 | 61 | Convert a greyscale image to a colour image (all grey): 62 | priweavepng -c 1 -c 1 -c 1 grey.png 63 | 64 | Add alpha mask from a separate (greyscale) image: 65 | priweavepng rgb.png grey.png 66 | 67 | Extract alpha mask into a separate (greyscale) image: 68 | priweavepng -c 4 rgba.png 69 | 70 | Steal alpha mask from second file and add to first. 71 | Note that the intermediate image in this example has 7 channels: 72 | priweavepng -c 1 -c 2 -c 3 -c 7 rgb.png rgba.png 73 | 74 | Take Green channel from 3 successive colour images to make a new RGB image: 75 | priweavepng -c 2 -c 5 -c 8 rgb1.png rgb2.png rgb3.png 76 | 77 | """ 78 | 79 | Image = collections.namedtuple("Image", "rows info") 80 | 81 | # For each channel in the intermediate raster, 82 | # model: 83 | # - image: the input image (0-based); 84 | # - i: the channel index within that image (0-based); 85 | # - bitdepth: the bitdepth of this channel. 86 | Channel = collections.namedtuple("Channel", "image i bitdepth") 87 | 88 | 89 | class Error(Exception): 90 | pass 91 | 92 | 93 | def weave(out, args): 94 | """Stack the input PNG files and extract channels 95 | into a single output PNG. 96 | """ 97 | 98 | paths = args.input 99 | 100 | if len(paths) < 1: 101 | raise Error("Required input is missing.") 102 | 103 | # List of Image instances 104 | images = [] 105 | # Channel map. Maps from channel number (starting from 1) 106 | # to an (image_index, channel_index) pair. 107 | channel_map = dict() 108 | channel = 1 109 | 110 | for image_index, path in enumerate(paths): 111 | inp = png.cli_open(path) 112 | rows, info = png.Reader(file=inp).asDirect()[2:] 113 | rows = list(rows) 114 | image = Image(rows, info) 115 | images.append(image) 116 | # A later version of PyPNG may intelligently support 117 | # PNG files with heterogenous bitdepths. 118 | # For now, assumes bitdepth of all channels in image 119 | # is the same. 120 | channel_bitdepth = (image.info["bitdepth"],) * image.info["planes"] 121 | for i in range(image.info["planes"]): 122 | channel_map[channel + i] = Channel(image_index, i, channel_bitdepth[i]) 123 | channel += image.info["planes"] 124 | 125 | assert channel - 1 == sum(image.info["planes"] for image in images) 126 | 127 | # If no channels, select up to first 4 as default. 128 | if not args.channel: 129 | args.channel = range(1, channel)[:4] 130 | 131 | out_channels = len(args.channel) 132 | if not (0 < out_channels <= 4): 133 | raise Error("Too many channels selected (must be 1 to 4)") 134 | alpha = out_channels in (2, 4) 135 | greyscale = out_channels in (1, 2) 136 | 137 | bitdepth = tuple(image.info["bitdepth"] for image in images) 138 | arraytype = "BH"[max(bitdepth) > 8] 139 | 140 | size = [image.info["size"] for image in images] 141 | # Currently, fail unless all images same size. 142 | if len(set(size)) > 1: 143 | raise NotImplementedError("Cannot cope when sizes differ - sorry!") 144 | size = size[0] 145 | 146 | # Values per row, of output image 147 | vpr = out_channels * size[0] 148 | 149 | def weave_row_iter(): 150 | """ 151 | Yield each woven row in turn. 152 | """ 153 | # The zip call creates an iterator that yields 154 | # a tuple with each element containing the next row 155 | # for each of the input images. 156 | for row_tuple in zip(*(image.rows for image in images)): 157 | # output row 158 | row = array(arraytype, [0] * vpr) 159 | # for each output channel select correct input channel 160 | for out_channel_i, selection in enumerate(args.channel): 161 | channel = channel_map[selection] 162 | # incoming row (make it an array) 163 | irow = array(arraytype, row_tuple[channel.image]) 164 | n = images[channel.image].info["planes"] 165 | row[out_channel_i::out_channels] = irow[channel.i :: n] 166 | yield row 167 | 168 | w = png.Writer( 169 | size[0], 170 | size[1], 171 | greyscale=greyscale, 172 | alpha=alpha, 173 | bitdepth=bitdepth, 174 | interlace=args.interlace, 175 | ) 176 | w.write(out, weave_row_iter()) 177 | 178 | 179 | def comma_list(s): 180 | """ 181 | Type and return a list of integers. 182 | """ 183 | 184 | return [int(c) for c in re.findall(r"\d+", s)] 185 | 186 | 187 | def main(argv=None): 188 | import argparse 189 | import itertools 190 | import sys 191 | 192 | if argv is None: 193 | argv = sys.argv 194 | argv = argv[1:] 195 | 196 | parser = argparse.ArgumentParser() 197 | parser.add_argument( 198 | "-c", 199 | "--channel", 200 | action="append", 201 | type=comma_list, 202 | help="list of channels to extract", 203 | ) 204 | parser.add_argument("--interlace", action="store_true", help="write interlaced PNG") 205 | parser.add_argument("input", nargs="+") 206 | args = parser.parse_args(argv) 207 | 208 | if args.channel: 209 | args.channel = list(itertools.chain(*args.channel)) 210 | 211 | return weave(png.binary_stdout(), args) 212 | 213 | 214 | if __name__ == "__main__": 215 | main() 216 | -------------------------------------------------------------------------------- /ext/pypng-0.0.21.dist-info/INSTALLER: -------------------------------------------------------------------------------- 1 | pip 2 | -------------------------------------------------------------------------------- /ext/pypng-0.0.21.dist-info/LICENCE: -------------------------------------------------------------------------------- 1 | LICENCE (MIT) 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation files 5 | (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, 8 | and to permit persons to whom the Software is furnished to do so, 9 | subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ext/pypng-0.0.21.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: pypng 3 | Version: 0.0.21 4 | Summary: Pure Python library for saving and loading PNG images 5 | Home-page: https://github.com/drj11/pypng 6 | Author: David Jones 7 | Author-email: drj@pobox.com 8 | License: MIT 9 | Platform: UNKNOWN 10 | Classifier: Topic :: Multimedia :: Graphics 11 | Classifier: Topic :: Software Development :: Libraries :: Python Modules 12 | Classifier: Programming Language :: Python 13 | Classifier: Programming Language :: Python :: 3 14 | Classifier: Programming Language :: Python :: 3.5 15 | Classifier: Programming Language :: Python :: 3.6 16 | Classifier: Programming Language :: Python :: 3.7 17 | Classifier: Programming Language :: Python :: 3.8 18 | Classifier: Programming Language :: Python :: 3.9 19 | Classifier: License :: OSI Approved :: MIT License 20 | Classifier: Operating System :: OS Independent 21 | Description-Content-Type: text/markdown; charset=UTF-8 22 | License-File: LICENCE 23 | 24 | # README for PyPNG 25 | 26 | drj@pobox.com 27 | 28 | 29 | # INTRODUCTION 30 | 31 | PNG module for Python. PyPNG is written entirely in Python. 32 | 33 | - PyPNG home page: https://github.com/drj11/pypng/ 34 | - PyPNG Documentation: https://pypng.readthedocs.io/en/latest/ 35 | - PyPNG mailing list: https://groups.google.com/forum/#!forum/pypng-users 36 | 37 | 38 | ## QUICK START 39 | 40 | import png 41 | png.from_array([[255, 0, 0, 255], 42 | [0, 255, 255, 0]], 'L').save("small_smiley.png") 43 | 44 | After that, try `import png` then `help(png)`. 45 | Also, lickable HTML documentation appears in the `html/` directory. 46 | If HTML is no good then you could try the ReST sources 47 | in the `man/` directory. 48 | 49 | 50 | ## INSTALLATION 51 | 52 | PyPNG is pure Python and has no dependencies. 53 | It requires Python 3.5 or any compatible higher version. 54 | 55 | To install PyPNG package via pip use: 56 | 57 | pip install pypng 58 | 59 | You can also use `setuptools` to install from source; 60 | PyPNG uses `setup.cfg` and `pyproject.toml` to record its 61 | configuration. 62 | 63 | To install from (version controlled) sources using a suitable 64 | version of `pip`: 65 | 66 | `cd` into the directory and execute the command: 67 | 68 | pip install . 69 | 70 | The `png` module will be installed; 71 | `import png` will allow you to use it from your Python programs. 72 | 73 | PyPNG is so simple, that you don't need installation tools. 74 | You can copy `code/png.py` wherever you like. 75 | It's intended that you can copy `png.py` into 76 | your application and distribute it. 77 | The following `curl` command should copy the latest version into 78 | your current directory: 79 | 80 | curl -LO https://raw.github.com/drj11/pypng/main/code/png.py 81 | 82 | 83 | ## RELEASE NOTES 84 | 85 | (For issues see https://github.com/drj11/pypng/issues?state=open ) 86 | 87 | ### Release 0.0.21 88 | 89 | Support for Python 2 is dropped. 90 | Python 3.5 and onwards are supported. 91 | Some of the ancillary tools are modified to work on Python 3. 92 | 93 | Installs via wheel files. 94 | 95 | `prichunkpng` command line tool now has some new options to add 96 | chunks: 97 | - `--iccprofile` to add a `iCCP` chunk (ICC Profile); 98 | - `--physical` to add a `pHYs` chunk, 99 | specifying the intended pixel size; 100 | - `--sigbit` to add a `sBIT` chunk, 101 | specifying the encoded significant bits; 102 | - `--transparent` to add a `tRNS` chunk, 103 | specifying the transparent colour. 104 | 105 | `priditherpng` command line tool standardised and 106 | converted to Python 3. 107 | 108 | `pripngtopam` tool now has a `--plain` option to output plan PGM 109 | and PPM formats. The `topam` part of the name is a bit of a 110 | misnomer: when possible (L and RGB PNG files) the tool will 111 | output either a PGM (grey) or a PPM (RGB) file. Essentially all 112 | tools that can process a PAM file can also process a PGM or a 113 | PPM file. PAM files cannot be _plain_ so using the option 114 | will raise an error in the case where a true PAM file is 115 | written. 116 | 117 | Better error messages when you write the wrong number of rows. 118 | 119 | (Slightly experimentally) running the `png` module as a command 120 | line tool, with `python -m png`, will report the version and 121 | file location of the `png` module. 122 | 123 | 124 | ### Release 0.0.20 125 | 126 | Support for earlier versions of Python is dropped. 127 | Python 3.4 and onwards are supported. 128 | Python 2.7 also works, but this is the last 129 | release to support any version of Python 2. 130 | 131 | Cython code is removed, which simplifies the implementation. 132 | 133 | Removed the (optional) dependency `setuptools`. 134 | 135 | Changed the default for `png.Writer` to be greyscale. 136 | 137 | Removed 3D support from `.from_array()`. 138 | 139 | 140 | ### Release 0.0.19 141 | 142 | Support for earlier versions of Python is dropped in order to 143 | simplify the code. 144 | From the Python 3.x series all versions from 3.2 onward are supported. 145 | From the 2.x series only Python 2.6 and 2.7 are supported. 146 | 147 | Code cleaned. 148 | Tests renamed and more organised. 149 | Generally Flake 8 compliant. 150 | Fewer special cases for ancient versions of Python. 151 | 152 | The row length is checked when writing PNG files. 153 | Previously it was possible to write badly formed PNG files 154 | by passing in rows of the wrong length. 155 | 156 | `pHYS` chunk is now processed. 157 | 158 | The `Writer()` interface now supports source pixels 159 | that have a different bitdepth for each channel. 160 | To exploit this, pass in a tuple for the bitdepth argument. 161 | 162 | Ancillary tools regularised and simplified. 163 | 164 | `pripamtopng` command line tool converts NetPBM PNM/PAM files to PNG. 165 | Previously `png.py` did this. 166 | Note that only one input file is converted, 167 | if you have intensity and opacity in separate files, 168 | you have two options: 169 | either use `pamstack` to convert them into a single PAM file and 170 | convert that, or 171 | convert each file to PNG, then use `priweavepng` to weave them together. 172 | Both will work. 173 | 174 | `pripngtopam` command line tool converts PNG to NetPBM PNM/PAM file. 175 | Previously `png.py` did this. 176 | 177 | `python -m pngsuite` is now a command line tool to 178 | write various images from the PNG suite of test images. 179 | Previously this was possible using `gen`. 180 | 181 | `priweavepng` command line tool performs channel extraction across 182 | multiple images. 183 | This is a more general version of `pipstack` (which has been removed), 184 | and is inspired by `pamstack` from NetPBM. 185 | 186 | The `--interlace` option available on many previous tools is 187 | now only available on `priweavepng`, 188 | making it the preferred tool for generating interlaced PNGs. 189 | 190 | `prichunkpng` command line tool adds and deletes chunks and 191 | "intelligently" knows about transparent, gamma, background chunks. 192 | It is the preferred tool for adding those chunks, 193 | which was previously possible using various options of other tools. 194 | 195 | `gen` has been renamed to `priforgepng`. 196 | 197 | `priforgepng` uses centre pixel sampling, which means that a 256 pixel 198 | wide 8-bit gradient takes on all possible 256 values. 199 | It also improves output for very small images. 200 | 201 | `priforgepng` uses `Fraction` for internal maths meaning that 202 | the stripe patterns are accurate and do not have loose pixels. 203 | 204 | `priforgepng` only outputs greyscale PNG files 205 | (but see next item for a feature to generate colour PNGs). 206 | 207 | `priforgepng` can output multiple PNGs onto the same stream. 208 | This aligns well with a feature of `priweavepng` which 209 | accepts multiple PNGs from stdin. 210 | LA, RGB, and RGBA test images can be generated by 211 | piping `priforgepng` into `priweavepng`: 212 | `priforgepng RTL RTR RBR | priweavepng - - -` 213 | will generate an RGB PNG. 214 | 215 | 216 | ### Release 0.0.18 217 | 218 | Thanks to `github.com/sean-duffy`, 219 | `.from_array()` can now take a 3D array. 220 | 221 | Converting to PNMs was broken in Python 3; this is now fixed. 222 | Github issue 26: https://github.com/drj11/pypng/issues/26 223 | 224 | 225 | ### Release 0.0.17 226 | 227 | Various fixes when running on Python 3 and Windows. 228 | Merging pull requests from `github.com/ironfroggy` and 229 | `github.com/techtonik`, 230 | and merging by hand a commit from `github.com/Scondo`. 231 | 232 | 233 | ### Release 0.0.16 234 | 235 | Compatible with nose: `nosetests png.py` now works. 236 | 237 | Allow any "file-like" object as an input. 238 | 239 | Handle newlines in `texttopng`. 240 | 241 | 242 | ### Release 0.0.15 243 | 244 | Fixed various URLs to point at github.com instead of googlecode. 245 | 246 | 247 | ### Release 0.0.14 248 | 249 | When using `png.py` as a command line tool, 250 | it can now produce non-square test images. 251 | 252 | PyPNG now installs "out of the box" on Python 3 on a plain install 253 | (previously `distribute` or `pip` was required). 254 | 255 | PyPNG welcomes the following community contributions: 256 | 257 | Joaquín Cuenca Abela speeds up PNG reading when Cython is available. 258 | 259 | Josh Bleecher Snyder adds a lenient mode 260 | which has relaxed checksum checking. 261 | 262 | nathan@dunfield.info fixed a problem writing files 263 | when using the command line tool on Windows (Issue 62). 264 | 265 | The following issues have been fixed: 266 | 267 | On github: 268 | 269 | Issue 6: Palette processing is annoying 270 | 271 | On googlecode: 272 | 273 | Issue 62: Problem writing PNG files on Windows 274 | 275 | Development has moved from googlecode to github. 276 | All issues below here, and the one immediately above, 277 | are from the googlecode issue tracker. 278 | All newer issue should be on github. 279 | 280 | 281 | ### Release 0.0.13 282 | 283 | PyPNG now installs "out of the box" on Python 3. 284 | Thanks to simon.sapin@kozea.fr and nathan@dunfield.info for the patch. 285 | 286 | The following issues have been fixed: 287 | 288 | Issue 63: setup.py does not use 2to3 289 | Issue 64: Typo in documentation 290 | 291 | 292 | ### Release 0.0.12 293 | 294 | PyPNG now works on Python 3 if you use the `2to3` tool. 295 | Fix for converting grey images to RGBA. 296 | 297 | The following issues have been fixed: 298 | 299 | Issue 60: Greyscale images not properly being converted to RGBA 300 | Issue 61: Doesn't work on Python 3 301 | 302 | 303 | ### Release 0.0.11 304 | 305 | Added the "How Fast is PyPNG" section to the documentation. 306 | Changed it so that more PNG formats return their rows as 307 | Python `array.array` instances. 308 | 309 | 310 | ### Release 0.0.10 311 | 312 | Fix for read_flat method (broken for ages). 313 | 314 | The following issues have been fixed: 315 | 316 | Issue 56: read_flat broken 317 | 318 | 319 | ### Release 0.0.9 320 | 321 | Tentative fix for a deprecation warning on 64-bit Python 2.5 systems. 322 | Conversion tool for Plan 9 images. 323 | 324 | Issue 54 (below) is tentative. 325 | The PyPNG developers have been unable to reproduce the error 326 | (as it seems to be on 64-bit Python 2.5 systems); 327 | any user reports would be most welcome. 328 | 329 | The following issues have been fixed: 330 | 331 | Issue 54: Deprecation warnings when using pypng. 332 | Issue 55: Cannot convert Plan 9 images. 333 | 334 | 335 | ### Release 0.0.8 336 | 337 | Mostly more robust to dodgy input PNGs, 338 | as a result of testing with `brokensuite`. 339 | One fixed bug was a critical: 340 | an infinite loop for a least one input (Issue 52 below). 341 | 342 | The following issues have been fixed: 343 | 344 | Issue 47: Leading blanks when using write_packed. 345 | Issue 48: pipdither fails when input has no gamma chunk. 346 | Issue 49: pipdither fail with 1-bit input. 347 | Issue 50: pipchunk adds second gamma chunk. 348 | Issue 51: piprgb and pipasgrey fail for color mapped images. 349 | Issue 52: Some inputs cause infinite loop. 350 | 351 | 352 | ### Release 0.0.7 353 | 354 | Better documentation (in `html/ex.html` mostly) for NumPy integration. 355 | 356 | The following issues have been fixed: 357 | 358 | Issue 46: Unclear how to get PNG pixel data into and out of NumPy. 359 | 360 | 361 | ### Release 0.0.6 362 | 363 | NumPy integer types now work. 364 | 365 | The following issues have been fixed: 366 | 367 | Issue 44: Cannot use numpy.uint16 for pixel values. 368 | 369 | 370 | ### Release 0.0.5 371 | 372 | `sBIT` chunks are now handled, 373 | meaning that PyPNG can handle any (single) bit depth from 1 to 16 374 | from end to end. 375 | 376 | The following issues have been fixed: 377 | 378 | Issue 28: Does not add sBIT chunk. 379 | Issue 36: Ignores sBIT chunk when present. 380 | 381 | 382 | ### Release 0.0.4 383 | 384 | PyPNG now works on Python 2.2 385 | (significant for Symbian users as PyS60 is based on Python 2.2). 386 | Not all features are supported on Python 2.2. 387 | 388 | The following issues have been fixed: 389 | 390 | Issue 16: Source and doc uses 'K' where it should use 'L'. 391 | Issue 32: Does not accept packed data. 392 | Issue 33: Cannot create greyscale PNG with transparency. 393 | Issue 35: Does not work on Python 2.2. 394 | 395 | 396 | ### Release 0.0.3 397 | 398 | Handling PAM files allows end to end handling of alpha channels in 399 | workflows that involve both Netpbm formats and PNG. 400 | PyPNG now works in Python 2.3. 401 | 402 | The following issues have been fixed: 403 | 404 | Issue 14: Does not read PAM files. 405 | Issue 15: Does not write PAM files. 406 | Issue 25: Incorrect handling of tRNS chunk. 407 | Issue 26: asRGBA8 method crashes out for color type 2 images. 408 | Issue 27: Fails on Python 2.3. 409 | 410 | 411 | ### Release 0.0.2 412 | 413 | Lickable HTML documentation is now provided (see the html/ directory), 414 | generated by Sphinx. 415 | 416 | The following issues have been fixed: 417 | 418 | Issue 8: Documentation is not lickable. 419 | Issue 9: Advantage over PIL is not clear. 420 | Issue 19: Bogus message for PNM inputs with unsupported maxval 421 | Issue 20: Cannot write large PNG files 422 | 423 | 424 | ### Release 0.0.1 425 | 426 | Stuff happened. 427 | 428 | 429 | ## MANIFEST 430 | 431 | - .../ - top-level crud (like this README, and setup.py). 432 | - .../asset - assets (needed for testing) 433 | - .../code/ - the Python code. 434 | - .../man/ - manuals (in source/plain-text). 435 | - .../proc/ - documented procedures (release procedure). 436 | 437 | 438 | ## REFERENCES 439 | 440 | - Python: www.python.org 441 | - PNG: http://www.w3.org/TR/PNG/ 442 | 443 | ## END 444 | 445 | 446 | -------------------------------------------------------------------------------- /ext/pypng-0.0.21.dist-info/RECORD: -------------------------------------------------------------------------------- 1 | ../../bin/prichunkpng,sha256=Ry5dvctZeLUUZrvXxk3xkQHko_4gYvUC9a-4uEdrIcs,7588 2 | ../../bin/priditherpng,sha256=fZr8vOogXF89UIKwwiAfagMsEx3vHyRNBHo6c8N6DJc,7756 3 | ../../bin/priforgepng,sha256=5Ylo7IrilM4AeKFxz2a2981Vpbhb0TkAi097WfUWigM,5919 4 | ../../bin/prigreypng,sha256=7-TOWDVF-MBxYT9qJ0uEg3IRKEMEUyog05rHhEG2RC8,1863 5 | ../../bin/pripalpng,sha256=WS0dA6uHWkBEs_AYy6-oQVZqk-35rr8_y83sl6pyAY8,2502 6 | ../../bin/pripamtopng,sha256=pf_vgakzkVF6of_dPUvmr_o-r6FFVPxCJjkiqNWsL4E,8194 7 | ../../bin/pripnglsch,sha256=TgPaCB8qOr5J16SihbKV-yNeYSH4JWQosZjAqWW_9eM,678 8 | ../../bin/pripngtopam,sha256=BdEdoEBKGbfaqK-W7Uzxl19gTYbwWvX_dqwwWAVmKf0,2694 9 | ../../bin/priweavepng,sha256=thA1aaGcp7VTaCVHtCYG0GAIzlNKuXvTv4dkMNqg8uQ,6611 10 | __pycache__/png.cpython-38.pyc,, 11 | png.py,sha256=n3CpAz8Pf0QScZx6UcrZBDwBh9_glpizwbBOu4WdF98,81765 12 | pypng-0.0.21.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 13 | pypng-0.0.21.dist-info/LICENCE,sha256=jdEn2Hu5Aaucj1hOmLfHqoU52yf-Yv8Bse5L6TtqUTo,1038 14 | pypng-0.0.21.dist-info/METADATA,sha256=5w1Obt_RxjLEvzi1l80OX7RtIrIpcwm3MpqLlzFqAYw,12480 15 | pypng-0.0.21.dist-info/RECORD,, 16 | pypng-0.0.21.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 17 | pypng-0.0.21.dist-info/WHEEL,sha256=OqRkF0eY5GHssMorFjlbTIq072vpHpF60fIQA6lS9xA,92 18 | pypng-0.0.21.dist-info/top_level.txt,sha256=M9g0SnE1xCqjh2cGuQj5W3Atg_9T4F5Kr_F8B79nqY4,4 19 | -------------------------------------------------------------------------------- /ext/pypng-0.0.21.dist-info/REQUESTED: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/ext/pypng-0.0.21.dist-info/REQUESTED -------------------------------------------------------------------------------- /ext/pypng-0.0.21.dist-info/WHEEL: -------------------------------------------------------------------------------- 1 | Wheel-Version: 1.0 2 | Generator: bdist_wheel (0.36.2) 3 | Root-Is-Purelib: true 4 | Tag: py3-none-any 5 | 6 | -------------------------------------------------------------------------------- /ext/pypng-0.0.21.dist-info/top_level.txt: -------------------------------------------------------------------------------- 1 | png 2 | -------------------------------------------------------------------------------- /helpers/mathHelper.py: -------------------------------------------------------------------------------- 1 | import math, random 2 | 3 | def percentile(data, perc: int): 4 | size = len(data) 5 | return sorted(data)[int(math.ceil((size * perc) / 100)) - 1] 6 | 7 | def lerp(lo, hi, t): 8 | return lo * (1 - t) + hi * t 9 | 10 | def smoothstep(t): 11 | return t * t * (3 - 2 * t) 12 | -------------------------------------------------------------------------------- /helpers/meshHelper.py: -------------------------------------------------------------------------------- 1 | import adsk 2 | from adsk.core import ProgressDialog, Vector2D, Vector3D 3 | #from sympy.solvers.diophantine.diophantine import norm 4 | 5 | 6 | class Body: 7 | def __init__(self, vertices:"list[list[float]]", textureCoordinates, normals, facets, name:str = "Body", mtllib = None): 8 | self.name = name 9 | self.vertices = vertices 10 | self.textureCoordinates = textureCoordinates 11 | self.normals = normals 12 | self.facets = facets 13 | self.mtllib = mtllib 14 | 15 | # Reads a Wavefront Obj file and returns it as a Body 16 | def readObjMesh(path: str) -> Body: 17 | vertices = [] 18 | textureCoordinates = [] 19 | vertexNormals = [] 20 | facets = [] 21 | with open(path) as file: 22 | for line in file: 23 | listOfValues = line.rstrip().split() 24 | if len(listOfValues) > 0: 25 | if listOfValues[0] == 'v': 26 | vertices.append([float(element) for element in listOfValues[1:]]) 27 | elif listOfValues[0] == 'vt': 28 | textureCoordinates.append([float(element) for element in listOfValues[1:]]) 29 | elif listOfValues[0] == 'vn': 30 | vertexNormals.append([float(element) for element in listOfValues[1:]]) 31 | elif listOfValues[0] == 'f': 32 | facets.append([float(element) for element in listOfValues[1:]]) 33 | elif listOfValues[0] == 'g': 34 | name = listOfValues[1] 35 | elif listOfValues[0] == 'mtllib': 36 | mtllib = listOfValues[1] 37 | return Body(vertices, textureCoordinates, vertexNormals, facets, name, mtllib) 38 | 39 | # Writes a Body to a Wavefront Obj file at path 40 | def writeObjMesh(path: str, body: Body): 41 | with open(path, 'w') as file: 42 | if body.mtllib: 43 | file.write('mtllib ' + body.mtllib + '\n') 44 | file.write('g ' + body.name + '\n') 45 | for v in body.vertices: 46 | file.write('v ' + " ".join([str(element) for element in v]) + '\n') 47 | for vt in body.textureCoordinates: 48 | file.write('vt ' + " ".join([str(element) for element in vt]) + '\n') 49 | for vn in body.normals: 50 | file.write('vn ' + " ".join([str(element) for element in vn]) + '\n') 51 | for f in body.facets: 52 | file.write('f ' + " ".join([str(element) for element in f]) + '\n') 53 | 54 | #Transforms the a Fusion360 PolygonMesh into a Body. Only uses triangles, not quads 55 | def fusionPolygonMeshToBody(mesh) -> Body: 56 | vertices = [x.getData()[1:] for x in mesh.nodeCoordinates] 57 | normals = [] 58 | normalVectors = list(mesh.normalVectorsAsDouble) 59 | for i in range(len(normalVectors)): 60 | if i%3==0: 61 | normals.append(normalVectors[i:i+3]) 62 | facets = [] 63 | if mesh.triangleCount > 0: 64 | indices = list(mesh.triangleNodeIndices) 65 | for i in range(len(indices)): 66 | if i%3==0: 67 | facets.append([x+1 for x in indices[i:i+3]]) # We have to increase each index by 1, because fusion and obj use different indeces 68 | return Body(vertices, [], normals, facets, "dummy", "plane.mtl") #ToDo: read mtllib 69 | 70 | def calculateAppropriateNoiseLevel(body:Body) -> float: 71 | n = 10 72 | xValues = [v[0] for v in body.vertices[0::n]] 73 | yValues = [v[1] for v in body.vertices[0::n]] 74 | zValues = [v[2] for v in body.vertices[0::n]] 75 | 76 | rangeX = max(xValues)-min(xValues) 77 | rangeY = max(yValues)-min(yValues) 78 | rangeZ = max(zValues)-min(zValues) 79 | mean = (rangeX+rangeY+rangeZ)/3 80 | return mean/10 81 | 82 | def calculateAverageFaceSize(body:Body, percentage:float) -> float: 83 | n = int(len(body.facets)*percentage) 84 | faces = body.facets[0::n] 85 | areas = [] 86 | for f in faces: 87 | a = Vector3D.create(body.vertices[f[0]-1][0], body.vertices[f[0]-1][1], body.vertices[f[0]-1][2]) 88 | b = Vector3D.create(body.vertices[f[1]-1][0], body.vertices[f[1]-1][1], body.vertices[f[1]-1][2]) 89 | c = Vector3D.create(body.vertices[f[2]-1][0], body.vertices[f[2]-1][1], body.vertices[f[2]-1][2]) 90 | areas.append(0.5* (a.crossProduct(b).crossProduct(a.crossProduct(c))).length) 91 | mean = sum(areas)/len(areas) 92 | print(mean) 93 | return mean 94 | -------------------------------------------------------------------------------- /helpers/pngHelper.py: -------------------------------------------------------------------------------- 1 | from ..ext import png 2 | 3 | class GrungeMap: 4 | def __init__(self, sizeX:int, sizeY:int, values:"list[int]"): 5 | self.x = sizeX 6 | self.y = sizeY 7 | self.values = values 8 | 9 | def readPng(filename): 10 | file = png.Reader(filename=filename) 11 | info = file.read_flat() 12 | sizeX = info[1] 13 | sizeY = info[0] 14 | isGrey = info[3]['greyscale'] 15 | hasAlpha = info[3]['alpha'] 16 | if 'palette' in info[3]: 17 | palette = info[3]['palette'] 18 | else: 19 | palette = None 20 | pixelValues = list(info[2]) 21 | 22 | minValue = min(pixelValues) 23 | maxValue = max(pixelValues) 24 | 25 | if isGrey: 26 | if hasAlpha: 27 | pixelsWithoutAlpha = pixelValues[0::2] 28 | flatValuesScaled = [(x-minValue)/(maxValue-minValue) for x in pixelsWithoutAlpha] 29 | else: 30 | flatValuesScaled = [(x-minValue)/(maxValue-minValue) for x in pixelValues] 31 | else: 32 | if palette: 33 | #print(len(palette[0])) 34 | def applyPalette(x): 35 | return round(0.299*palette[x][0]+0.587*palette[x][1]+0.114*palette[x][2],1) 36 | appliedPalette = [applyPalette(x) for x in pixelValues] 37 | minValue = min(appliedPalette) 38 | maxValue = max(appliedPalette) 39 | flatValuesScaled = [(x-minValue)/(maxValue-minValue) for x in appliedPalette] 40 | #print(flatValuesScaled) 41 | else: 42 | if hasAlpha: 43 | r = pixelValues[0::4] 44 | g = pixelValues[1::4] 45 | b = pixelValues[2::4] 46 | else: 47 | r = pixelValues[0::3] 48 | g = pixelValues[1::3] 49 | b = pixelValues[2::3] 50 | flatValuesScaled = [(x-minValue)/(maxValue-minValue) for x in list(map(lambda x: 0.299*x[0]+0.587*x[1]+0.114*x[2], zip(r,g,b)))] 51 | 52 | values = [] 53 | #for i in range(sizeX): 54 | # values.append([]) 55 | # for j in range(sizeY): 56 | # values[i].append(flatValuesScaled[i*sizeX + j]) 57 | 58 | for j in range(sizeY): 59 | values.append([]) 60 | for j in range(sizeY-1,-1,-1): 61 | for i in range(sizeX-1,-1,-1): 62 | values[j].append(flatValuesScaled[i*sizeX + j]) 63 | 64 | return GrungeMap(sizeX,sizeY,values) -------------------------------------------------------------------------------- /noises/grungeMapNoise.py: -------------------------------------------------------------------------------- 1 | import random, math, time 2 | from ..helpers.meshHelper import Body 3 | from ..helpers.mathHelper import * 4 | from ..helpers.pngHelper import GrungeMap 5 | from adsk.core import ProgressDialog, Vector2D, Vector3D 6 | import adsk.core 7 | 8 | def grungeMapNoise(body:Body, map:GrungeMap, amplitude, inverse, smooth, plane,progressDialog=None): 9 | if plane == 'xY' or plane == None: 10 | xValues = [v[0] for v in body.vertices] 11 | yValues = [v[1] for v in body.vertices] 12 | elif plane == 'xZ': 13 | xValues = [v[0] for v in body.vertices] 14 | yValues = [v[2] for v in body.vertices] 15 | elif plane == 'yZ': 16 | xValues = [v[1] for v in body.vertices] 17 | yValues = [v[2] for v in body.vertices] 18 | 19 | #make a lattice grid 20 | lattice = map.values 21 | 22 | def getNoiseValue(x,y): 23 | xMin = min(int(x),map.x-1) 24 | yMin = min(int(y),map.y-1) 25 | tx = x - xMin 26 | ty = y - yMin 27 | if smooth: 28 | tx = smoothstep(tx) 29 | ty = smoothstep(ty) 30 | 31 | rx0 = xMin 32 | rx1 = min(xMin+1,map.x-1) 33 | ry0 = yMin 34 | ry1 = min(yMin+1,map.y-1) 35 | 36 | c00 = lattice[rx0][ry0] 37 | c10 = lattice[rx1][ry0] 38 | c01 = lattice[rx0][ry1] 39 | c11 = lattice[rx1][ry1] 40 | 41 | nx0 = lerp(c00, c10, tx) 42 | nx1 = lerp(c01, c11, tx) 43 | return lerp(nx0, nx1, ty) 44 | 45 | minX = min(xValues) 46 | maxX = max(xValues) 47 | minY = min(yValues) 48 | maxY = max(yValues) 49 | 50 | xValuesScaled = [(x- minX)/(maxX-minX) * (map.x) for x in xValues] 51 | yValuesScaled = [(y- minY)/(maxY-minY) * (map.y) for y in yValues] 52 | xyValuesScaled = list(zip(xValuesScaled,yValuesScaled)) 53 | 54 | allSteps = len(body.vertices) 55 | maxSteps = allSteps - allSteps/20 56 | for i in range(len(xyValuesScaled)): 57 | # Update progress value of progress dialog 58 | if progressDialog: 59 | if progressDialog.wasCancelled: 60 | raise ValueError('CanceledProgress') 61 | if i%(int(allSteps/20)+1)==0: 62 | progressDialog.progressValue = i+1 63 | elif i == 0: 64 | progressDialog.progressValue = i+1 65 | elif i > maxSteps: 66 | progressDialog.progressValue = progressDialog.maximumValue 67 | 68 | b = body.vertices[i] 69 | n = body.normals[i] 70 | vec = Vector3D.create(b[0],b[1],b[2]) 71 | normal = Vector3D.create(n[0],n[1],n[2]) 72 | normal.normalize() 73 | ### 74 | noise = getNoiseValue(xyValuesScaled[i][0],xyValuesScaled[i][1]) 75 | if inverse: 76 | normal.scaleBy(noise*amplitude) 77 | else: 78 | normal.scaleBy(-noise*amplitude) 79 | ## Just a workaround to level the result 80 | normal.add(Vector3D.create(0,0,amplitude)) 81 | vec.add(normal) 82 | ### 83 | body.vertices[i] = vec.asArray() -------------------------------------------------------------------------------- /noises/perlinNoise.py: -------------------------------------------------------------------------------- 1 | import random 2 | from ..helpers.meshHelper import Body 3 | from ..helpers.mathHelper import * 4 | from adsk.core import ProgressDialog, Vector2D, Vector3D 5 | 6 | def perlinNoise3D(body:Body, resolution:int, amplitude:float=1, frequency:float=1, signed:bool=True, smooth:bool=True, seed:int=None, progressDialog:ProgressDialog=None) -> Body: 7 | if seed: 8 | random.seed(seed) 9 | xValues = [v[0] for v in body.vertices] 10 | yValues = [v[1] for v in body.vertices] 11 | zValues = [v[2] for v in body.vertices] 12 | #make a lattice grid 13 | lattice = [] 14 | for i in range(resolution): # This is the ugliest matrix init of all time 15 | lattice.append([]) 16 | for j in range(resolution): 17 | lattice[i].append([]) 18 | for k in range(resolution): 19 | #Todo: Think about wether a signed perlin noise is meaningful 20 | if signed: 21 | bottomRange = -1 22 | else: 23 | bottomRange = 0 24 | x = random.uniform(bottomRange,1) 25 | y = random.uniform(bottomRange,1) 26 | z = random.uniform(bottomRange,1) 27 | gradient = Vector3D.create(x,y,z) 28 | gradient.normalize() 29 | lattice[i][j].append(gradient) 30 | 31 | def getNoiseValue(x,y,z): 32 | xMin = min(int(x),len(lattice)-1) 33 | yMin = min(int(y),len(lattice)-1) 34 | zMin = min(int(z),len(lattice)-1) 35 | tx = x - xMin 36 | ty = y - yMin 37 | tz = z - zMin 38 | if smooth: 39 | tx = smoothstep(tx) 40 | ty = smoothstep(ty) 41 | tz = smoothstep(tz) 42 | 43 | rx0 = xMin 44 | rx1 = min(xMin+1,len(lattice)-1) 45 | ry0 = yMin 46 | ry1 = min(yMin+1,len(lattice)-1) 47 | rz0 = zMin 48 | rz1 = min(zMin+1,len(lattice)-1) 49 | 50 | # Get the surrounding gradients 51 | c000 = lattice[rx0][ry0][rz0] 52 | c100 = lattice[rx1][ry0][rz0] 53 | c010 = lattice[rx0][ry1][rz0] 54 | c001 = lattice[rx0][ry0][rz1] 55 | c110 = lattice[rx1][ry1][rz0] 56 | c101 = lattice[rx1][ry0][rz1] 57 | c011 = lattice[rx0][ry1][rz1] 58 | c111 = lattice[rx1][ry1][rz1] 59 | 60 | #Generate Vectors from the point to the gradients 61 | p000 = Vector3D.create(tx, ty, tz); 62 | p100 = Vector3D.create(tx-1, ty, tz); 63 | p010 = Vector3D.create(tx, ty-1, tz); 64 | p110 = Vector3D.create(tx-1, ty-1, tz); 65 | 66 | p001 = Vector3D.create(tx, ty, tz-1); 67 | p101 = Vector3D.create(tx-1, ty, tz-1); 68 | p011 = Vector3D.create(tx, ty-1, tz-1); 69 | p111 = Vector3D.create(tx-1, ty-1, tz-1); 70 | 71 | nx00 = lerp(c000.dotProduct(p000), c100.dotProduct(p100), tx) 72 | nx01 = lerp(c001.dotProduct(p001), c101.dotProduct(p101), tx) 73 | nx10 = lerp(c010.dotProduct(p010), c110.dotProduct(p110), tx) 74 | nx11 = lerp(c011.dotProduct(p011), c111.dotProduct(p111), tx) 75 | 76 | nxy0 = lerp(nx00, nx10, ty) 77 | nxy1 = lerp(nx01, nx11, ty) 78 | 79 | return lerp(nxy0, nxy1, tz) 80 | 81 | minX = min(xValues) 82 | maxX = max(xValues) 83 | minY = min(yValues) 84 | maxY = max(yValues) 85 | minZ = min(zValues) 86 | maxZ = max(zValues) 87 | 88 | xValuesScaled = [(x- minX)/(maxX-minX) * (resolution-1) for x in xValues] 89 | yValuesScaled = [(y- minY)/(maxY-minY) * (resolution-1) for y in yValues] 90 | if not maxZ == minZ: 91 | zValuesScaled = [(z- minZ)/(maxZ-minZ) * (resolution-1) for z in zValues] 92 | else: 93 | zValuesScaled = zValues 94 | xyzValuesScaled = list(zip(xValuesScaled,yValuesScaled,zValuesScaled)) 95 | 96 | allSteps = len(body.vertices) 97 | maxSteps = allSteps - allSteps/20 98 | for i in range(len(xyzValuesScaled)): 99 | # Update progress value of progress dialog 100 | if progressDialog: 101 | if progressDialog.wasCancelled: 102 | raise ValueError('CanceledProgress') 103 | if i%(int(allSteps/20)+1)==0: 104 | progressDialog.progressValue = i+1 105 | elif i > maxSteps: 106 | progressDialog.progressValue = progressDialog.maximumValue 107 | elif i == 0: 108 | progressDialog.progressValue = i+1 109 | 110 | b = body.vertices[i] 111 | n = body.normals[i] 112 | 113 | vec = Vector3D.create(b[0],b[1],b[2]) 114 | normal = Vector3D.create(n[0],n[1],n[2]) 115 | normal.normalize() 116 | noise = getNoiseValue(xyzValuesScaled[i][0]*frequency,xyzValuesScaled[i][1]*frequency,xyzValuesScaled[i][2]*frequency) 117 | normal.scaleBy(noise*amplitude) 118 | vec.add(normal) 119 | body.vertices[i] = vec.asArray() 120 | return body 121 | 122 | 123 | #frequency>1 -> compress the curve, frequency<1 -> stretch the curve 124 | # We don't allow frequencies > 1, as our curve is not periodic. 125 | def perlinNoise2D(body:Body, resolution:int, amplitude:float=1, frequency:float=1, signed:bool=True, smooth:bool=True, seed:int=None, progressDialog:ProgressDialog=None) -> Body: 126 | if seed: 127 | random.seed(seed) 128 | xValues = [v[0] for v in body.vertices] 129 | yValues = [v[1] for v in body.vertices] 130 | 131 | #make a lattice grid 132 | lattice = [] 133 | for i in range(resolution): 134 | lattice.append([]) 135 | for j in range(resolution): 136 | if signed: 137 | bottomRange = -1 138 | else: 139 | bottomRange = 0 140 | x = random.uniform(bottomRange,1) 141 | y = random.uniform(bottomRange,1) 142 | gradient = Vector2D.create(x,y) 143 | gradient.normalize() 144 | lattice[i].append(gradient) 145 | 146 | def getNoiseValue(x,y): 147 | xMin = min(int(x),len(lattice)-1) 148 | yMin = min(int(y),len(lattice)-1) 149 | tx = x - xMin 150 | ty = y - yMin 151 | if smooth: 152 | tx = smoothstep(tx) 153 | ty = smoothstep(ty) 154 | 155 | rx0 = xMin 156 | rx1 = min(xMin+1,len(lattice)-1) 157 | ry0 = yMin 158 | ry1 = min(yMin+1,len(lattice)-1) 159 | 160 | c00 = lattice[rx0][ry0] 161 | c10 = lattice[rx1][ry0] 162 | c01 = lattice[rx0][ry1] 163 | c11 = lattice[rx1][ry1] 164 | 165 | #Generate Vectors from point to grid gradients 166 | p00 = Vector2D.create(tx, ty); 167 | p10 = Vector2D.create(tx-1, ty); 168 | p01 = Vector2D.create(tx, ty-1); 169 | p11 = Vector2D.create(tx-1, ty-1); 170 | 171 | nx0 = lerp(c00.dotProduct(p00), c10.dotProduct(p10), tx) 172 | nx1 = lerp(c01.dotProduct(p01), c11.dotProduct(p11), tx) 173 | return lerp(nx0, nx1, ty) 174 | 175 | minX = min(xValues) 176 | maxX = max(xValues) 177 | minY = min(yValues) 178 | maxY = max(yValues) 179 | 180 | xValuesScaled = [(x- minX)/(maxX-minX) * (resolution-1) for x in xValues] 181 | yValuesScaled = [(y- minY)/(maxY-minY) * (resolution-1) for y in yValues] 182 | xyValuesScaled = list(zip(xValuesScaled,yValuesScaled)) 183 | 184 | allSteps = len(body.vertices) 185 | maxSteps = allSteps - allSteps/20 186 | for i in range(len(xyValuesScaled)): 187 | # Update progress value of progress dialog 188 | if progressDialog: 189 | if progressDialog.wasCancelled: 190 | raise ValueError('CanceledProgress') 191 | if i%(int(allSteps/20)+1)==0: 192 | progressDialog.progressValue = i+1 193 | elif i > maxSteps: 194 | progressDialog.progressValue = progressDialog.maximumValue 195 | 196 | b = body.vertices[i] 197 | n = body.normals[i] 198 | vec = Vector3D.create(b[0],b[1],b[2]) 199 | normal = Vector3D.create(n[0],n[1],n[2]) 200 | normal.normalize() 201 | ### 202 | noise = getNoiseValue(xyValuesScaled[i][0]*frequency,xyValuesScaled[i][1]*frequency) 203 | normal.scaleBy(noise*amplitude) 204 | vec.add(normal) 205 | ### 206 | body.vertices[i] = vec.asArray() 207 | 208 | #Here a proper linAlg library could be useful for performance and for noise in normal vector direction... 209 | #though the noise in one diretion can look much cooler sometimes. should be an option 210 | #body.vertices[i][2] += getNoiseValue(xyValuesScaled[i][0],xyValuesScaled[i][1]) -------------------------------------------------------------------------------- /noises/randomNoise.py: -------------------------------------------------------------------------------- 1 | import random 2 | from ..helpers.meshHelper import Body 3 | from adsk.core import ProgressDialog, Vector2D, Vector3D 4 | 5 | # TODO: Dass die funktionen den body returnen ist natürlich aktuell nutzlos. Der originale body wird verändert 6 | 7 | #def scaleMesh(body:Body, scalar:int) -> Body: 8 | # body.vertices = (scalar*Matrix(body.vertices)).tolist() 9 | # return body 10 | 11 | #def scaleMeshByAxis(body:Body, x=1., y=1., z=1.) -> Body: 12 | # mat = Matrix(body.vertices) 13 | # mat[:,0] = (x*(Matrix(body.vertices)[:,0])) 14 | # mat[:,1] = (y*(Matrix(body.vertices)[:,1])) 15 | # mat[:,2] = (z*(Matrix(body.vertices)[:,2])) 16 | # body.vertices = mat.tolist() 17 | # return body 18 | 19 | #randomly distorts each x,y,z coordinate of each vertex 20 | def randomDistortion(body:Body, degree:float, seed:int=None) -> Body: 21 | if seed: 22 | random.seed(seed) 23 | res = [] 24 | for v in body.vertices: 25 | res.append([random.uniform(-degree,degree)+float(el) for el in v]) 26 | body.vertices = res 27 | return body 28 | 29 | def randomDistortionForVertices(vertices, degree:float, seed:int=None): 30 | if seed: 31 | random.seed(seed) 32 | res = [] 33 | for v in vertices: 34 | res.append([random.uniform(-degree,degree)+float(el) for el in v]) 35 | return res 36 | 37 | #randomly distorts each vertex. This seems to preserve some faces TODO: Warum? 38 | def randomGeneralDistortion(body:Body, degree:float, seed:int=None) -> Body: 39 | if seed: 40 | random.seed(seed) 41 | res = [] 42 | for v in body.vertices: 43 | i = random.uniform(-degree,degree) 44 | res.append([i+float(el) for el in v]) 45 | body.vertices = res 46 | return body 47 | 48 | # Distorts each vertex by the given degree. The degree is scaled according to the face size 49 | # If inverse=False then bigger faces are distorted more extremely 50 | # if inverse=True then smaller faces are distorted more extremely 51 | def adaptiveVertexDistortion(body, degree:float, inverse=False, seed:int=None, progressDialog=None): 52 | if seed: 53 | random.seed(seed) 54 | res = [] 55 | areas = [] 56 | for f in body.facets: 57 | a = Vector3D.create(body.vertices[f[0]-1][0], body.vertices[f[0]-1][1], body.vertices[f[0]-1][2]) 58 | b = Vector3D.create(body.vertices[f[1]-1][0], body.vertices[f[1]-1][1], body.vertices[f[1]-1][2]) 59 | c = Vector3D.create(body.vertices[f[2]-1][0], body.vertices[f[2]-1][1], body.vertices[f[2]-1][2]) 60 | areas.append(0.5* (a.crossProduct(b).crossProduct(a.crossProduct(c))).length) 61 | if inverse: 62 | maxArea = min(areas) 63 | minArea = max(areas) 64 | else: 65 | minArea = min(areas) 66 | maxArea = max(areas) 67 | 68 | if maxArea == minArea: 69 | raise ValueError('All faces of the mesh are of the same size. Adaptive Noise can not be applied. ') 70 | areas = list(map(lambda x: (x- minArea)/(maxArea-minArea)*(1-0)+0, areas)) 71 | allSteps = len(body.facets) 72 | maxSteps = allSteps - allSteps/20 73 | i=0 74 | for f,a in zip(body.facets,areas): 75 | i+=1 76 | if progressDialog: 77 | if progressDialog.wasCancelled: 78 | raise ValueError('CanceledProgress') 79 | if i%(int(allSteps/20)+1)==0: 80 | progressDialog.progressValue = i+1 81 | elif i > maxSteps: 82 | progressDialog.progressValue = progressDialog.maximumValue 83 | 84 | body.vertices[f[0]-1] = [random.uniform(-degree,degree)*a + float(el) for el in body.vertices[f[0]-1]] 85 | body.vertices[f[1]-1] = [random.uniform(-degree,degree)*a + float(el) for el in body.vertices[f[1]-1]] 86 | body.vertices[f[2]-1] = [random.uniform(-degree,degree)*a + float(el) for el in body.vertices[f[2]-1]] 87 | return res 88 | 89 | #similar to the one above but only scales in one direction. Looks super weird 90 | def weirdScalyDistortion(body, degree:float, seed:int=None): 91 | if seed: 92 | random.seed(seed) 93 | res = [] 94 | areas = [] 95 | for f in body.facets: 96 | a = Vector3D.create(body.vertices[f[0]-1][0], body.vertices[f[0]-1][1], body.vertices[f[0]-1][2]) 97 | b = Vector3D.create(body.vertices[f[1]-1][0], body.vertices[f[1]-1][1], body.vertices[f[1]-1][2]) 98 | c = Vector3D.create(body.vertices[f[2]-1][0], body.vertices[f[2]-1][1], body.vertices[f[2]-1][2]) 99 | areas.append(0.5* (a.crossProduct(b).crossProduct(a.crossProduct(c))).length) 100 | minArea = min(areas) 101 | maxArea = max(areas) 102 | areas = list(map(lambda x: (x- minArea)/(maxArea-minArea), areas)) 103 | for f,a in zip(body.facets,areas): 104 | i = random.uniform(-degree,degree) 105 | 106 | body.vertices[f[0]-1] = [i*a + float(el) for el in body.vertices[f[0]-1]] 107 | body.vertices[f[1]-1] = [i*a + float(el) for el in body.vertices[f[1]-1]] 108 | body.vertices[f[2]-1] = [i*a + float(el) for el in body.vertices[f[2]-1]] 109 | return res -------------------------------------------------------------------------------- /noises/valueNoise.py: -------------------------------------------------------------------------------- 1 | import random 2 | from ..helpers.meshHelper import Body 3 | from ..helpers.mathHelper import * 4 | from adsk.core import ProgressDialog, Vector2D, Vector3D 5 | 6 | def valueNoise3D(body:Body, resolutionX:int, resolutionY:int, resolutionZ:int, amplitude:float=1, frequency:float=1, signed:bool=True, smooth:bool=True, seed:int=None, progressDialog:ProgressDialog=None) -> Body: 7 | if seed: 8 | random.seed(seed) 9 | xValues = [v[0] for v in body.vertices] 10 | yValues = [v[1] for v in body.vertices] 11 | zValues = [v[2] for v in body.vertices] 12 | #make a lattice grid 13 | lattice = [] 14 | for i in range(resolutionX): # This is the ugliest matrix init of all time 15 | lattice.append([]) 16 | for j in range(resolutionY): 17 | lattice[i].append([]) 18 | for k in range(resolutionZ): 19 | if signed: 20 | lattice[i][j].append(random.uniform(-1,1)) 21 | else: 22 | lattice[i][j].append(random.uniform(0,1)) 23 | 24 | def getNoiseValue(x,y,z): 25 | xMin = min(int(x),len(lattice)-1) 26 | yMin = min(int(y),len(lattice[0])-1) 27 | zMin = min(int(z),len(lattice[0][0])-1) 28 | tx = x - xMin 29 | ty = y - yMin 30 | tz = z - zMin 31 | if smooth: 32 | tx = smoothstep(tx) 33 | ty = smoothstep(ty) 34 | tz = smoothstep(tz) 35 | 36 | rx0 = xMin 37 | rx1 = min(xMin+1,len(lattice)-1) 38 | ry0 = yMin 39 | ry1 = min(yMin+1,len(lattice[0])-1) 40 | rz0 = zMin 41 | rz1 = min(zMin+1,len(lattice[0][0])-1) 42 | 43 | c000 = lattice[rx0][ry0][rz0] 44 | c100 = lattice[rx1][ry0][rz0] 45 | c010 = lattice[rx0][ry1][rz0] 46 | c001 = lattice[rx0][ry0][rz1] 47 | c110 = lattice[rx1][ry1][rz0] 48 | c101 = lattice[rx1][ry0][rz1] 49 | c011 = lattice[rx0][ry1][rz1] 50 | c111 = lattice[rx1][ry1][rz1] 51 | 52 | nx00 = lerp(c000, c100, tx) 53 | nx01 = lerp(c001, c101, tx) 54 | nx10 = lerp(c010, c110, tx) 55 | nx11 = lerp(c011, c111, tx) 56 | 57 | nxy0 = lerp(nx00, nx10, ty) 58 | nxy1 = lerp(nx01, nx11, ty) 59 | 60 | return lerp(nxy0, nxy1, tz) 61 | 62 | minX = min(xValues) 63 | maxX = max(xValues) 64 | minY = min(yValues) 65 | maxY = max(yValues) 66 | minZ = min(zValues) 67 | maxZ = max(zValues) 68 | 69 | xValuesScaled = [(x- minX)/(maxX-minX) * (resolutionX-1) for x in xValues] 70 | yValuesScaled = [(y- minY)/(maxY-minY) * (resolutionY-1) for y in yValues] 71 | if not maxZ == minZ: 72 | zValuesScaled = [(z- minZ)/(maxZ-minZ) * (resolutionZ-1) for z in zValues] 73 | else: 74 | zValuesScaled = zValues 75 | xyzValuesScaled = list(zip(xValuesScaled,yValuesScaled,zValuesScaled)) 76 | 77 | allSteps = len(body.vertices) 78 | maxSteps = allSteps - allSteps/20 79 | for i in range(len(xyzValuesScaled)): 80 | # Update progress value of progress dialog 81 | if progressDialog: 82 | if progressDialog.wasCancelled: 83 | raise ValueError('CanceledProgress') 84 | if i%(int(allSteps/20)+1)==0: 85 | progressDialog.progressValue = i+1 86 | elif i > maxSteps: 87 | progressDialog.progressValue = progressDialog.maximumValue 88 | 89 | b = body.vertices[i] 90 | n = body.normals[i] 91 | 92 | vec = Vector3D.create(b[0],b[1],b[2]) 93 | normal = Vector3D.create(n[0],n[1],n[2]) 94 | normal.normalize() 95 | noise = getNoiseValue(xyzValuesScaled[i][0]*frequency,xyzValuesScaled[i][1]*frequency,xyzValuesScaled[i][2]*frequency) 96 | normal.scaleBy(noise*amplitude) 97 | vec.add(normal) 98 | body.vertices[i] = vec.asArray() 99 | return body 100 | 101 | 102 | #frequency>1 -> compress the curve, frequency<1 -> stretch the curve 103 | # We don't allow frequencies > 1, as our curve is not periodic. 104 | def valueNoise2D(body:Body, resolutionX:int, resolutionY:int, amplitude:float=1, frequency:float=1, signed:bool=True, smooth:bool=True, seed:int=None, progressDialog:ProgressDialog=None) -> Body: 105 | if seed: 106 | random.seed(seed) 107 | xValues = [v[0] for v in body.vertices] 108 | yValues = [v[1] for v in body.vertices] 109 | #zValues = [v[2] for v in body.vertices] 110 | 111 | #make a lattice grid 112 | lattice = [] 113 | for i in range(resolutionX): 114 | lattice.append([]) 115 | for j in range(resolutionY): 116 | if signed: 117 | lattice[i].append(random.uniform(-1,1)) 118 | else: 119 | lattice[i].append(random.uniform(0,1)) 120 | 121 | def getNoiseValue(x,y): 122 | xMin = min(int(x),len(lattice)-1) 123 | yMin = min(int(y),len(lattice[0])-1) 124 | tx = x - xMin 125 | ty = y - yMin 126 | if smooth: 127 | tx = smoothstep(tx) 128 | ty = smoothstep(ty) 129 | 130 | rx0 = xMin 131 | rx1 = min(xMin+1,len(lattice)-1) 132 | ry0 = yMin 133 | ry1 = min(yMin+1,len(lattice[0])-1) 134 | 135 | c00 = lattice[rx0][ry0] 136 | c10 = lattice[rx1][ry0] 137 | c01 = lattice[rx0][ry1] 138 | c11 = lattice[rx1][ry1] 139 | 140 | nx0 = lerp(c00, c10, tx) 141 | nx1 = lerp(c01, c11, tx) 142 | return lerp(nx0, nx1, ty) 143 | 144 | minX = min(xValues) 145 | maxX = max(xValues) 146 | minY = min(yValues) 147 | maxY = max(yValues) 148 | 149 | xValuesScaled = [(x- minX)/(maxX-minX) * (resolutionX-1) for x in xValues] 150 | yValuesScaled = [(y- minY)/(maxY-minY) * (resolutionY-1) for y in yValues] 151 | xyValuesScaled = list(zip(xValuesScaled,yValuesScaled)) 152 | 153 | allSteps = len(body.vertices) 154 | maxSteps = allSteps - allSteps/20 155 | for i in range(len(xyValuesScaled)): 156 | # Update progress value of progress dialog 157 | if progressDialog: 158 | if progressDialog.wasCancelled: 159 | raise ValueError('CanceledProgress') 160 | if i%(int(allSteps/20)+1)==0: 161 | progressDialog.progressValue = i+1 162 | elif i > maxSteps: 163 | progressDialog.progressValue = progressDialog.maximumValue 164 | 165 | b = body.vertices[i] 166 | n = body.normals[i] 167 | vec = Vector3D.create(b[0],b[1],b[2]) 168 | normal = Vector3D.create(n[0],n[1],n[2]) 169 | normal.normalize() 170 | ### 171 | noise = getNoiseValue(xyValuesScaled[i][0]*frequency,xyValuesScaled[i][1]*frequency) 172 | normal.scaleBy(noise*amplitude) 173 | vec.add(normal) 174 | ### 175 | body.vertices[i] = vec.asArray() 176 | 177 | #Here a proper linAlg library could be useful for performance and for noise in normal vector direction... 178 | #though the noise in one diretion can look much cooler sometimes. should be an option 179 | #body.vertices[i][2] += getNoiseValue(xyValuesScaled[i][0],xyValuesScaled[i][1]) 180 | 181 | 182 | 183 | 184 | def valueNoise1D(body:Body, resolution:int, amplitude:float=1, frequency:float=1, signed:bool=True, smooth:bool=True, seed:int=None, progressDialog:ProgressDialog=None) -> Body: 185 | if seed: 186 | random.seed(seed) 187 | xValues = [v[0] for v in body.vertices] 188 | #yValues = [v[1] for v in body.vertices] 189 | #zValues = [v[2] for v in body.vertices] 190 | 191 | #make a lattice grid 192 | lattice = [] 193 | for i in range(resolution): 194 | if signed: 195 | lattice.append(random.uniform(-1,1)) 196 | else: 197 | lattice.append(random.uniform(0,1)) 198 | 199 | def getNoiseValue(x): 200 | xMin = min(int(x),len(lattice)-2) 201 | t = x-xMin 202 | if smooth: 203 | t = smoothstep(t) 204 | return lerp(lattice[xMin],lattice[xMin+1],t) 205 | 206 | minX = min(xValues) 207 | maxX = max(xValues) 208 | xValuesScaled = [(x- minX)/(maxX-minX) * (resolution-1) for x in xValues] 209 | 210 | allSteps = len(body.vertices) 211 | maxSteps = allSteps - allSteps/20 212 | for i in range(len(xValuesScaled)): 213 | # Update progress value of progress dialog 214 | if progressDialog: 215 | if progressDialog.wasCancelled: 216 | raise ValueError('CanceledProgress') 217 | if i%(int(allSteps/20)+1)==0: 218 | progressDialog.progressValue = i+1 219 | elif i > maxSteps: 220 | progressDialog.progressValue = progressDialog.maximumValue 221 | 222 | #n = (xValuesScaled[i]/len(body.vertices)) * resolution 223 | body.vertices[i][2] += getNoiseValue(xValuesScaled[i]*frequency)*amplitude 224 | 225 | 226 | 227 | return body -------------------------------------------------------------------------------- /noises/worleyNoise.py: -------------------------------------------------------------------------------- 1 | import random, math, time 2 | from ..helpers.meshHelper import Body 3 | from ..helpers.mathHelper import * 4 | from adsk.core import ProgressDialog, Vector2D, Vector3D 5 | import adsk.core 6 | 7 | 8 | def worleyNoise3D(body:Body, resolution:int, amplitude:float, step:bool, stepPadding:float, seed:int=None, progressDialog:ProgressDialog=None) -> Body: 9 | start = time.time() 10 | 11 | if seed: 12 | random.seed(seed) 13 | xValues = [v[0] for v in body.vertices] 14 | yValues = [v[1] for v in body.vertices] 15 | zValues = [v[2] for v in body.vertices] 16 | 17 | minX = min(xValues) 18 | maxX = max(xValues) 19 | minY = min(yValues) 20 | maxY = max(yValues) 21 | minZ = min(zValues) 22 | maxZ = max(zValues) 23 | 24 | #Generate random points in space 25 | #features = [] 26 | features = random.choices(body.vertices,k=resolution) 27 | for i in range(len(features)): 28 | # This Block chooses random points on the bodies surface. Cool. 29 | features[i] = Vector3D.create(features[i][0],features[i][1],features[i][2]) 30 | 31 | def distance3D(a,b): 32 | return math.sqrt((a.x-b.x)**2 + (a.y-b.y)**2 + (a.z-b.z)**2) 33 | 34 | #print(time.time()-start) 35 | allSteps = len(body.vertices) 36 | maxSteps = allSteps - allSteps/20 37 | for i in range(len(body.vertices)): 38 | 39 | # Update progress value of progress dialog 40 | if progressDialog: 41 | if progressDialog.wasCancelled: 42 | raise ValueError('CanceledProgress') 43 | if i%(int(allSteps/20)+1)==0: 44 | progressDialog.progressValue = i+1 45 | elif i > maxSteps: 46 | progressDialog.progressValue = progressDialog.maximumValue 47 | 48 | v = body.vertices[i] 49 | n = body.normals[i] 50 | vec = Vector3D.create(v[0],v[1],v[2]) 51 | normal = Vector3D.create(n[0],n[1],n[2]) 52 | normal.normalize() 53 | 54 | # Another option is to specify the nth closest not the closest 55 | # This is obviously extremly slow 56 | #Experimental: 57 | if step: 58 | closest = [distance3D(vec,x) for x in sorted(features,key=lambda x:distance3D(x,vec))[:2]] 59 | if abs(closest[0]-closest[1]) < stepPadding: 60 | dist = 0 61 | #elif abs(closest[0]-closest[1]) < 0.2: 62 | # dist = 0.5 63 | else: 64 | dist = 1 65 | else: 66 | dist = min([distance3D(vec,f) for f in features]) 67 | 68 | noise = dist*amplitude 69 | normal.scaleBy(noise) 70 | vec.add(normal) 71 | body.vertices[i] = vec.asArray() 72 | #print(time.time()-start) 73 | return body 74 | 75 | 76 | def worleyNoise2D(body:Body, resolution:int, amplitude:float, step:bool, stepPadding:float, seed:int=None, progressDialog:ProgressDialog=None) -> Body: 77 | if seed: 78 | random.seed(seed) 79 | xValues = [v[0] for v in body.vertices] 80 | yValues = [v[1] for v in body.vertices] 81 | #zValues = [v[2] for v in body.vertices] 82 | 83 | minX = min(xValues) 84 | maxX = max(xValues) 85 | minY = min(yValues) 86 | maxY = max(yValues) 87 | 88 | #Generate random points in space 89 | features = random.choices(body.vertices,k=resolution) 90 | for i in range(len(features)): 91 | # This Block chooses random points on the bodies surface. Cool. 92 | features[i] = Vector2D.create(features[i][0],features[i][1]) 93 | 94 | def distance2D(a,b): 95 | return math.sqrt((a.x-b.x)**2 + (a.y-b.y)**2) 96 | 97 | allSteps = len(body.vertices) 98 | maxSteps = allSteps - allSteps/20 99 | for i in range(len(body.vertices)): 100 | b = body.vertices[i] 101 | n = body.normals[i] 102 | vec = Vector3D.create(b[0],b[1],b[2]) 103 | normal = Vector3D.create(n[0],n[1],n[2]) 104 | normal.normalize() 105 | 106 | # Update progress value of progress dialog 107 | if progressDialog: 108 | if progressDialog.wasCancelled: 109 | raise ValueError('CanceledProgress') 110 | if i%(int(allSteps/20)+1)==0: 111 | progressDialog.progressValue = i+1 112 | elif i > maxSteps: 113 | progressDialog.progressValue = progressDialog.maximumValue 114 | 115 | ### 116 | if step: 117 | closest = [distance2D(vec,x) for x in sorted(features,key=lambda x:distance2D(x,vec))[:2]] 118 | if abs(closest[0]-closest[1]) < stepPadding: 119 | dist = 0 120 | else: 121 | dist = 1 122 | else: 123 | dist = min([distance2D(vec,f) for f in features]) 124 | 125 | normal.scaleBy(dist*amplitude) 126 | vec.add(normal) 127 | ### 128 | body.vertices[i] = vec.asArray() 129 | 130 | return body 131 | 132 | -------------------------------------------------------------------------------- /resources/Body1.mtl: -------------------------------------------------------------------------------- 1 | # WaveFront *.mtl file (generated by Autodesk ATF) 2 | 3 | newmtl Paint_-_Enamel_Glossy_(Green) 4 | Kd 0.266667 0.588235 0.282353 5 | 6 | -------------------------------------------------------------------------------- /resources/button/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/button/.DS_Store -------------------------------------------------------------------------------- /resources/button/16x16-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/button/16x16-disabled.png -------------------------------------------------------------------------------- /resources/button/16x16-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/button/16x16-normal.png -------------------------------------------------------------------------------- /resources/button/32x32-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/button/32x32-normal.png -------------------------------------------------------------------------------- /resources/button/64x64-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/button/64x64-normal.png -------------------------------------------------------------------------------- /resources/button/toolClip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/button/toolClip.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_001.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_002.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_003.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_004.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_005.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_006.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_007.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_008.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_008.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_009.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_010.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_011.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_011.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_012.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_012.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_013.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_013.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_014.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/GrungeMap_015.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/GrungeMap_015.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/australia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/australia.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/heightmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/heightmap.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/ireland.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/ireland.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/liquid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/liquid.png -------------------------------------------------------------------------------- /resources/exampleGrungeMaps/mountain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/exampleGrungeMaps/mountain.png -------------------------------------------------------------------------------- /resources/fileDialogButton/16x16-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/fileDialogButton/16x16-disabled.png -------------------------------------------------------------------------------- /resources/fileDialogButton/16x16-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/fileDialogButton/16x16-normal.png -------------------------------------------------------------------------------- /resources/fileDialogButton/32x32-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/fileDialogButton/32x32-disabled.png -------------------------------------------------------------------------------- /resources/fileDialogButton/32x32-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/fileDialogButton/32x32-normal.png -------------------------------------------------------------------------------- /resources/fileDialogButton/64x64-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/fileDialogButton/64x64-normal.png -------------------------------------------------------------------------------- /resources/newButton/16x16-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/newButton/16x16-normal.png -------------------------------------------------------------------------------- /resources/newButton/32x32-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/newButton/32x32-normal.png -------------------------------------------------------------------------------- /resources/newButton/64x64-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/newButton/64x64-normal.png -------------------------------------------------------------------------------- /resources/newButton/old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/newButton/old.png -------------------------------------------------------------------------------- /resources/planeButtons/xY/16x16-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xY/16x16-disabled.png -------------------------------------------------------------------------------- /resources/planeButtons/xY/16x16-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xY/16x16-normal.png -------------------------------------------------------------------------------- /resources/planeButtons/xY/32x32-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xY/32x32-disabled.png -------------------------------------------------------------------------------- /resources/planeButtons/xY/32x32-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xY/32x32-normal.png -------------------------------------------------------------------------------- /resources/planeButtons/xY/64x64-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xY/64x64-normal.png -------------------------------------------------------------------------------- /resources/planeButtons/xZ/16x16-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xZ/16x16-disabled.png -------------------------------------------------------------------------------- /resources/planeButtons/xZ/16x16-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xZ/16x16-normal.png -------------------------------------------------------------------------------- /resources/planeButtons/xZ/32x32-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xZ/32x32-disabled.png -------------------------------------------------------------------------------- /resources/planeButtons/xZ/32x32-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xZ/32x32-normal.png -------------------------------------------------------------------------------- /resources/planeButtons/xZ/64x64-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/xZ/64x64-normal.png -------------------------------------------------------------------------------- /resources/planeButtons/yZ/16x16-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/yZ/16x16-disabled.png -------------------------------------------------------------------------------- /resources/planeButtons/yZ/16x16-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/yZ/16x16-normal.png -------------------------------------------------------------------------------- /resources/planeButtons/yZ/32x32-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/yZ/32x32-disabled.png -------------------------------------------------------------------------------- /resources/planeButtons/yZ/32x32-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/yZ/32x32-normal.png -------------------------------------------------------------------------------- /resources/planeButtons/yZ/64x64-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/planeButtons/yZ/64x64-normal.png -------------------------------------------------------------------------------- /resources/readme/australiaScreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/australiaScreen.png -------------------------------------------------------------------------------- /resources/readme/heads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/heads.png -------------------------------------------------------------------------------- /resources/readme/newheads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/newheads.png -------------------------------------------------------------------------------- /resources/readme/paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/paint.png -------------------------------------------------------------------------------- /resources/readme/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/preview.png -------------------------------------------------------------------------------- /resources/readme/sphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/sphere.png -------------------------------------------------------------------------------- /resources/readme/sphereNoise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/sphereNoise.png -------------------------------------------------------------------------------- /resources/readme/sphereRender.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/sphereRender.PNG -------------------------------------------------------------------------------- /resources/readme/usage.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/usage.gif -------------------------------------------------------------------------------- /resources/readme/valueNoisePlane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/valueNoisePlane.png -------------------------------------------------------------------------------- /resources/readme/well.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/well.png -------------------------------------------------------------------------------- /resources/readme/working.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmueller27/Fusion360PatternsAndTextures/9a8288643c9d3442d725e1316104b15a51c6f2eb/resources/readme/working.png --------------------------------------------------------------------------------