smeighan Posted April 3, 2012 Share Posted April 3, 2012 Would you like to write your animations? The new effect, user_defined allows you to do this.The audience for this effect will be anyone who has some programming knowledge. You are going to provide a code snippet in the PHP language.When you select user_defined, the Nutcracker will call a routine called user_defined.here is the wrapper for the call$maxFrame=80;for($frame=1;$frame<=$maxFrame;$frame++) for($s=1;$s<=$maxStrand;$s++) for($p=1;$p<=$maxPixel;$p++) $rgb=user_defined($frame,$s,$p,$maxFrame,$maxStrand,$maxPixel,$user1);So your job is to create code that will return a rgb value for every frame, strand and pixel.Lets have some examples:Example #1if($frame%4==0) $rgb=hexdec("#FFFFFF"); // WHITEif($frame%4==1) $rgb=hexdec("#FF0000"); // REDif($frame%4==2) $rgb=hexdec("#00FF00"); // GREENif($frame%4==3) $rgb=hexdec("#0000FF"); // BLUEhexdec(string) converts hexadecimal string into a decimal.array_to_saveusername fuser_target ZZ_ZZeffect_class user_definedeffect_name USER1window_degrees 180start_color #FFFFFFend_color #FFFFFFframe_delay 200sparkles 0param1 1param2 2seq_duration 2php_program if($frame%4==0) $rgb=hexdec("#FFFFFF"); if($frame%4==1) $rgb=hexdec("#FF0000"); if($frame%4==2) $rgb=hexdec("#00FF00"); if($frame%4==3) $rgb=hexdec("#0000FF");submit Submit Form to create your effectOBJECT_NAME user_definedExample #2$rgb=0;if($s%2==0){if($p<=$frame)$rgb=hexdec("FF0000");}else if($s%2==1){if($p>=($maxPixel-$frame))$rgb=hexdec("0000FF");}array_to_saveusername fuser_target ZZ_ZZeffect_class user_definedeffect_name USER2window_degrees 180start_color #FFFFFFend_color #FFFFFFframe_delay 100sparkles 0param1 1param2 2seq_duration 2php_program $rgb=0; if($s%2==0) { if($p<=$frame) $rgb=hexdec("FF0000"); } else if($s%2==1) { if($p>=($maxPixel-$frame)) $rgb=hexdec("0000FF"); }submit Submit Form to create your effectOBJECT_NAME user_definedExample #3$H=$S=$V=0;if($s%2==0){if($p<=$frame) { $H=$p/$maxPixel; $S=$V=1; }}else if($s%2==1){if($p>=($maxPixel-$frame)) { $H=1- ($p/$maxPixel); $S=$V=1; }} $rgb=HSV_TO_RGB ($H, $S, $V); Now we get to using a function that will use HUE, SATURATION and VALUE. H is a value between 0 to 1.0. This varies the hue through the color specturm.$S, saturation, is a 1 if we are fully saturated. S=0 means we have a WHITE. $V is the brightness value. $V=1 full brightness, $V=0 = black.H,S,V is much better for creating animations because of the ease of sliding through the colors. I wrote a function, HSV_TO_RGB to change HSV into an rgb value.array_to_saveusername fuser_target ZZ_ZZeffect_class user_definedeffect_name USER3window_degrees 180start_color #FFFFFFend_color #FFFFFFframe_delay 100sparkles 0param1 1param2 2seq_duration 2php_program $H=$S=$V=0; if($s%2==0) { if($p<=$frame) { $H=$p/$maxPixel; $S=$V=1; } } else if($s%2==1) { if($p>=($maxPixel-$frame)) { $H=1- ($p/$maxPixel); $S=$V=1; } } $rgb=HSV_TO_RGB ($H, $S, $V);submit Submit Form to create your effectOBJECT_NAME user_definedExample #4$s_ratio=$s/$maxStrand; $p_ration=$p/$maxPixel;$H1=sin($s_ratio) * cos($p_ratio);$H = $H1 * $frame;if($H>1) $H=$H- intval($H);$S=$V=1;$rgb=HSV_TO_RGB ($H, $S, $V);We can use math functions (sin, cos .etc). We need to make sure $H is never greater than 1.array_to_saveusername fuser_target ZZ_ZZeffect_class user_definedeffect_name USER4window_degrees 180start_color #FFFFFFend_color #FFFFFFframe_delay 200sparkles 0param1 4param2 2seq_duration 2php_program $s_ratio=$s/$maxStrand; $p_ration=$p/$maxPixel; $H1=sin($s_ratio) * cos($p_ratio); $H = $H1 * $frame; if($H>1) $H=$H- intval($H); $S=$V=1; $rgb=HSV_TO_RGB ($H, $S, $V);submit Submit Form to create your effectOBJECT_NAME user_definedExample #5$s_ratio=$frame*$s/$maxStrand; $p_ration=$frame*$p/$maxPixel;$H1=sin($s_ratio) * sin($s_ratio) + cos($p_ratio)* cos($p_ratio);$H = $H1 * $p/$maxPixel;if($H>1) $H=$H- intval($H);$S=$V=1;$rgb=HSV_TO_RGB ($H, $S, $V);array_to_saveusername fuser_target ZZ_ZZeffect_class user_definedeffect_name USER5window_degrees 180start_color #FFFFFFend_color #FFFFFFframe_delay 200sparkles 0param1 4param2 2seq_duration 2php_program $s_ratio=$frame*$s/$maxStrand; $p_ration=$frame*$p/$maxPixel; $H1=sin($s_ratio) * sin($s_ratio) + cos($p_ratio)* cos($p_ratio); $H = $H1 * $p/$maxPixel; if($H>1) $H=$H- intval($H); $S=$V=1; $rgb=HSV_TO_RGB ($H, $S, $V);submit Submit Form to create your effectOBJECT_NAME user_definedExample #6$rgb=hexdec("#FFFFFF");$H=$S=$V=0;$p_half = $maxPixel/2; // find half way point going down tree$p2=$p*2; // double speed of pixel movementif($p2<$p_half) $p_working = $p2;else $p_working = ($p*2-$p_half);if($s%2==1){ $H=$p_working/$maxPixel; $H = $H*$frame/$maxFrame; $S=$V=1;}else{ $H=1-$p_working/$maxPixel; $H = $H*$frame/$maxFrame; $S=$V=1;}$rgb=HSV_TO_RGB ($H, $S, $V);return $rgb; array_to_saveusername fuser_target ZZ_ZZeffect_class user_definedeffect_name USER6window_degrees 180start_color #FFFFFFend_color #FFFFFFframe_delay 200sparkles 0param1 4param2 2seq_duration 2php_program $rgb=hexdec("#FFFFFF"); $H=$S=$V=0; $p_half = $maxPixel/2; // find half way point going down tree $p2=$p*2; // double speed of pixel movement if($p2<$p_half) $p_working = $p2; else $p_working = ($p*2-$p_half); if($s%2==1) { $H=$p_working/$maxPixel; $H = $H*$frame/$maxFrame; $S=$V=1; } else { $H=1-$p_working/$maxPixel; $H = $H*$frame/$maxFrame; $S=$V=1; } $rgb=HSV_TO_RGB ($H, $S, $V); return $rgb;submit Submit Form to create your effectOBJECT_NAME user_definedExample #7# function user_defined($frame,$s,$p,$maxFrame,$maxStrand,$maxPixel,$param1,$param2,$start_color,$end_color)$rgb=hexdec("#FFFFFF");$H=$S=$V=1;$slice=$param1; // use first parameter passed in from user$slice_size=$maxPixel/$slice;$H0 = (($frame% $slice) * $slice_size);$H=($p+$H0)/$maxPixel;if($H>1) $H = $H-intval($H);$rgb=HSV_TO_RGB ($H, $S, $V);//echo "f,s,p=$frame,$s,$p. slice_size=$slice_size. H0=$H0, H=$H";//echo " maxP=$maxPixel. H,S,V=$H,$S,$V, rgb=$rgb";return $rgb; Here you see we are using the passed in parameter from the user form, $param1. You have 4 variables you can use:$param1, $param2, $start_color, $end_color.Also, see how to debug your code by outputting a echo "stuff to seen"; These debug statements are currently commented out.array_to_saveusername fuser_target ZZ_ZZeffect_class user_definedeffect_name USER7window_degrees 180start_color #FFFFFFend_color #FFFFFFframe_delay 200sparkles 0param1 3param2 2seq_duration 2php_program 1) $H = $H-intval($H); $rgb=HSV_TO_RGB ($H, $S, $V); //echo "f,s,p=$frame,$s,$p. slice_size=$slice_size. H0=$H0, H=$H"; //echo " maxP=$maxPixel. H,S,V=$H,$S,$V, rgb=$rgb"; return $rgb; ># function user_defined($frame,$s,$p,$maxFrame,$maxStrand,$maxPixel,$param1,$param2,$start_color,$end_color) $rgb=hexdec("#FFFFFF"); $H=$S=$V=1; $slice=$param1; // use first parameter passed in from user $slice_size=$maxPixel/$slice; $H0 = (($frame% $slice) * $slice_size); $H=($p+$H0)/$maxPixel; if($H>1) $H = $H-intval($H); $rgb=HSV_TO_RGB ($H, $S, $V); //echo "f,s,p=$frame,$s,$p. slice_size=$slice_size. H0=$H0, H=$H"; //echo " maxP=$maxPixel. H,S,V=$H,$S,$V, rgb=$rgb"; return $rgb;submit Submit Form to create your effectOBJECT_NAME user_definedWell, have fun creating your own animation effects. If you find a cool one, please post it. I will add it into the effects library.thankssean Link to comment Share on other sites More sharing options...
jimswinder Posted April 3, 2012 Share Posted April 3, 2012 you programmers blow me away!!!!Darn it...should have listened to those guys would said computers were the next big thing!!!But NOOOOOOOO...I took accounting!!!To this day I have NEVER held a job where I used my accounting degree... :shock: Link to comment Share on other sites More sharing options...
smeighan Posted April 3, 2012 Author Share Posted April 3, 2012 jimswinder wrote:you programmers blow me away!!!!Darn it...should have listened to those guys would said computers were the next big thing!!!But NOOOOOOOO...I took accounting!!!To this day I have NEVER held a job where I used my accounting degree... :shock:Hi Jim;Here is another simple one , just for you.This program:$H = rand(1,100)/100;$S=rand(1,100)/100;$V=rand(1,100)/100;if($p%5==0) { $H=$p/$maxPixel; $S=$V=1; }$rgb=HSV_TO_RGB ($H, $S, $V);makes this tree: Link to comment Share on other sites More sharing options...
jimswinder Posted April 3, 2012 Share Posted April 3, 2012 smeighan wrote: jimswinder wrote:you programmers blow me away!!!!Darn it...should have listened to those guys would said computers were the next big thing!!!But NOOOOOOOO...I took accounting!!!To this day I have NEVER held a job where I used my accounting degree... :shock:Hi Jim;Here is another simple one , just for you.This program:$H = rand(1,100)/100;$S=rand(1,100)/100;$V=rand(1,100)/100;if($p%5==0) { $H=$p/$maxPixel; $S=$V=1; }$rgb=HSV_TO_RGB ($H, $S, $V);lol...Yeah...REALLY simple!!I do recognize the $ sign and the numbers 1 and 100!!! Link to comment Share on other sites More sharing options...
jimswinder Posted April 4, 2012 Share Posted April 4, 2012 Jeff Millard wrote: jimswinder wrote: smeighan wrote: This program:$H = rand(1,100)/100;$S=rand(1,100)/100;$V=rand(1,100)/100;if($p%5==0) { $H=$p/$maxPixel; $S=$V=1; }$rgb=HSV_TO_RGB ($H, $S, $V);lol...Yeah...REALLY simple!!I do recognize the $ sign and the numbers 1 and 100!!! Ooh ooh! I recognize a percent sign! Does that make Jim and I honorary programmers???no...Honorary Accountants... Link to comment Share on other sites More sharing options...
Champion Sound Entertainment Posted April 4, 2012 Share Posted April 4, 2012 What kind of lights do you need to create trees like these? Link to comment Share on other sites More sharing options...
Guest wbottomley Posted April 5, 2012 Share Posted April 5, 2012 Champion Sound Entertainment wrote:What kind of lights do you need to create trees like these?LED's. Link to comment Share on other sites More sharing options...
TGabriel Posted April 5, 2012 Share Posted April 5, 2012 And lots and lots of them. $$$$$$$$$$$$$$$ Link to comment Share on other sites More sharing options...
jimswinder Posted April 5, 2012 Share Posted April 5, 2012 Champion Sound Entertainment wrote: What kind of lights do you need to create trees like these?I use some RGB seeds...best time to plant them is on Earth Day...April 22nd... Link to comment Share on other sites More sharing options...
Guest wbottomley Posted April 5, 2012 Share Posted April 5, 2012 jimswinder wrote:Champion Sound Entertainment wrote: What kind of lights do you need to create trees like these?I use some RGB seeds...best time to plant them is on Earth Day...April 22nd...+1 For Jim today. Link to comment Share on other sites More sharing options...
Guest guest Posted April 5, 2012 Share Posted April 5, 2012 jimswinder wrote: Champion Sound Entertainment wrote: What kind of lights do you need to create trees like these?I use some RGB seeds...best time to plant them is on Earth Day...April 22nd...But consider the source. This may only get you horizontal rgb trees. Link to comment Share on other sites More sharing options...
ItsMeBobO Posted April 5, 2012 Share Posted April 5, 2012 Jim gets ongoing credit for inventing the RGB vine prop. Link to comment Share on other sites More sharing options...
smeighan Posted April 5, 2012 Author Share Posted April 5, 2012 Champion Sound Entertainment wrote:What kind of lights do you need to create trees like these?You need strings that have each RGB pixel addressable.The LOR CCR would be one choice.I am going to be using thesehttp://www.diylightanimation.com/wiki/index.php?title=Equipment#Smart_StringsI will be building 8 strings of 100 pixels each. Here is where i will buy the 100 pixel stringhttp://www.aliexpress.com/fm-store/701799/209889132-495658159/100-node-LED-pixel-string-DC12V-input-new-model-IP68.htmlThere is also the ELOR controller from http://www.sandevices.com/ that allows you to connect things together.There are probably more choices for LOR. Others smarter than me could answer this.thanks Link to comment Share on other sites More sharing options...
Recommended Posts