ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

error with color epxression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Assaf Goldlust
error with color epxression
on Mar 3, 2018 at 7:08:01 pm
Last Edited By Assaf Goldlust on Mar 3, 2018 at 7:09:17 pm

in the book "AE Expressions"
he gave the following expression

var red=thisComp.layer("Controls").effect("Red")("Slider");
var green=thisComp.layer("Controls").effect("Green")("Slider");
var blue=thisComp.layer("Controls").effect("Blue")("Slider");
var alpha=1;

var hsl=
rgbToHsl=([red,green,blue,alpha])
hsl[0]+=.5;
if (hsl[0]>1)hsl[0][H11546]=1;
var rgb = hslToRgb(hsl);
rgb

but keep getting an error that tells me that

H11546 in class 'global' is missing or dosent exist
I have compared what i wrote against whats in the book and i dont see why,
can any of your help me out here?


Return to posts index

Dan Ebberts
Re: error with color epxression
on Mar 3, 2018 at 8:12:40 pm

I think it should be like this:

var red=thisComp.layer("Controls").effect("Red")("Slider");
var green=thisComp.layer("Controls").effect("Green")("Slider");
var blue=thisComp.layer("Controls").effect("Blue")("Slider");
var alpha=1;

var hsl = rgbToHsl([red,green,blue,alpha]);
hsl[0]+=.5;
if (hsl[0]>1)hsl[0] -= 1;
var rgb = hslToRgb(hsl);
rgb

Dan



Return to posts index

Assaf Goldlust
Re: error with color epxression
on Mar 3, 2018 at 8:19:05 pm

wait, so why in the book its looks like this?




Return to posts index


Dan Ebberts
Re: error with color epxression
on Mar 3, 2018 at 8:27:49 pm

It definitely does not look like that in my copy. Maybe you have a newer edition, where it somehow got messed up.


Dan



Return to posts index

Assaf Goldlust
Re: error with color epxression
on Mar 4, 2018 at 5:58:00 am

Well,this sucks


Return to posts index

Assaf Goldlust
Re: error with color epxression
on Mar 4, 2018 at 10:40:14 am

Any way, i have another queation.
At some point in the expression he used the code

hsl[0] + = .5;

And later he explained:
“+ = .5” means add .5 to whatever the value already is.

Im slightly confused,
What is tge diffrence bewtween the usual
Value=+.5?


Return to posts index


Dan Ebberts
Re: error with color epxression
on Mar 4, 2018 at 4:39:22 pm

It would be:

hsl[0] += .5;

(no space between the + and the = ).

+= is a JavaScript shorthand operator that gives you the same result as:

hsl[0] = hsl[0] + .5;


Dan



Return to posts index

Assaf Goldlust
Re: error with color epxression
on Mar 5, 2018 at 5:46:10 am

So if i lets say want to do:
T=transform.position[0]+5;

I can instead do?
transform.position[0]+=5;


Return to posts index

Dan Ebberts
Re: error with color epxression
on Mar 5, 2018 at 7:54:54 am

The first one takes the layer's x postion, adds 5 to it, and stuffs the result in variable T.

I don't think the second one actually does anything (except maybe generate an error). So no, they're not equivalent.

Dan



Return to posts index


Assaf Goldlust
Re: error with color epxression
on Mar 7, 2018 at 4:57:17 pm

so whats is this operator function?

i mean in general not just in the contest of this color expression?


Return to posts index

Dan Ebberts
Re: error with color epxression
on Mar 7, 2018 at 5:09:56 pm

+= is one of JavaScript's assignment operators.

Where

x += y

is the same as

x = x + y



Dan



Return to posts index

Assaf Goldlust
Re: error with color epxression
on Mar 8, 2018 at 6:10:56 pm

So why dosnt it work whrn i try to apply it to a specific dimension from an array?


Return to posts index


Dan Ebberts
Re: error with color epxression
on Mar 8, 2018 at 6:23:38 pm

It should.

var a = [1,1]
a[0] += 1;

should give you [2,1]

Getting back to what you were trying to do before, something like this should work:

T = transform.position.value;
T[0] += 5;
T


Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]