Implement renderInstructions in themer-wallpaper-trianglify

This commit is contained in:
Matt Swensen 2020-03-20 07:09:00 -06:00
parent 926d99a2d2
commit 54b693f1da
No known key found for this signature in database
GPG Key ID: 3F9E482BFC526F35
5 changed files with 30 additions and 3 deletions

@ -42,3 +42,5 @@ to which you would pass `<width>x<height>`. For example, to forego the default r
--themer-wallpaper-trianglify-variance <variance>
Accepts a float between `0` and `1`, defaults to `0.75` (see [trianglify docs](https://github.com/qrohlf/trianglify#variance)). Like `--themer-wallpaper-trianglify-size`, this option can be provided multiple times—`themer` will generate a complete set of wallpapers for each value passed.
The generated files will be listed in `<output dir>/README.md`.

@ -7,3 +7,14 @@ exports[`themer trianglify wallpaper should allow for specifying variances 2`] =
exports[`themer trianglify wallpaper should allow for specifying variances 3`] = `"<svg width=\\"100\\" height=\\"100\\" xmlns=\\"http://www.w3.org/2000/svg\\"><path d=\\"M50,50L-25,-25L-25,50Z\\" fill=\\"#508c77\\" stroke=\\"#508c77\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,50L50,-25L-25,-25Z\\" fill=\\"#4a6868\\" stroke=\\"#4a6868\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,-25L-100,-25L-25,50Z\\" fill=\\"#36715e\\" stroke=\\"#36715e\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,-25L-100,50L-25,50Z\\" fill=\\"#508c77\\" stroke=\\"#508c77\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,-25L-25,-100L-25,-25Z\\" fill=\\"#36715e\\" stroke=\\"#36715e\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,-25L-25,-100L-100,-25Z\\" fill=\\"#36715e\\" stroke=\\"#36715e\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,50L-25,125L-25,50Z\\" fill=\\"#88c5ae\\" stroke=\\"#88c5ae\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,50L-25,125L50,50Z\\" fill=\\"#88c5ae\\" stroke=\\"#88c5ae\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,-25L50,-100L-25,-100Z\\" fill=\\"#4a6868\\" stroke=\\"#4a6868\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,125L50,125L50,50Z\\" fill=\\"#b6d7d6\\" stroke=\\"#b6d7d6\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,50L125,-25L50,50Z\\" fill=\\"#8b60a1\\" stroke=\\"#8b60a1\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,50L125,-25L50,-25Z\\" fill=\\"#65537c\\" stroke=\\"#65537c\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,-25L125,-25L50,-100Z\\" fill=\\"#65537c\\" stroke=\\"#65537c\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,125L125,50L50,50Z\\" fill=\\"#b8a3d0\\" stroke=\\"#b8a3d0\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,-100L-100,-100L-100,-25Z\\" fill=\\"#36715e\\" stroke=\\"#36715e\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,50L-100,125L-25,125Z\\" fill=\\"#a4e2ca\\" stroke=\\"#a4e2ca\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,-25L125,-100L50,-100Z\\" fill=\\"#704686\\" stroke=\\"#704686\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,125L125,125L125,50Z\\" fill=\\"#e3b2f9\\" stroke=\\"#e3b2f9\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,125L50,200L125,125Z\\" fill=\\"#d5bfee\\" stroke=\\"#d5bfee\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,125L-25,200L50,125Z\\" fill=\\"#a4e2ca\\" stroke=\\"#a4e2ca\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,125L-25,200L-25,125Z\\" fill=\\"#a4e2ca\\" stroke=\\"#a4e2ca\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,200L50,200L50,125Z\\" fill=\\"#b6d7d6\\" stroke=\\"#b6d7d6\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,-25L200,-25L125,-100Z\\" fill=\\"#704686\\" stroke=\\"#704686\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,50L200,-25L125,-25Z\\" fill=\\"#704686\\" stroke=\\"#704686\\" stroke-width=\\"1.51\\"></path><path d=\\"M200,50L200,-25L125,50Z\\" fill=\\"#8b60a1\\" stroke=\\"#8b60a1\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,125L200,50L125,50Z\\" fill=\\"#c596db\\" stroke=\\"#c596db\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,125L-100,200L-25,200Z\\" fill=\\"#a4e2ca\\" stroke=\\"#a4e2ca\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,125L200,125L200,50Z\\" fill=\\"#e3b2f9\\" stroke=\\"#e3b2f9\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,200L125,200L125,125Z\\" fill=\\"#e3b2f9\\" stroke=\\"#e3b2f9\\" stroke-width=\\"1.51\\"></path><path d=\\"M200,-25L200,-100L125,-100Z\\" fill=\\"#704686\\" stroke=\\"#704686\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,200L200,125L125,125Z\\" fill=\\"#e3b2f9\\" stroke=\\"#e3b2f9\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,200L200,200L200,125Z\\" fill=\\"#e3b2f9\\" stroke=\\"#e3b2f9\\" stroke-width=\\"1.51\\"></path></svg>"`;
exports[`themer trianglify wallpaper should allow for specifying variances 4`] = `"<svg width=\\"100\\" height=\\"100\\" xmlns=\\"http://www.w3.org/2000/svg\\"><path d=\\"M50,50L-25,-25L-25,50Z\\" fill=\\"#a38548\\" stroke=\\"#a38548\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,50L50,-25L-25,-25Z\\" fill=\\"#886140\\" stroke=\\"#886140\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,-25L-100,-25L-25,50Z\\" fill=\\"#876b2f\\" stroke=\\"#876b2f\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,-25L-100,50L-25,50Z\\" fill=\\"#a38548\\" stroke=\\"#a38548\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,-25L-25,-100L-25,-25Z\\" fill=\\"#876b2f\\" stroke=\\"#876b2f\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,-25L-25,-100L-100,-25Z\\" fill=\\"#876b2f\\" stroke=\\"#876b2f\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,50L-25,125L-25,50Z\\" fill=\\"#dfbd7d\\" stroke=\\"#dfbd7d\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,50L-25,125L50,50Z\\" fill=\\"#dfbd7d\\" stroke=\\"#dfbd7d\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,-25L50,-100L-25,-100Z\\" fill=\\"#886140\\" stroke=\\"#886140\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,125L50,125L50,50Z\\" fill=\\"#ffcfa9\\" stroke=\\"#ffcfa9\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,50L125,-25L50,50Z\\" fill=\\"#a25987\\" stroke=\\"#a25987\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,50L125,-25L50,-25Z\\" fill=\\"#874b5e\\" stroke=\\"#874b5e\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,-25L125,-25L50,-100Z\\" fill=\\"#874b5e\\" stroke=\\"#874b5e\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,125L125,50L50,50Z\\" fill=\\"#df9baf\\" stroke=\\"#df9baf\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,-100L-100,-100L-100,-25Z\\" fill=\\"#876b2f\\" stroke=\\"#876b2f\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,50L-100,125L-25,125Z\\" fill=\\"#feda98\\" stroke=\\"#feda98\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,-25L125,-100L50,-100Z\\" fill=\\"#863f6c\\" stroke=\\"#863f6c\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,125L125,125L125,50Z\\" fill=\\"#fcacdb\\" stroke=\\"#fcacdb\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,125L50,200L125,125Z\\" fill=\\"#fdb8cb\\" stroke=\\"#fdb8cb\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,125L-25,200L50,125Z\\" fill=\\"#feda98\\" stroke=\\"#feda98\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,125L-25,200L-25,125Z\\" fill=\\"#feda98\\" stroke=\\"#feda98\\" stroke-width=\\"1.51\\"></path><path d=\\"M-25,200L50,200L50,125Z\\" fill=\\"#ffcfa9\\" stroke=\\"#ffcfa9\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,-25L200,-25L125,-100Z\\" fill=\\"#863f6c\\" stroke=\\"#863f6c\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,50L200,-25L125,-25Z\\" fill=\\"#863f6c\\" stroke=\\"#863f6c\\" stroke-width=\\"1.51\\"></path><path d=\\"M200,50L200,-25L125,50Z\\" fill=\\"#a25987\\" stroke=\\"#a25987\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,125L200,50L125,50Z\\" fill=\\"#dd8fbe\\" stroke=\\"#dd8fbe\\" stroke-width=\\"1.51\\"></path><path d=\\"M-100,125L-100,200L-25,200Z\\" fill=\\"#feda98\\" stroke=\\"#feda98\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,125L200,125L200,50Z\\" fill=\\"#fcacdb\\" stroke=\\"#fcacdb\\" stroke-width=\\"1.51\\"></path><path d=\\"M50,200L125,200L125,125Z\\" fill=\\"#fcacdb\\" stroke=\\"#fcacdb\\" stroke-width=\\"1.51\\"></path><path d=\\"M200,-25L200,-100L125,-100Z\\" fill=\\"#863f6c\\" stroke=\\"#863f6c\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,200L200,125L125,125Z\\" fill=\\"#fcacdb\\" stroke=\\"#fcacdb\\" stroke-width=\\"1.51\\"></path><path d=\\"M125,200L200,200L200,125Z\\" fill=\\"#fcacdb\\" stroke=\\"#fcacdb\\" stroke-width=\\"1.51\\"></path></svg>"`;
exports[`themer trianglify wallpaper should list outputfiles 1`] = `
"
Files generated:
* \`themer-wallpaper-trianglify-dark-1000x1000-0.5-1.svg\`
* \`themer-wallpaper-trianglify-dark-1000x1000-0.5-2.svg\`
* \`themer-wallpaper-trianglify-light-1000x1000-0.5-1.svg\`
* \`themer-wallpaper-trianglify-light-1000x1000-0.5-2.svg\`
"
`;

@ -1,5 +1,5 @@
const Trianglify = require('trianglify'),
{ deepFlatten } = require('themer-utils'),
{ deepFlatten, listOutputFiles } = require('themer-utils'),
{ getSizes, getVariances } = require('./opts');
const optionNames = {
@ -55,4 +55,5 @@ const render = (colors, options) => {
module.exports = {
render,
renderInstructions: listOutputFiles,
};

@ -1,5 +1,5 @@
const { colors } = require('../../themer-colors-default'),
{ render } = require('./index');
{ render, renderInstructions } = require('./index');
describe('themer trianglify wallpaper', () => {
it('should allow for specifying sizes', async () => {
@ -20,4 +20,17 @@ describe('themer trianglify wallpaper', () => {
expect(file.contents.toString('utf8')).toMatchSnapshot();
});
});
it('should list outputfiles', async () => {
const files = await Promise.all(
render(
colors,
{
'themer-wallpaper-trianglify-size': '1000x1000',
'themer-wallpaper-trianglify-variance': '0.5',
},
)
);
const instructions = renderInstructions(files.map(({ name }) => name));
expect(instructions).toMatchSnapshot();
});
});

@ -21,7 +21,7 @@
"/lib/opts.js"
],
"dependencies": {
"themer-utils": "^1.1.0",
"themer-utils": "^1.2.0",
"trianglify": "^1.2.0"
},
"devDependencies": {},