0.0.1 • Published 10 years ago

gulp-9-patch v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

gulp-9-patch

Utilities for android-9-patch images.

https://www.npmjs.org/package/gulp-9-patch

Installation

npm install gulp-9-patch

Usage

trim(dont_rename: boolean = false)

Remove 9-patch marker from image that name ends ".9.***".

var gulp = require('gulp')
var nine = require('gulp-9-patch');

gulp.src('./src/target.9.png') // with 9-patch image
.pipe(nine.trim())
.pipe(gulp.dest('./ios/image/'))
// Result: "target.png" without 9-patch

gulp.src('./src/target.9.png')
.pipe(nine.trim(true))
.pipe(gulp.dest('./ios/image/'))
// Result: "target.9.png" without 9-patch

gulp.src('./src/target.png') // without 9-patch image
.pipe(nine.trim())
.pipe(gulp.dest('./ios/image/'))
// Result: do nothing (output only)

scale(scale: float)

Scale image. If file name ends ".9.***", also scale 9-patch marker.

gulp.task('default', function() {
	gulp.src('./src/target.9.png') // 102 x 52 with 9-patch
	.pipe(nine.trim(0.5))
	.pipe(gulp.dest('./android/app/src/main/res/drawable-xhdpi'))
});
// Result: 52 x 27 image

gulp.task('default', function() {
	gulp.src('./src/target.png') // 100 x 50 without 9-patch
	.pipe(nine.trim(0.5))
	.pipe(gulp.dest('./android/app/src/main/res/drawable-xhdpi'))
});
// Result: 50 x 25 image
0.0.1

10 years ago