Entries for month: August 2007

ColdFusion 8: Rounded Corners & Reflection


As you may have known, Foundeo has created an Image Effects CFC that can generate image gradients, reflection, drop shadows, and some more cool effects by taking advantage of the new image features in ColdFusion 8.

Some people have been trying to replicate some of the functions this package has, especially the gradients, reflection and rounded corners functions. John Hartmann did an excellent job in replicating the reflect() and gradientMask() functions.

Jeff Coughlin also started building a CFImage Effects Plugin for FarCry based off of John Hartmann's functions. His Plugin has code to replicate the rounded corners.

Now, lets get into the code...

No Comments

Search Thru a Multi-Dimensional Array

I ran into a situation today where I needed to search thru a multi-dimensional array to update quantities and total prices for backordered products coming from a query. Unfortunately ColdFusion doesn't have an ArrayFind() function like it does for structs. I did a search on CFLib and found a UDF that did the trick.

The ArrayFindByDimension() UDF allows you to pass it an array, the value to find, dimension to search and returns the numeric array position if found, 0 if not found.

Here is some of my sample code:

<!---
Search a multidimensional array for a value.

@param arrayToSearch     Array to search. (Required)
@param valueToFind     Value to find. (Required)
@param dimensionToSearch     Dimension to search. (Required)
@return Returns a number.
@author Grant Szabo (grant@quagmire.com)
@version 1, September 23, 2004
--->

<cffunction name="ArrayFindByDimension" access="public" returntype="numeric" output="false">
   <cfargument name="arrayToSearch" type="array" required="Yes">
   <cfargument name="valueToFind" type="string" required="Yes">
   <cfargument name="dimensionToSearch" type="numeric" required="Yes">
   <cfscript>
      var ii = 1;
      
      //loop through the array, looking for the value
      for(; ii LTE arrayLen(arguments.arrayToSearch); ii = ii + 1){
         //if this is the value, return the index
         if(NOT compareNoCase(arguments.arrayToSearch[ii][arguments.dimensionToSearch], arguments.valueToFind))
            return ii;
      }
      //if we've gotten this far, it means the value was not found, so return 0
      return 0;
   </cfscript>
</cffunction>

<!--- begin the count --->
<cfset i = 1>
<!--- create the array --->
<cfset products = ArrayNew(2)>

<cfloop query="backordered">
   <!--- search array --->
   <cfset arrPos = arrayFindByDimension(products, "#backordered.product_code#", 2)>
   <cfif arrPos EQ 0>
      <cfset products[i][1] = backordered.product_id>
      <cfset products[i][2] = backordered.product_code>
      <cfset products[i][3] = backordered.order_details_quanity>
      <cfset products[i][4] = backordered.order_details_price * backordered.order_details_quanity>
      <cfset i = i + 1>
   <cfelse>
      <cfset products[arrPos][3] = products[arrPos][3] + backordered.order_details_quanity>
      <cfset products[arrPos][4] = products[arrPos][4] + (backordered.order_details_price * backordered.order_details_quanity)>
   </cfif>
</cfloop>

<!--- dump the array --->
<cfdump var="#products#">

No Comments

ColdFusion 8: Watermarks, Transparency & Resizing


I wanted to share some code examples that I have come across within the past few weeks regarding the new functionality in ColdFusion 8. My first example will be using the following functions: ImageRead(), ImageSetAntialiasing(), ImageScaleToFit(), ImageSetDrawingTransparency(), ImageGetWidth(), ImageGetHeight(), and finally ImagePaste(). Ok, here we go...

No Comments

Full WEB 2.0 API List

I ran into a site where there is a list of many different types of practical and popular APIs which can be used for your web 2.0 applications. Categories including: Advertising, Blogging, Bookmarks, Calendar, Chat, Email, Photos, etc. You can find alot of good information here:

http://techmagazine.ws/full-web-20-api-list/

No Comments

Adobe MAX Map Embedded

Last month I posted a link to a google map I created with all the hotels, airports and venue mapped onto one map. Google has made it one step easier in sharing their maps. Now you can embed their maps directly into a webpage. Check it out!


View Larger Map

No Comments