Utility Function: ImageBlurMore()
- March 26, 2010 8:46 AM
- ColdFusion
- Comments (0)
OK, so up until now you probably can guess that the functionality I'm working on has something to do with drawing or moving a shape since I've posted math rounding functions and functions dealing with geometric positioning. Lets throw you a curve-ball: I also need the following function. What happens when ImageBlur(image, 10) just isn't enough? Well you're going to need to blur the image more!
<cfargument name="Image" type="any" required="true" />
<cfargument name="Blur" type="numeric" required="false" default="11" />
<cfset var local = StructNew() />
<!--- Set blur tracker --->
<cfset local.blur = arguments.Blur />
<!--- Loop until all of the blur has been assigned --->
<cfloop condition="local.blur gt 0">
<!--- If the blur value is too small, end the function --->
<cfif local.blur lt 3>
<cfbreak />
<!--- If the blur is large enough, use the maximum blur --->
<cfelseif local.blur gte 13>
<cfset local.blurStep = 10 />
<!--- If the blur is within normal ImageBlur(), us it --->
<cfelseif local.blur lte 10>
<cfset local.blurStep = local.blur />
<!--- Otherwise, set the blur such that a valid blur amount isleft --->
<cfelse>
<cfset local.blurStep = local.blur - 3 />
</cfif>
<!--- Apply the blur --->
<cfset ImageBlur(arguments.Image, local.blurStep) />
<!--- Update the blur tracker --->
<cfset local.blur = local.blur - local.blurStep />
</cfloop>
<cfreturn />
</cffunction>
This function handles breaking up a blur value of more than a single increment of 10, so that you don't need to call blur multiple times yourself.