react-image-fuzzy
Advanced tools
Comparing version 0.1.4 to 0.1.6
@@ -29,5 +29,5 @@ import React, { Component } from "react"; | ||
*/ | ||
};const Filter = function (filter, options) { | ||
};const Filter = function (filter, parameter) { | ||
this.filter = filter; | ||
this.options = options; | ||
this.parameter = parameter; | ||
}; | ||
@@ -69,5 +69,5 @@ | ||
this.loadImage(nextProps.url); | ||
} else if (nextProps.filter != this.props.filter || nextProps.options != this.props.options) { | ||
} else if (nextProps.filter != this.props.filter || nextProps.parameter != this.props.parameter) { | ||
this.setImageDataFromOriginalImage(); | ||
this.processImage(nextProps.filter, nextProps.options, nextProps.useImg); | ||
this.processImage(nextProps.filter, nextProps.parameter, nextProps.useImg); | ||
} | ||
@@ -97,3 +97,3 @@ } | ||
this.processImage(this.props.filter, this.props.options, this.props.useImg); | ||
this.processImage(this.props.filter, this.props.parameter, this.props.useImg); | ||
} | ||
@@ -112,6 +112,6 @@ | ||
* @param {array} filter The string filter or array of filters to apply | ||
* @param {string} options Any provided options (number or string) | ||
* @param {string} parameter Any provided parameter (number or string) | ||
* @param {boolean} useImg Flag indicating if an img element is being used | ||
*/ | ||
processImage(filter, options, useImg) { | ||
processImage(filter, parameter, useImg) { | ||
if (!filter) return; | ||
@@ -122,6 +122,6 @@ | ||
if (typeof filter === 'string') { | ||
this.applyFilter(filter, options); | ||
this.applyFilter(filter, parameter); | ||
} else if (filter instanceof Array) { | ||
for (var i = 0; i < filter.length; i++) { | ||
this.applyFilter(filter[i].filter, filter[i].options); | ||
this.applyFilter(filter[i].filter, filter[i].parameter); | ||
} | ||
@@ -142,12 +142,12 @@ } else { | ||
* @param {string} filter The filter to apply | ||
* @param {string} options Filter options (string or number) | ||
* @param {string} parameter Filter parameter (string or number) | ||
*/ | ||
applyFilter(filter, options) { | ||
console.log('Applying', filter, options); | ||
applyFilter(filter, parameter) { | ||
console.log('Applying', filter, parameter); | ||
switch (filter) { | ||
case Filters.Color: | ||
FuzzyLogic.colorFilter(this.imageData, options); | ||
FuzzyLogic.colorFilter(this.imageData, parameter); | ||
break; | ||
case Filters.Invert: | ||
FuzzyLogic.invert(this.imageData, options); | ||
FuzzyLogic.invert(this.imageData, parameter); | ||
break; | ||
@@ -158,15 +158,15 @@ case Filters.Greyscale: | ||
case Filters.Pixelate: | ||
FuzzyLogic.pixelate(this.imageData, options, this.originalImage.width, this.originalImage.height); | ||
FuzzyLogic.pixelate(this.imageData, parameter, this.originalImage.width, this.originalImage.height); | ||
break; | ||
case Filters.BoxBlur: | ||
FuzzyLogic.boxBlur(this.imageData, options); | ||
FuzzyLogic.boxBlur(this.imageData, parameter); | ||
break; | ||
case Filters.HorizontalBlur: | ||
FuzzyLogic.horizontalBlur(this.imageData, options); | ||
FuzzyLogic.horizontalBlur(this.imageData, parameter); | ||
break; | ||
case Filters.VerticalBlur: | ||
FuzzyLogic.verticalBlur(this.imageData, options); | ||
FuzzyLogic.verticalBlur(this.imageData, parameter); | ||
break; | ||
case Filters.GuassianBlur: | ||
FuzzyLogic.gaussianBlur(this.imageData, options); | ||
FuzzyLogic.gaussianBlur(this.imageData, parameter); | ||
break; | ||
@@ -180,3 +180,3 @@ case Filters.Emboss: | ||
case Filters.Luminosity: | ||
FuzzyLogic.luminosity(this.imageData, options); | ||
FuzzyLogic.luminosity(this.imageData, parameter); | ||
break; | ||
@@ -187,3 +187,3 @@ case Filters.Edge: | ||
case Filters.Convolution: | ||
FuzzyLogic.convolution(this.imageData, options); | ||
FuzzyLogic.convolution(this.imageData, parameter); | ||
break; | ||
@@ -212,3 +212,3 @@ } | ||
filter: PropTypes.oneOfType([PropTypes.string.isRequired, PropTypes.array.isRequired]), | ||
options: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]), | ||
parameter: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]), | ||
useImg: PropTypes.bool, | ||
@@ -215,0 +215,0 @@ className: PropTypes.string |
{ | ||
"name": "react-image-fuzzy", | ||
"version": "0.1.4", | ||
"version": "0.1.6", | ||
"description": "A simple ReactJS component for client-side image processing", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -17,3 +17,3 @@ A simple React component for image filter/processing | ||
## Examples | ||
Using React Fuzzy is simple. Once imported, just use the <Fuzzy /> component, providing the image, the filters, and any necessary options: | ||
Using React Fuzzy is simple. Once imported, just use the <Fuzzy /> component, providing the image, the filters, and any necessary parameters: | ||
@@ -27,3 +27,3 @@ ```jsx | ||
filter={'colorFilter'} | ||
option={'red'} /> | ||
parameter={'red'} /> | ||
</div> | ||
@@ -33,3 +33,3 @@ } | ||
A single filter and option can be provided via `filter` and `option` property but an array of filter objects can also be passed to the `filter` property. When passing an array of filters, a filter object is required that contains information on the filter and options: | ||
A single filter and parameter can be provided via `filter` and `parameter` property but an array of filter objects can also be passed to the `filter` property. When passing an array of filters, a filter object is required that contains information on the filter and parameters: | ||
@@ -39,3 +39,3 @@ ``` | ||
filter: 'colorFilter', | ||
option: 'red' | ||
parameter: 'red' | ||
}]; | ||
@@ -50,7 +50,7 @@ ``` | ||
filter: 'colorFilter', | ||
option: 'red' | ||
parameter: 'red' | ||
}, | ||
{ | ||
filter: 'boxBlur', | ||
option: 5 | ||
parameter: 5 | ||
} | ||
@@ -57,0 +57,0 @@ ]; |
27966