Code Monkey home page Code Monkey logo

sass-trigonometry's Introduction

sass-trigonometry

Build Status License npm version

Sass trigonometry and inverse trigonometry functions.

Introduction

Expand Sass function with pure Sass trigonometry functions : pi , deg-to-rad, rad-to-deg , sin , cos , tan , asin , acos and atan. And with some usefull math functions : pow, fact and sqrt.

It could allows to dynamicly calculate angle in pure sass.

Install

Using npm

npm install --save sass-trigonometry

Using yarn

yarn add sass-trigonometry

Usage

@import "~sass-trigonometry";

Constant

pi

Example:

$pio2: pi() / 2;

Functions

deg-to-rad and rad-to-deg

Simple degres to radian conversion functions.

sin , cos and tan

Sine, Cosine and Tangent trigonometry functions.

Example

sin(45deg); // => 0.7071...
cos(30deg); // => 0.8660...
tan(60deg); // => 1.7320...

asin , acos and atan.

Arcsine, Arccosine and Arctangent inverted trigonometry functions.

Example

asin(0.7071); // => 45
acos(0.8660); // => 30
atan(1.7320); // => 60

pow, fact and sqrt

Power, Factorial and Square-root functions

Example

pow(10, 2); // => 100
fact(5); // => 120
sqrt(100); // => 10

Examples

@import "~sass-trigonometry";

$width: 200;
$height: 150;
$diagonal-width: sqrt(pow($width, 2) + pow($height, 2));
$diagonal-angle: atan($height / $width);


#triangle {
    position: relative;
    height: #{$height}px;
    width: #{$width}px;
    border-bottom: 1px solid red;
    border-left: 1px solid red;

    &:before {
        border-top: 1px solid red;
        content: "";
        left: 0;
        position: absolute;
        top: $height;
        transform-origin: left;
        transform: rotate(#{$diagonal-angle}deg);
        width: #{$diagonal-width}px;
    }
}

See the result in Codepen

References

sass-trigonometry's People

Contributors

dependabot[bot] avatar gbprod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.