Highlighted

This stroke-width expression works, but I have no clue why — would you kindly explain it to me?

Community Beginner ,
Jul 03, 2020

Copy link to clipboard

Copied

Hi there!

 

I recently picked this expression from one of Ordinary Folks freebee. It preserves the thickness of a stroke constant despite of the scale of the object. It is nicely short, but I have no idea why it works. And what the strange numbers are doing there?

 

Thank you in advance.

 

value / length(toComp([0,0]), toComp([0.7071,0.7071])) || 0.001;

 

TOPICS
Expressions

Views

61

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

This stroke-width expression works, but I have no clue why — would you kindly explain it to me?

Community Beginner ,
Jul 03, 2020

Copy link to clipboard

Copied

Hi there!

 

I recently picked this expression from one of Ordinary Folks freebee. It preserves the thickness of a stroke constant despite of the scale of the object. It is nicely short, but I have no idea why it works. And what the strange numbers are doing there?

 

Thank you in advance.

 

value / length(toComp([0,0]), toComp([0.7071,0.7071])) || 0.001;

 

TOPICS
Expressions

Views

62

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 03, 2020 0
Most Valuable Participant ,
Jul 03, 2020

Copy link to clipboard

Copied

The values are simply transposed to composition space to compensate for scaling. Otherwise it's just a normal ratio division.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 03, 2020 0
Community Beginner ,
Jul 03, 2020

Copy link to clipboard

Copied

Thank you for your reply Mylenium,

 

I am sorry for being thickheaded, but why 0.7071?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 03, 2020 0
Most Valuable Participant ,
Jul 03, 2020

Copy link to clipboard

Copied

Pythagoras' theorem. It's the length of the hypothenuse for the desired target value. Other thicknesses would require different values, naturally. The expression basically constructs a virtual equilateral triangle which is scaled and measures the actual length in comp coordinates by ways of the toComp() function to do its magic.

 

Mylenium

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 03, 2020 0
Community Beginner ,
Jul 03, 2020

Copy link to clipboard

Copied

Simple & ellegant. Thank you for your time Mylenium.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 03, 2020 0