├── .gitattributes ├── favicon.png ├── examples ├── example1.png ├── example2.png ├── example3.png └── example4.png ├── README.md ├── LICENSE ├── ZzSprite.js └── index.html /.gitattributes: -------------------------------------------------------------------------------- 1 | *.html linguist-language=Javascript 2 | -------------------------------------------------------------------------------- /favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KilledByAPixel/ZzSprite/HEAD/favicon.png -------------------------------------------------------------------------------- /examples/example1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KilledByAPixel/ZzSprite/HEAD/examples/example1.png -------------------------------------------------------------------------------- /examples/example2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KilledByAPixel/ZzSprite/HEAD/examples/example2.png -------------------------------------------------------------------------------- /examples/example3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KilledByAPixel/ZzSprite/HEAD/examples/example3.png -------------------------------------------------------------------------------- /examples/example4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KilledByAPixel/ZzSprite/HEAD/examples/example4.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZzSprite 2 | 3 | A Tiny Sprite Generator by Frank Force 4 | 5 | [Based on a Dweet](https://www.dwitter.net/d/3078) by Firey Fly 6 | 7 | # [Live Demo](https://killedbyapixel.github.io/ZzSprite/) 8 | 9 | ## Features 10 | 11 | - Generates a wide variety of symetric pixel art sprites 12 | - Click on a sprite to set that as the current seed 13 | - Sprite can be mutated in shape or color 14 | - Sprite sheets can be saved as pngs 15 | - Sprites can be coppied to the clipboard for easy pasting 16 | - Supports 4 color and monochrome color modes 17 | - ZzSprite function can be used to generate sprites at run time 18 | 19 | ## Example sprites... 20 | ![Example Image 1](/examples/example1.png) 21 | 22 | ## Example mutations... 23 | ![Example Image 2](/examples/example2.png) 24 | 25 | ## Example animations... 26 | ![Example Image 3](/examples/example3.png) 27 | 28 | ## So many possibilities! 29 | ![Example Image 4](/examples/example4.png) 30 | 31 | ![Favicon](/favicon.png) 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Frank Force 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ZzSprite.js: -------------------------------------------------------------------------------- 1 | // ZzSprite - Tiny Sprite Generator - Frank Force 2020 - MIT License 2 | 3 | 'use strict'; 4 | 5 | // ==ClosureCompiler== 6 | // @compilation_level ADVANCED_OPTIMIZATIONS 7 | // @language_out ECMASCRIPT_2019 8 | // @js_externs ZzSprite 9 | // ==/ClosureCompiler== 10 | 11 | function ZzSprite(context, x=0, y=0, seed=1, size=16, mode=0, mutateSeed=0, colorSeed=0) 12 | { 13 | function Random(max=1, min=0) 14 | { 15 | randomSeed ^= randomSeed << 13; 16 | randomSeed ^= randomSeed >>> 17; 17 | return (Math.abs(randomSeed ^= randomSeed << 5) % 1e9 / 1e9)*(max-min) + min; 18 | } 19 | 20 | // random chance to flip drawing axis 21 | let randomSeed = seed; 22 | const flipAxis = Random() < .5; 23 | const w = flipAxis ? size-3 : size/2 - 1 |0; 24 | const h = !flipAxis ? size-3 : size/2 - 1 |0; 25 | 26 | // apply mutations 27 | randomSeed += mutateSeed + 1e8; 28 | const spriteSize = size * Random(.9, .6); 29 | const density = Random(1, .9); 30 | const doubleCenter = Random() < .5; 31 | const yBias = Random(.1, -.1); 32 | const colorRand = (mode==1 ? .08 : .04); 33 | 34 | // recenter 35 | x += size/2 | 0; 36 | y += 2 | 0; 37 | 38 | function DrawSpriteInternal(x, y, outline) 39 | { 40 | // draw each pixel 41 | randomSeed = seed; 42 | const passCount = mode == 3 ? 3: 1 43 | for(let pass=0; pass < passCount; ++pass) 44 | for(let k=0; k < w*h; ++k) 45 | { 46 | const i = flipAxis ? k/w|0 : k%w; 47 | const j = !flipAxis ? k/w|0 : k%w; 48 | 49 | // pick new random color using color seed 50 | const saveSeed = randomSeed; 51 | randomSeed += colorSeed + 1e9; 52 | const r = Random(360)|0; 53 | let newColor = `hsl(${ r },${ Random(200,0)|0 }%,${ Random(100,20)|0 }%)`; 54 | if (outline || mode == 3) 55 | newColor = '#000'; 56 | else if (mode == 1) 57 | newColor = r%3? r%3==1 ? '#444' : '#999' : '#fff'; 58 | else if (mode == 2) 59 | newColor = `#fff`; 60 | if (!k || Random() < colorRand) 61 | context.fillStyle = newColor; 62 | randomSeed = saveSeed; 63 | 64 | // check if pixel should be drawn 65 | const isHole = Random() > density; 66 | if (Random(spriteSize/2)**2 > i*i + (j-(1-2*yBias)*h/2)**2 && !isHole) 67 | { 68 | const o = !!outline; 69 | context.fillRect(x+i-o-doubleCenter, y+j-o, 1+2*o, 1+2*o); 70 | context.fillRect(x-i-o, y+j-o, 1+2*o, 1+2*o); 71 | } 72 | } 73 | } 74 | 75 | // outline then fill 76 | if (mode != 3) 77 | DrawSpriteInternal(x, y, 1); 78 | DrawSpriteInternal(x, y); 79 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 38 | 39 |
40 |
41 | 42 |
43 |
44 | 45 |
46 |
47 | Advanced 48 |
49 |
50 |
51 | 52 |
53 | 54 | 55 | 56 | 57 | 297 | --------------------------------------------------------------------------------