Skip to content

Instantly share code, notes, and snippets.

@tsechingho
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsechingho/b5664213e18f8df10884 to your computer and use it in GitHub Desktop.
Save tsechingho/b5664213e18f8df10884 to your computer and use it in GitHub Desktop.
slim_sass_coffee
// http://thesassway.com/advanced/inverse-trigonometric-functions-with-sass
$default-threshold: pi() / 180 / 20
@function convert-angle($value, $unit-name)
$factors: (rad: 1rad, deg: 180deg / pi(), grad: 200grad / pi(), turn: 0.5turn / pi())
@if not unitless($value)
@warn "`#{$value}` should be unitless"
@return false
@if not map-has-key($factors, $unit-name)
@warn "unit `#{$unit-name}` is not a valid unit - please make sure it is either `deg`, `rad`, `grad` or `turn`"
@return false
@return $value * map-get($factors, $unit-name)
@function asin($z, $unit-name: deg, $threshold: $default-threshold)
$sum: 0
$complement: false
$sign: if($z != 0, $z / abs($z), 1)
$z: abs($z)
@if $z > 1
@warn "illegal `#{$z}` value for function"
@return false
@if $z > sin(pi() / 4)
$complement: true
$z: sqrt(1 - pow($z, 2))
$term: $z
$i: 0
$k: 1
@while $term > $threshold
$sum: $sum + $term
$i: $i + 1
$k: $k * (2 * $i - 1) / (2 * $i)
$j: 2 * $i + 1
$term: $k * pow($z, $j) / $j
@return convert-angle($sign * if($complement, pi() / 2 - $sum, $sum), $unit-name)
@function acos($z, $unit-name: deg, $threshold: $default-threshold)
@return convert-angle(pi() / 2, $unit-name) - asin($z, $unit-name, $threshold)
@function atan($z, $unit-name: deg, $threshold: $default-threshold)
@return asin($z / sqrt(1 + pow($z, 2)), $unit-name, $threshold)
#calendar
.title
@extend .text-left
display: inline-block
h3
font-size: 32px
margin: 4px 0 0
.controls
@extend .btn-group
float: right
padding: 5px
.previous
@extend .btn
@extend .btn-default
padding-left: 14px
i
@extend .glyphicon
@extend .glyphicon-chevron-left
@extend .pull-left
margin-top: 1px
.next
@extend .btn
@extend .btn-default
padding-right: 14px
i
@extend .glyphicon
@extend .glyphicon-chevron-right
@extend .pull-right
margin-top: 1px
.today
@extend .btn
@extend .btn-default
#calendar
.row
.col-xs-12.col-sm-12.col-md-12
.title
h3
= "#{calendar.month.to_s("%B")} #{calendar.year}"
.controls
= link_to calendar_path(calendar.previous.month), class: 'previous' do
| Prev
i
= link_to 'Today', calendar_path(Date.today.strftime('%Y-%m')), class: 'today'
= link_to calendar_path(calendar.next.month), class: 'next' do
| Next
i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment