문제

I'm having some trouble figuring out how to use the compass math helper functions.

Assume I have a triangle ABC with C = 90 degrees. I would like to know how many degrees A is.

The formula for that is easy: A = arctan(a/b), but how do I code that with Compass and Sass?

도움이 되었습니까?

해결책

You'll have to create a function in Ruby to do this. Since you're already using Compass, you can take advantage of the Sassy Math extension. Their Ruby code for this function looks like this (hope I've got the right one here):

  def atan2(y, x)
    y = y.value.to_f
    x = x.value.to_f
    result = Math.atan2(y, x)
    Sass::Script::Number.new(result)
  end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top