質問

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