(catNum: number, len: number)
| 19 | }); |
| 20 | |
| 21 | async function createCat(catNum: number, len: number) { |
| 22 | const imgHeight = 60; |
| 23 | |
| 24 | const butt = await Jimp.read(__dirname + "/images/cat_butt.png"); |
| 25 | const head = await Jimp.read(__dirname + "/images/cat_head.png"); |
| 26 | const fuzz = await Jimp.read(__dirname + "/images/cat_fuzz.png"); |
| 27 | |
| 28 | let longCat = len; |
| 29 | longCat = longCat > 20 ? 20 : longCat; |
| 30 | longCat = longCat <= 1 ? 1 : longCat; |
| 31 | |
| 32 | const cat = |
| 33 | Math.floor(catNum * (head.bitmap.height / imgHeight)) * imgHeight; |
| 34 | |
| 35 | const newImage = new Jimp({ |
| 36 | width: |
| 37 | butt.bitmap.width + head.bitmap.width + fuzz.bitmap.width * longCat, |
| 38 | height: imgHeight, |
| 39 | color: 0x00000000, |
| 40 | }); |
| 41 | |
| 42 | newImage.blit({ |
| 43 | src: butt, |
| 44 | x: 0, |
| 45 | y: 0, |
| 46 | srcX: 0, |
| 47 | srcY: cat, |
| 48 | srcW: butt.bitmap.width, |
| 49 | srcH: imgHeight, |
| 50 | }); |
| 51 | for (let i = 0; i < longCat; i++) { |
| 52 | newImage.blit({ |
| 53 | src: fuzz, |
| 54 | x: butt.bitmap.width + fuzz.bitmap.width * i, |
| 55 | y: 0, |
| 56 | srcX: 0, |
| 57 | srcY: cat, |
| 58 | srcW: fuzz.bitmap.width, |
| 59 | srcH: imgHeight, |
| 60 | }); |
| 61 | } |
| 62 | |
| 63 | newImage.blit({ |
| 64 | src: head, |
| 65 | x: butt.bitmap.width + fuzz.bitmap.width * longCat, |
| 66 | y: 0, |
| 67 | srcX: 0, |
| 68 | srcY: cat, |
| 69 | srcW: head.bitmap.width, |
| 70 | srcH: imgHeight, |
| 71 | }); |
| 72 | |
| 73 | return newImage; |
| 74 | } |
| 75 | |
| 76 | test("uses src params correctly", async () => { |
| 77 | const small = await createCat(0.3, 1); |
no test coverage detected
searching dependent graphs…