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