Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
alternating .setFontSize() inside of an array

Im not really a programmer so please excuse the slightly crude description. This is an expression for a textlayer in Adobe After Effects (which uses Javascript)

I currently use this expression to generate an array of values (which is later used as customizable labels for the axes of a graph)

x = 0 //starting point (the first number in the list)
y= 20 //increments (the size of the steps)
z= 5 //the number of steps

Array.from(new Array(z)).map((_, i) => i * y + x + "km").join("\n")

which outputs

0km
20km
40km
60km
80km

Then I thought it would also be good to have miles in there so I changed the code to this

Array.from(new Array(z)).map((_, i) => i * y + x + "km " + (i * y + x) * 0.6 +"mi").join("\n")

I suppose its not beautiful but it does the job ...

0km 0mi
20km 12mi
40km 24mi
60km 36mi
80km 48mi

I then tried to add a customizable fontsize. Thats how I did it.

text.sourceText.style.setText
(
Array.from(new Array(z)).map((_, i) => i * y + x + "km " + (i * y + x) * 0.6 +"mi").join("\n")
)
.setFontSize(20)

This worked, but really I only want a different font size for the miles value and this is where I ran into trouble. I tried

Array.from(new Array(z)).map((_, i) => i * y + x + "km " + text.sourceText.style.setText((i * y + x) * 0.6 +"mi").setFontSize(10)).join("\n")

but this seems to break the code. It only outputs

0km [object Object]
20km [object Object]
40km [object Object]
60km [object Object]
80km [object Object]

any ideas? Thanks in advance

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!