home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 July / com!online0702.iso / software / livemotion / DATA1.CAB / Include / Create.js < prev    next >
Encoding:
JavaScript  |  2002-05-13  |  10.9 KB  |  464 lines

  1. /***************************************************************
  2. ADOBE SYSTEMS INCORPORATED 
  3. Copyright 2002 Adobe Systems Incorporated 
  4. All Rights Reserved 
  5.  
  6. NOTICE:  Adobe permits you to use, modify, and distribute this 
  7. file in accordance with the terms of the Adobe license agreement 
  8. accompanying it.  If you have received this file from a source 
  9. other than Adobe, then your use, modification, or distribution
  10. of it requires the prior written permission of Adobe. 
  11. ***************************************************************/
  12. /***************************************************************
  13. Author: Ken Villines
  14. ***************************************************************/
  15.  
  16. /***************************************************************
  17.  
  18. This file is an include file used for Automation Scripting.
  19.  
  20. *************Function Definitions****************
  21.  
  22.  
  23. These functions return the object shape stated --
  24.  
  25.  
  26. ellipse(w, h, x, y [r, g, b])
  27.  
  28. w = width , h = height, x = x coordinate,  y = y coordinate,(Optional Args r = red , g = green , b = blue)
  29.  
  30. returns an ellipse  object
  31.  
  32.  
  33. polygon(w, h, x, y, s, [r, g, b])
  34.  
  35. w = width , h = height , x = x coordinate,  y = y coordinate, s = sides (Optional Args r = red , g = green , b = blue)
  36.  
  37. returns a polygon object
  38.  
  39.  
  40. roundedRectangle(w, h, x, y, cr, [r, g, b])
  41.  
  42. w = width , h = height , x = x coordinate,  y = y coordinate, cr = corner radius (Optional Args r = red , g = green , b = blue)
  43.  
  44. returns a rounded rectangle object
  45.  
  46.  
  47. rectangle(w, h, x, y, [r, g, b])
  48.  
  49. w = width , h = height, x = x coordinate,  y = y coordinate,(Optional Args r = red , g = green , b = blue)
  50.  
  51. returns a rectangle object
  52.  
  53.  
  54. path(w, h, x, y,[r, g, b])
  55.  
  56. w = width , h = height, x = x coordinate,  y = y coordinate, (Optional Args r = red , g = green , b = blue)
  57.  
  58. returns a path object
  59.  
  60. ***************************************************************/
  61.  
  62. /***************************************************************
  63. DO NOT EDIT BELOW THIS LINE
  64. ***************************************************************/
  65.  
  66.  
  67.  
  68. function getCC()
  69. {
  70. return application.currentComposition;
  71. }
  72.  
  73.  
  74.  
  75. function ellipse(w, h, x, y, r, g, b)
  76. {
  77.  var Obj = getCC().createObject(LMObjectType.geometric, x, y);
  78.  var newEllipse = Obj.convertType(LMGeometricType.ellipse);
  79.  newEllipse.size.x = w;
  80.  newEllipse.size.y = h;
  81.  
  82.      if(r)
  83.      {
  84.      var maxVal = Math.max(r, 255);  //if argument exists check bounds
  85.     var minVal = Math.min(r, 0);
  86.             
  87.         if(maxVal <= 255 && minVal >= 0){
  88.             newEllipse.layers[0].colorGradient.startColor.red = r;
  89.             }
  90.             else
  91.             {
  92.             Console.write("ERROR: Color values are between 0 and 255\n");
  93.             Console.write("The RED value was not set\n");
  94.             return null;
  95.             }
  96.      }
  97.      else
  98.      {
  99.      newEllipse.layers[0].colorGradient.startColor.red = 0;
  100.      }
  101.  
  102.  
  103.      if(g)
  104.      {
  105.      var maxVal = Math.max(g, 255);  //if argument exists check bounds
  106.     var minVal = Math.min(g, 0);
  107.             
  108.         if(maxVal <= 255 && minVal >= 0){
  109.             newEllipse.layers[0].colorGradient.startColor.green = g;
  110.             }
  111.             else
  112.             {
  113.             Console.write("ERROR: Color values are between 0 and 255\n");
  114.             Console.write("The GREEN value was not set\n");
  115.             return null;
  116.             }
  117.      }
  118.      else
  119.      {
  120.      newEllipse.layers[0].colorGradient.startColor.green = 0;
  121.      }
  122.  
  123.      if(b)
  124.      {
  125.      var maxVal = Math.max(b, 255);  //if argument exists check bounds
  126.     var minVal = Math.min(b, 0);
  127.             
  128.         if(maxVal <= 255 && minVal >= 0){
  129.             newEllipse.layers[0].colorGradient.startColor.blue = b;
  130.             }
  131.             else
  132.             {
  133.             Console.write("ERROR: Color values are between 0 and 255\n");
  134.             Console.write("The BLUE value was not set\n");
  135.             return null;
  136.             }
  137.      }
  138.      else
  139.      {
  140.      newEllipse.layers[0].colorGradient.startColor.blue = 0;
  141.      }
  142.  
  143.      return newEllipse;
  144. }
  145.  
  146.  
  147.  
  148. function polygon(w, h, x, y, s, r, g, b)
  149. {
  150.  var Obj = getCC().createObject(LMObjectType.geometric, x, y);
  151.  var newPolygon = Obj.convertType(LMGeometricType.polygon);
  152.  newPolygon.size.x = w;
  153.  newPolygon.size.y = h;
  154.  
  155.  var sideMaxVal = Math.max(s, 10);  //if argument exists check bounds
  156.  var sideMinVal = Math.min(s, 3);
  157.             
  158.         if(sideMaxVal <= 10 && sideMinVal >= 3){
  159.             newPolygon.sides = s;
  160.             }
  161.             else
  162.             {
  163.             Console.write("ERROR: Number of sides is between 3 and 10\n");
  164.             Console.write("The number of sides were not set\n");
  165.             return null;
  166.             }
  167.  
  168.      if(r)
  169.      {
  170.      var maxVal = Math.max(r, 255);  //if argument exists check bounds
  171.     var minVal = Math.min(r, 0);
  172.             
  173.         if(maxVal <= 255 && minVal >= 0){
  174.             newPolygon.layers[0].colorGradient.startColor.red = r;
  175.             }
  176.             else
  177.             {
  178.             Console.write("ERROR: Color values are between 0 and 255\n");
  179.             Console.write("The RED value was not set\n");
  180.             return null;
  181.             }
  182.      }
  183.      else
  184.      {
  185.      newPolygon.layers[0].colorGradient.startColor.red = 0;
  186.      }
  187.  
  188.  
  189.      if(g)
  190.      {
  191.      var maxVal = Math.max(g, 255);  //if argument exists check bounds
  192.     var minVal = Math.min(g, 0);
  193.             
  194.         if(maxVal <= 255 && minVal >= 0){
  195.             newPolygon.layers[0].colorGradient.startColor.green = g;
  196.             }
  197.             else
  198.             {
  199.             Console.write("ERROR: Color values are between 0 and 255\n");
  200.             Console.write("The GREEN value was not set\n");
  201.             return null;
  202.             }
  203.      }
  204.      else
  205.      {
  206.      newPolygon.layers[0].colorGradient.startColor.green = 0;
  207.      }
  208.  
  209.      if(b)
  210.      {
  211.      var maxVal = Math.max(b, 255);  //if argument exists check bounds
  212.     var minVal = Math.min(b, 0);
  213.             
  214.         if(maxVal <= 255 && minVal >= 0){
  215.             newPolygon.layers[0].colorGradient.startColor.blue = b;
  216.             }
  217.             else
  218.             {
  219.             Console.write("ERROR: Color values are between 0 and 255\n");
  220.             Console.write("The BLUE value was not set\n");
  221.             return null;
  222.             }
  223.      }
  224.      else
  225.      {
  226.      newPolygon.layers[0].colorGradient.startColor.blue = 0;
  227.      }
  228.  return newPolygon;
  229. }
  230.  
  231.  
  232.  
  233.  
  234. function roundedRectangle(w, h, x, y, cr, r, g, b)
  235. {
  236.  var Obj = getCC().createObject(LMObjectType.geometric, x, y);
  237.  var newRoundedRectangle = Obj.convertType(LMGeometricType.roundedRectangle);
  238.  newRoundedRectangle.size.x = w;
  239.  newRoundedRectangle.size.y = h;
  240.  
  241.  var radiusMaxVal = Math.max(cr, 200);  //if argument exists check bounds
  242.  var radiusMinVal = Math.min(cr, 0);
  243.             
  244.         if(radiusMaxVal <= 200 && radiusMinVal >= 0){
  245.             newRoundedRectangle.cornerRadius = cr;
  246.             }
  247.             else
  248.             {
  249.             Console.write("ERROR: The radius should be between 0 and 200\n");
  250.             Console.write("The radius was not set\n");
  251.             return null;
  252.             }
  253.  
  254.      if(r)
  255.      {
  256.      var maxVal = Math.max(r, 255);  //if argument exists check bounds
  257.     var minVal = Math.min(r, 0);
  258.             
  259.         if(maxVal <= 255 && minVal >= 0){
  260.             newRoundedRectangle.layers[0].colorGradient.startColor.red = r;
  261.             }
  262.             else
  263.             {
  264.             Console.write("ERROR: Color values are between 0 and 255\n");
  265.             Console.write("The RED value was not set\n");
  266.             return null;
  267.             }
  268.      }
  269.      else
  270.      {
  271.      newRoundedRectangle.layers[0].colorGradient.startColor.red = 0;
  272.      }
  273.  
  274.  
  275.      if(g)
  276.      {
  277.      var maxVal = Math.max(g, 255);  //if argument exists check bounds
  278.     var minVal = Math.min(g, 0);
  279.             
  280.         if(maxVal <= 255 && minVal >= 0){
  281.             newRoundedRectangle.layers[0].colorGradient.startColor.green = g;
  282.             }
  283.             else
  284.             {
  285.             Console.write("ERROR: Color values are between 0 and 255\n");
  286.             Console.write("The GREEN value was not set\n");
  287.             return null;
  288.             }
  289.      }
  290.      else
  291.      {
  292.      newRoundedRectangle.layers[0].colorGradient.startColor.green = 0;
  293.      }
  294.  
  295.      if(b)
  296.      {
  297.      var maxVal = Math.max(b, 255);  //if argument exists check bounds
  298.     var minVal = Math.min(b, 0);
  299.             
  300.         if(maxVal <= 255 && minVal >= 0){
  301.             newRoundedRectangle.layers[0].colorGradient.startColor.blue = b;
  302.             }
  303.             else
  304.             {
  305.             Console.write("ERROR: Color values are between 0 and 255\n");
  306.             Console.write("The BLUE value was not set\n");
  307.             return null;
  308.             }
  309.      }
  310.      else
  311.      {
  312.      newRoundedRectangle.layers[0].colorGradient.startColor.blue = 0;
  313.      }
  314.  
  315.  return newRoundedRectangle;
  316. }
  317.  
  318.  
  319.  
  320. function rectangle(w, h, x, y, r, g, b)
  321. {
  322.  var Obj = getCC().createObject(LMObjectType.geometric, x, y);
  323.  var newRectangle = Obj.convertType(LMGeometricType.rectangle);
  324.  newRectangle.size.x = w;
  325.  newRectangle.size.y = h;
  326.  
  327.      if(r)
  328.      {
  329.      var maxVal = Math.max(r, 255);  //if argument exists check bounds
  330.     var minVal = Math.min(r, 0);
  331.             
  332.         if(maxVal <= 255 && minVal >= 0){
  333.             newRectangle.layers[0].colorGradient.startColor.red = r;
  334.             }
  335.             else
  336.             {
  337.             Console.write("ERROR: Color values are between 0 and 255\n");
  338.             Console.write("The RED value was not set\n");
  339.             return null;
  340.             }
  341.      }
  342.      else
  343.      {
  344.      newRectangle.layers[0].colorGradient.startColor.red = 0;
  345.      }
  346.  
  347.  
  348.      if(g)
  349.      {
  350.      var maxVal = Math.max(g, 255);  //if argument exists check bounds
  351.     var minVal = Math.min(g, 0);
  352.             
  353.         if(maxVal <= 255 && minVal >= 0){
  354.             newRectangle.layers[0].colorGradient.startColor.green = g;
  355.             }
  356.             else
  357.             {
  358.             Console.write("ERROR: Color values are between 0 and 255\n");
  359.             Console.write("The GREEN value was not set\n");
  360.             return null;
  361.             }
  362.      }
  363.      else
  364.      {
  365.      newRectangle.layers[0].colorGradient.startColor.green = 0;
  366.      }
  367.  
  368.      if(b)
  369.      {
  370.      var maxVal = Math.max(b, 255);  //if argument exists check bounds
  371.     var minVal = Math.min(b, 0);
  372.             
  373.         if(maxVal <= 255 && minVal >= 0){
  374.             newRectangle.layers[0].colorGradient.startColor.blue = b;
  375.             }
  376.             else
  377.             {
  378.             Console.write("ERROR: Color values are between 0 and 255\n");
  379.             Console.write("The BLUE value was not set\n");
  380.             return null;
  381.             }
  382.      }
  383.      else
  384.      {
  385.      newRectangle.layers[0].colorGradient.startColor.blue = 0;
  386.      }
  387.  
  388.  return newRectangle;
  389. }
  390.  
  391.  
  392.  
  393. function path(w, h, x, y, r, g, b)
  394. {
  395.  var Obj = getCC().createObject(LMObjectType.geometric, x, y);
  396.  var newPath = Obj.convertType(LMGeometricType.path);
  397.  newPath.size.x = w;
  398.  newPath.size.y = h;
  399.  
  400.      if(r)
  401.      {
  402.      var maxVal = Math.max(r, 255);  //if argument exists check bounds
  403.     var minVal = Math.min(r, 0);
  404.             
  405.         if(maxVal <= 255 && minVal >= 0){
  406.             newPath.layers[0].colorGradient.startColor.red = r;
  407.             }
  408.             else
  409.             {
  410.             Console.write("ERROR: Color values are between 0 and 255\n");
  411.             Console.write("The RED value was not set\n");
  412.             return null;
  413.             }
  414.      }
  415.      else
  416.      {
  417.      newPath.layers[0].colorGradient.startColor.red = 0;
  418.      }
  419.  
  420.  
  421.      if(g)
  422.      {
  423.      var maxVal = Math.max(g, 255);  //if argument exists check bounds
  424.     var minVal = Math.min(g, 0);
  425.             
  426.         if(maxVal <= 255 && minVal >= 0){
  427.             newPath.layers[0].colorGradient.startColor.green = g;
  428.             }
  429.             else
  430.             {
  431.             Console.write("ERROR: Color values are between 0 and 255\n");
  432.             Console.write("The GREEN value was not set\n");
  433.             return null;
  434.             }
  435.      }
  436.      else
  437.      {
  438.      newPath.layers[0].colorGradient.startColor.green = 0;
  439.      }
  440.  
  441.      if(b)
  442.      {
  443.      var maxVal = Math.max(b, 255);  //if argument exists check bounds
  444.     var minVal = Math.min(b, 0);
  445.             
  446.         if(maxVal <= 255 && minVal >= 0){
  447.             newPath.layers[0].colorGradient.startColor.blue = b;
  448.             }
  449.             else
  450.             {
  451.             Console.write("ERROR: Color values are between 0 and 255\n");
  452.             Console.write("The BLUE value was not set\n");
  453.             return null;
  454.             }
  455.      }
  456.      else
  457.      {
  458.      newPath.layers[0].colorGradient.startColor.blue = 0;
  459.      }
  460.  
  461.  return newPath;
  462. }
  463.  
  464.