Code Monkey home page Code Monkey logo

grained's Introduction

Add animated grain texture effect to your content.

With grained.js you can add customized noise effect on your web page. It has easily customizable options to generate the animated noise effect. The animation is added using CSS3 key-frame animation and instantly generated png noise image.

"Create your own"

Create your own

How to use

Include the library file in your html page.

<script src="grained.js"></script>

initialize the library by

grained('elementId',options)

'elementId' is the id of the container element to add the grain effect. It is important to note that grainedjs will not change the background of the container element. It appends a div element as the first child of the container. Grainedjs will add two style changes to the container element 'position:relative;overflow:hidden'. If the container position is absolute it will remand as absolute only.

Since a 'div' element with class 'grained' is added as first child element with position absolute it will have the z index priority and appears on top of other contents in the container element. If you want the other elements in container element on top of grained effect you have to add a css like

#container > * { position:relative; }

So the ideal structure of implementaion is like follows

<div id="container">
   <div class="contents">
     your contents goes here .. like <a>, <p> etc
   </div>
</div>

after initilizing grained('#container', {}); it will look like this

<div id="container">
    <div class='grained'></div>
    <div class="contents">
        your contents goes here .. like <a>, <p> etc
    </div>
</div>

Options

With these options you can crate customized grained effect , these are the option parameter you can change and the default values.

 var options = {
         animate: true,
         patternWidth: 100,
         patternHeight: 100,
         grainOpacity: 0.05,
         grainDensity: 1,
         grainWidth: 1,
         grainHeight: 1
 };

With animation true/false you can create textures with grain movement and a static one. The other value you can see the live in online generator

grained's People

Contributors

anirudh-eka avatar lpmi-13 avatar sarathsaleem 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.