Code Monkey home page Code Monkey logo

sassy-math's Introduction

Sassy Math

Sassy Math is a tool designed to expand upon Sass and Compass's built in mathematic operations to include more advanced functions needed for complex calculations. These calculations may include mathematics based grid layouts, complex background images, advanced CSS animations, and anything else you can imagine.

Requirements

Sassy Math is a Compass extension, so make sure you have Sass and Compass Installed in order to use its awesomeness!

Install

sudo gem install sassy-math

If creating a new project

compass create <my_project> -r sassy-math

If adding to existing project, in config.rb

require 'sassy-math'

There are no partials to import! As long as Sassy Math is included in your config.rb file, you can use all of its might!

Constants

Functions

Exponents

  • exponent($base, $power_numerator, $power_denominator) - The $base raised to the given power where the power is a fraction in the form of $power_numerator / $power_denominator.
  • power($base, $power) - The $base raised to the given $power where the power is an integer or floating point number.
  • nth-root($number, $root) - The given $root of the input $number.
  • sqrt($number) - The square root of the given $number.

Logarithms

  • ln($number) - The natural log of the $number.
  • log($number) - The base 10 log of the $number

Angular

Note: Compass comes with sine (sin($radians)), cosine (cos($radians)), and tangent (tan($radians)) functions already, so they aren't included as part of Sassy Math.

General

  • deg-to-rad($degrees) - Returns the $degrees in radians.
  • rad-to-deg($radians) - Returns the $radians in degrees (unitless).

Inverse Trigonometric

  • asin($radians) - Arcsine of $radians. Constrained to the domain -1 ≤ $radians ≤ 1.
  • acos($radians) - Arccosine of $radians. Constrained to the domain -1 ≤ $radians ≤ 1.
  • atan($radians) - Arctangent of $radians.
  • atan2($y, $x) - Arctangent given $x and $y.

Hyperbolic

  • sinh($radians) - Hyperbolic sine of $radians.
  • cosh($radians) - Hyperbolic cosine of $radians.
  • tanh($radians) - Hyperbolic tangent of $radians.

Inverse Hyperbolic

  • asinh($radians) - Hyperbolic arcsine of $radians.
  • acosh($radians) - Hyperbolic arccosine of $radians. Constrained to the domain $radians < 1.
  • atanh($radians) - Hyperbolic arctangent of $radians. $radians cannot equal ±1.

Miscellaneous

  • factorial($number) - The factorial of the $number.
  • random($max) — Random number. The default max is 100 but you can specify whatever you want.
  • hypot($a, $b) - Returns the hypotenuse of a right-angled triangle given sides $a and $b

Comparative

  • is-int($number) - Determines whether or not the $number is an integer. Returns true or false.
  • is-float($number) - Determines whether or not the $number is a floating point number. Returns true or false.

License

Copyright (c) 2012 Sam Richard, Mario Valencia and Scott Kellum

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

sassy-math's People

Contributors

robocoder avatar scottkellum avatar snugug avatar sultancillo avatar yuvilio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sassy-math's Issues

Building a test suite

Sam,

I am playing around with building a test suite for this stuff as I dive in but am having trouble getting the ruby working. Are you building a gem after each change to test? Seems like there should be a better way.

Attached is my work, hoping to tackle random numbers and stuff to get back into this:
scottkellum/sassy-math@f7c3654

Planning on rolling this stuff into modular scale, and this project into Compass.

Convert to SCSS

Would anyone be opposed to me converting this to SCSS? For me, with lots of nested if/else and for loops, SCSS is a lot easier to keep track of everything.

Should exponent() be able to accept a fraction?

Hi, in your readme file you mention being able to us

exponent($base, $power_numerator, $power_denominator)

However this function only accepts two arguments. Have I misunderstand the meaning here?

Naming arguments and categorizing functions

In the readme.md and in the sassy-math.rb files, the inverse trigonometric functions, the hyperbolic functions and their inverses take in an argument called $radians or rad. That's a bit misleading.

The inverse trigonometric functions actually take in a number value (restricted to the interval [-1, 1] in the case of sin and cos) and output an angle value in radians. It's precisely the inverse of the direct trigonometric functions, which take in an angle value in radians and return a number (which is a number between -1 and 1 for sin and cos).

The hyperbolic functions are just that, hyperbolic functions. They're not trigonometric functions and they don't fall under trigonometry, but under hyperbolic geometry. Their name is just an analogy. Just like when plotting the points (sin(a), cos(a)), the result is the unit circle (which is why the trigonometric functions are also called circular functions), when plotting the points (sinh(a), cosh(a)), the result is the unit hyperbola.

Calling the argument for such a function $radians or rad doesn't make much sense, since the radian is a unit of angular measure. Both the hyperbolic functions and their inverses take in a number value and return a number value as well (with the domain restrictions corresponding to each).

Publish to npm

Would be nice so we can use it on, say, Metalsmith projects.

Move to Branch/Pull Request Model

What are people's thoughts on moving from a "push straight to master" model to a "branch and issue pull request" model? This would help with us stepping on each other's toes and make it easier to keep track of discrete pieces to be worked on.
Thoughts?

Make public

Ready to make this public soon? Lets just clean this up and switch it to SCSS only. Mark as beta and add the licence.

The basics are there, but it seems like we need more eyes on this to polish up rough areas.

use a prefix

hi,

is it possible to use a prefix for functions in order to avoid conflicts with other frameworks?

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.