pimBE

fastled mapXY coldfusion cfm

Jun 2nd, 2016
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <cfset matrixWidth = 8>
  2. <cfset matrixHeight = 58>
  3. <cfset matrixOrientation = 'rows'>
  4. <cfset matrixOrigin = 'bottomRight'>
  5. <cfset serpentine = true>
  6.  
  7. <cffunction name='mapXY'>
  8. <cfargument name='row' default="">
  9. <cfargument name='col' default="">
  10. <!--- COLUMNS LAYOUT --->
  11. <cfif matrixOrientation eq 'columns'>
  12. <!--- ORIGIN BOTTOM LEFT --->
  13. <cfif matrixOrigin EQ 'bottomLeft'>
  14. <cfif col mod 2 EQ 0 OR serpentine EQ false>
  15. <cfreturn ((col + 1) * matrixHeight) - row - 1>
  16. <cfelse>
  17. <cfreturn ((col) * matrixHeight) + row>
  18. </cfif>
  19. </cfif>
  20. <!--- ORIGIN TOP LEFT --->
  21. <cfif matrixOrigin EQ 'topLeft'>
  22. <cfif col mod 2 EQ 0 OR serpentine EQ false>
  23. <cfreturn (col * matrixHeight) + row>
  24. <cfelse>
  25. <cfreturn ((col + 1) * matrixHeight) - row - 1>
  26. </cfif>
  27. </cfif>
  28. <!--- ORIGIN BOTTOM RIGHT --->
  29. <!--- GOING BACKWARDS --->
  30. <cfif matrixOrigin EQ 'bottomRight'>
  31. <cfset invertCol = matrixWidth - col>
  32. <cfif invertCol mod 2 EQ 1 OR serpentine EQ false>
  33. <cfreturn ((invertCol) * matrixHeight) - row - 1>
  34. <cfelse>
  35. <cfreturn ((invertCol - 1) * matrixHeight) + row>
  36.  
  37. </cfif>
  38. </cfif>
  39. <!--- ORIGIN TOP RIGHT --->
  40. <!--- GOING BACKWARDS --->
  41. <cfif matrixOrigin EQ 'topRight'>
  42. <cfset invertCol = matrixWidth - col>
  43. <cfif invertCol mod 2 EQ 1 OR serpentine EQ false>
  44. <cfreturn ((invertCol - 1) * matrixHeight) + row>
  45. <cfelse>
  46. <cfreturn (invertCol * matrixHeight) - row - 1>
  47.  
  48. </cfif>
  49. </cfif>
  50. <!--- ROWS LAYOUT --->
  51. <cfelseif matrixOrientation eq 'rows'>
  52. <!--- ORIGIN TOP LEFT --->
  53. <cfif matrixOrigin EQ 'topLeft'>
  54. <cfif row mod 2 EQ 0 OR serpentine EQ false>
  55. <cfreturn (row * matrixWidth) + col>
  56. <cfelse>
  57. <cfreturn ((row + 1) * matrixWidth) - col - 1>
  58. </cfif>
  59. </cfif>
  60. <!--- ORIGIN TOP RIGHT --->
  61. <cfif matrixOrigin EQ 'topRight'>
  62. <cfif row mod 2 EQ 0 OR serpentine EQ false>
  63. <cfreturn ((row + 1) * matrixWidth) - col - 1>
  64. <cfelse>
  65. <cfreturn ((row) * matrixWidth) + col>
  66. </cfif>
  67. </cfif>
  68.  
  69. <!--- ORIGIN BOTTOM LEFT --->
  70. <!--- GOING BACKWARDS --->
  71. <cfif matrixOrigin EQ 'bottomLeft'>
  72. <cfset invertRow = matrixHeight - row>
  73. <cfif invertRow mod 2 EQ 1 OR serpentine EQ false>
  74. <cfreturn ((invertRow-1) * matrixWidth) + col>
  75. <cfelse>
  76. <cfreturn ((invertRow) * matrixWidth) - col - 1>
  77. </cfif>
  78. </cfif>
  79.  
  80. <!--- ORIGIN BOTTOM RIGHT --->
  81. <!--- GOING BACKWARDS --->
  82. <cfif matrixOrigin EQ 'bottomRight'>
  83. <cfset invertRow = matrixHeight - row>
  84. <cfif invertRow mod 2 EQ 1 OR serpentine EQ false>
  85. <cfreturn ((invertRow) * matrixWidth) - col - 1>
  86. <cfelse>
  87. <cfreturn ((invertRow - 1) * matrixWidth) + col>
  88.  
  89. </cfif>
  90. </cfif>
  91. </cfif>
  92. </cffunction>
Advertisement
Add Comment
Please, Sign In to add comment