Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Sprite generator that takes a root directory and recursively combines all images into a sprite and style sheet.
Sprite generator that takes a root directory and recursively combines all images into a sprite and style sheet.
Spritegen requires a fork of node-canvas, which requires Cairo. To install Cairo follow the portion of the Wiki that pertains to your operating system. Only follow the installing Cairo section, I'll walk you through the rest. Once Cairo is installed follow these steps:
npm install spritegen
If you're noticing that we are requiring a module called canvas-gyp instead of canvas, it's because node-canvas includes both waf and gyp. It is buggy and in our experience, always fails to compile on Windows machines. We created a fork called canvas-gyp that only uses gyp, which installs correctly on Windows.
$ spritegen --dir site/images
Recursively combines all images inside the directory "site/images" into one sprite.png and sprite.css per directory and sub-directory.
site/
images/
icons/
answer.png
connect.png
discover.png
The sprite.css is generated with classes by folder and file name.
.icons-answer-png {
background-image: url("sprite.png");
background-repeat: no-repeat;
background-position: 0px 2px;
width: 22px;
height: 22px;
}
.icons-connect-png {
background-image: url("sprite.png");
background-repeat: no-repeat;
background-position: 0px 26px;
width: 26px;
height: 22px;
}
.icons-discover-png {
background-image: url("sprite.png");
background-repeat: no-repeat;
background-position: 0px 50px;
width: 28px;
height: 22px;
}
This CSS works by simply assigning the class name to an element.
<!DOCTYPE html>
<html>
<head>
<title>spritegen example</title>
<link rel="stylesheet" href="images/icons/sprite.css"/>
</head>
<body>
<p>
<span class="icons-answer-png"></span>
<span class="icons-connect-png"></span>
<span class="icons-discover-png"></span>
</p>
</body>
</html>
spritegen can also be called directly by including the module.
var SpriteGen = require('spritegen');
var imagesPath = path.join(__dir, 'public/images');
var spriteGen = new SpriteGen({ dir: imagesPath, padding: 5 });
spriteGen.execute();
$ spritegen --help
=> [spritegen]
Sprite generator that takes a root directory and recursively combines all images into a sprite and style sheet.
* Version: 0.0.1
* Usage: spritegen [options]
Options:
--help Shows help.
--dir Root directory to recursively process.
--padding Padding between images in pixels.
--verbose Sets if logging is verbose (true/false).
FAQs
Sprite generator that takes a root directory and recursively combines all images into a sprite and style sheet.
The npm package spritegen receives a total of 0 weekly downloads. As such, spritegen popularity was classified as not popular.
We found that spritegen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.