Well, thatβs not entirely independent of the language, but since itβs just Javascript, it should work in all LESS implementations, unless I think about it clearly.
In doing so, you can use Javascript to calculate the sine and cosine:
.rotate(@deg) { // css transform capable browsers properties... // IE <= 8 @deg2radians: 3.1416 * 2 / 360; @rad: @degree * @deg2radians; @sintheta: ~`Math.sin(@{rad})`; @costheta: ~`Math.cos(@{rad})`; // filter: transform matrix method... }
Backticks are used to evaluate Javascript, and you can also access the DOM. For example, the following is valid:
`document.write('Hello!')`
The tilde is used for escaping, and @ {} means variable interpolation. For example:
@input: 10; `document.write(Math.sin(@{input}))`;
See the LESS Usage Guide for more information.
voithos
source share