Jump to content

tiscavalcanti

Members
  • Posts

    46
  • Joined

  • Last visited

Everything posted by tiscavalcanti

  1. I myself will continue trying to do. That is it.
  2. Hello, I'm needing to write code that do the following. Take two values: [x, y]; And using conditions change within functions. The following is: var x = 0;var y = 0;var b = 2;var c = 3;So;first function of x = valueXOffset (xFunctionFirst) // OffsetIf b = 1return{96 // 5% of 1920}y = 54 // 5% of 1080Else if b = 2return{192 // 10% of 1920}y = 108 // 10% of 1080Else if b = 3return{288 // 15% of 1920}y = 162 // 15% of 1080Else b = (any value)return{0}y = 0second function of x = valueXFinal (xFunctionSecond)If c = 1return{xFunctionFirst}Else If c = 2return{1920/2}Else If c = 3return{1920 - xFunctionFirst}Else c = (any value)0call function here, to get x value and y too.[x, y]; By "y" get stuck within a function, have to follow the conditions, it must be called in the last function. I think you need to use two functions, something like this example: the function (x) {// <- function function b (y) {// <- inner function return x + y; // <- Use variables from outer scope } return b; // <- You can even return to function. } to (3) (4); And each function use two parameters to represent x and y. As a way to array. In the function of "x", if you need to call a value, which is 1920. And in function of "y" 1080. What this code does is every time I increase 1-3, b, x rise or fall by 5%, and y will increase by 5% from 1 to 1. And 1 to 3 passes c 0 + offset, 960 = half, and then in 1920, the total - offset. The restrictions I have, it is to be done with functions, please.
  3. I have: function val(a,z){ return a/2, z+8; } val(3,4); Put this in a Array; x = 1,5 y = 12 [x,y]; Thanks.
  4. w = thisComp.width;h = thisComp.height;s = 0;p = [.95, .90, .85, .15, .10, .05];x = value[0];y = value[1];function getLayerName(theLayer,theName,theParm){ try{ return theLayer.effect(theName)(theParm).name; }catch(err){ return "None"; }}L = thisComp.layer("Less");a = getLayerName(L,"Scale","Layer");b = getLayerName(L,"Position","Layer");c = getLayerName(L,"Side","Layer"); This is it.
  5. After I managed to go ahead on the understanding of "for" loops and functions, I realized that there really is not a way to make a loop or function, use the instruction always use the same base code: (thisComp.effect ("")("Layer") name;), adding effect name (Scale, Position, Side) in half and then, generating variables (a, b, c), each getting one line of code ready. (as a factory cakes, which uses always the same base recipe, and only adds a special ingredient for each cake, making cakes with different flavors, for example). But if there is a another way to do this, let me know please. Actually, I just wanted a way to simplify my code, but I realized that is not feasible. Because just getting more complicated, what was simpler. Sorry to ask a question without much foundation.
  6. Is there a way to do this more easily? How to add a value in the middle of a code line? And there is a way to separate each line of output of a for loop? Thanks.
  7. What I want is to actually simplify the code, to avoid repetition. I want to avoid of writing dozens of times, the same base of effect code to save rewrite that part: thisComp.effect("")("Layer").name; Because the expression in general, becomes very extensive and more difficult to edit with lot of effects. So I want a way to use a loop that collects all the names of the effects, and use the base of effect code above which is repeated, to receive these names: "Scale", "Position" & "Side", and generate 3 full effects separately, with this output: thisComp.effect("Scale")("Layer").name; thisComp.effect("Position")("Layer").name; thisComp.effect("Side")("Layer").name; And finally, take these three generated effects, and connect them to 3 variables... a, b and c. It is possible? I'm beginner with functions and loops.
  8. var names=["Scale", "Position", "Side"]; for (var i = 0; i < names.length; i++) { var val="thisComp.effect(" +names +")('Layer').name"; } the result of "var val" is this: thisComp.effect(Scale)('Layer').namethisComp.effect(Position)('Layer').namethisComp.effect(Side)('Layer').name I can arrive until here. But it's all together. I wanted to separate each line, now for each variable. A, B and C. Lack take each line of output to a variable.
  9. var a = thisComp.effect("Scale")("Layer").name; var b = thisComp.effect("Position")("Layer").name; var c = thisComp.effect("Side")("Layer").name;
  10. I need to create a code that take the following strings: "Scale" "Position" "Side" And put each one, within of a copy of this code: thisComp.effect(!!!STRING HERE!!!)("Layer").name; And after that, three variables, each one, receive a complete code. var a; var b; var c; The result would be this: var a = thisComp.effect("Scale")("Layer").name; var b = thisComp.effect("Position")("Layer").name; var c = thisComp.effect("Side")("Layer").name; I try made like this: var strings = ["Scale", "Position", "Side"]; var val = function (a, b, c){ for (var i=0; i<strings.length; i++){ var effect=thisComp.effect(strings)("Layer").name; val(effect); } } But no have experience with functions and For Loops. And no know if this is the correct way of do it. I need to do this because my code is becoming too long for many repetitions. I think for that, will need to use for loop, and function. Thanks.
  11. I got. Examples: .20*76 | 20% of 76 = 15.2 1.20*76 | 76 + 20% = 91.2 (1-.20)*76 | 76 - 20% = 60.8 Calculate numerical difference between two values: (-8)+(3) = - 5 | balance value. (-8)-(3) = 11 | difference value. This is it. Thanks.
  12. I need make a calculation which allow know difference between two numbers. I can subtract the smallest of the larger, but this calculation is very limited, implies if a number is negative and the other positive. I want to know another way to do this. It is possible to do this calculation in JavaScript through the: modulo; function; (Others); Mainly: Another important thing which I want, is to calculate percentage difference through two differents numbers. To know the value resultant. I want to know all the possible ways to do this. Because I came across in an embarrassing situation in a video Software that uses expressions based on the JavaScript language. Thanks!
×
×
  • Create New...