A library for pretty shadows.

Related tags

Effect shine.js
Overview

shine.js

A library for pretty shadows.

See the working demo at http://bigspaceship.github.io/shine.js/.

Get Started Inline docs

Install using bower: bower install shine or download as zip or fork on GitHub.

Create a Shine.js instance for each DOM element you'd like to shine:

var shine = new Shine(document.getElementById('my-shine-object'));

Change the light position and make sure to redraw:

shine.light.position.x = window.innerWidth * 0.5;
shine.light.position.y = window.innerHeight * 0.5;
shine.draw(); // make sure to re-draw

Configuration

Each shine instance has a property pointing to an instance of shinejs.Config. One config can be shared amongst multiple shine instances.

When a config value changes, shine.draw() needs to be called to re-draw with the new settings.

Change the shadow of a shine instance:

shine.config.opacity = 0.1;
shine.config.blur = 0.2;
shine.draw(); // make sure to re-draw

Create a shared shinejs.Config instance:

// all parameters are optional and can be changed later
var config = new shinejs.Config({
  numSteps: 4,
  opacity: 0.2,
  shadowRGB: new shinejs.Color(255, 0, 0)
});

// pass the config in the constructor
var shineA = new Shine(document.getElementById('my-shine-object-a'), config);
var shineB = new Shine(document.getElementById('my-shine-object-b'), config);

// or assign it to an instance later
var shineC = new Shine(document.getElementById('my-shine-object-c'));
shineC.config = config;
shineC.draw(); // make sure to re-draw

Shine API

Note: Shine is also mapped to shinejs.Shine. Use the long version if Shine is already defined.

Shine(domElement, optConfig, optClassPrefix, optShadowProperty)

The Shine constructor. Instantiate as new Shine(...) to create a new instance.

Parameter Type Description
domElement !HTMLElement The DOM element to apply the shine effect to.
optConfig ?shinejs.Config= Optional config instance. If no instance is passed it a new instance with default values will be stored in the config property.
optClassPrefix ?string= Optional class prefix that will be applied to all shine DOM elements. Defaults to shine-.
optShadowProperty ?string= Optional property name that the shadow will be applied to. Overrides the automatic detection for use of either textShadow or boxShadow. The value will be applied as element.style[shadowProperty] = '...' and automatically prefixed for legacy browsers (e.g. MozBoxShadow).

Shine.prototype.draw()

Draws all shadows based on the current light position. Call this method whenever a shine parameter is changed.

Shine.prototype.destroy()

Releases all resources and removes event listeners. Destroyed instance can't be reused and must be discarded.

Shine.prototype.updateContent(optText)

Re-initializes all shadows. Use this when you want to change the text or the domElement's contents have changed.

Parameter Type Description
optText ?string= If defined, will replace the DOM element's textContent. If omitted, the content will be read from the DOM element.

Shine.prototype.enableAutoUpdates()

Adds DOM event listeners to automatically update all properties.

Shine.prototype.disableAutoUpdates()

Removes DOM event listeners to automatically update all properties.

Shine Properties

Property Type Description
domElement HTMLElement The DOM element to apply the shine effect to.
config shinejs.Config Stores all config parameters.
light shinejs.Light Stores the light position and intensity.

shinejs.Config API

shinejs.Config(optSettings)

The shine config constructor. Pass an optional settings object from which to read values.

Parameter Type Description
optSettings ?Object= An optional object containing config parameters.

shinejs.Config Properties

Property Type Default Description
numSteps number 8 The number of steps drawn in each shadow
opacity number 0.1 The opacity of each shadow (range: 0...1)
opacityPow number 1.2 The exponent applied to each step's opacity (1.0 = linear opacity).
offset number 0.15 Larger offsets create longer shadows
offsetPow number 1.8 The exponent applied to each step's offset (1.0 = linear offset).
blur number 40 The strength of the shadow blur.
blurPow number 1.4 The exponent applied to each step's blur (1.0 = linear blur).
shadowRGB shinejs.Color new shinejs.Color(0, 0, 0) The shadow color in r, g, b (0...255)

shinejs.Light API

shinejs.Light(optPosition)

The light constructor. Pass an optional position to apply by default.

Parameter Type Description
optPosition ?shinejs.Point= An position. Defaults to new shinejs.Point(0, 0).

shinejs.Light Properties

Property Type Default Description
position shinejs.Point new shinejs.Point(0, 0) The position of this light.
intensity number 1.0 The intensity of this light. Gets multiplied with shadow opacity.

shinejs.Point API

shinejs.Point(x, y)

A 2D point class.

Parameter Type Description
x number= The x-coordinate. Defaults to 0.
y number= The y-coordinate. Defaults to 0.

shinejs.Point Properties

Property Type Default Description
x number 0 The x-coordinate.
y number 0 The y-coordinate.

shinejs.Point.prototype.delta(p)

Returns a new instance of shinejs.Point with the x- and y-distance between this instance and the point p.

Parameter Type Description
p shinejs.Point The point to which to calculate the distance to. Distance will be expressed as this.x - p.x and this.y - p.y.
Comments
  • Doesn't work with Require.js?

    Doesn't work with Require.js?

    I've tried including shine.js into my project with require, but it doesn't work. I get two errors: the first is exports is undefined and the second is that the module returns undefined.

    enhancement 
    opened by gfarrell 5
  • Removes elements from the DOM

    Removes elements from the DOM

    A really beautiful plugin this...

    But I'm having a little trouble when applying it to a container which has (so far) 12 children to whom I want shadows to be applied. However, when called, the plugin remove 6 of these children. I couldn't find any mention of this kind of behaviour in the documentation, or an option for specifying the max number of child elements.

    So I was wondering... Is this intended behaviour?

    I can understand there would be performance issues if there are too many elements, but it might be useful to know that's what's happening. Or even to be able to set the max number of elements.

    (I did look through the plugin's JS but couldn't spot where this might be happening. I'd be happy to try and implement an a maxElements option...)

    Thanks!

    opened by bravokiloecho 3
  • Doesn't work with transparent images.

    Doesn't work with transparent images.

    Hi,

    Amazing plugin. I love it. When i am using it on png image, shadow is not considering transparent pixels. Please see attached screenshot. (In screenshot i have used transparent circle.). Is it possible to consider transparent pixels in png images?

    circle

    enhancement 
    opened by vijay-vanecha 2
  • Added option to bind light source to scroll position (also removed console logs)

    Added option to bind light source to scroll position (also removed console logs)

    There are inline styles on the body and h1 in the mouse-follow demo to better immediately demonstrate the added option. I also removed the console logs.

    enhancement demo 
    opened by cmd-kae 2
  • High CPU utilization - 80%+

    High CPU utilization - 80%+

    If I mouse around at normal speed in the demo, CPU utilization jumps to 80% - 90%. I'm using Chrome 43.0.2357.124 m on Windows 7 on a Dell E7450 Core i5 with some an integrated GPU (which is perfectly capable of handling this demo at <40% CPU).

    invalid 
    opened by dandv 1
  • Remove moot `version` property from bower.json

    Remove moot `version` property from bower.json

    Per bower/bower.json-spec@a325da3

    Also their maintainer says they probably won't ever use it: http://stackoverflow.com/questions/24844901/bowers-bower-json-file-version-property

    opened by kkirsche 1
  • Add docs badge to README

    Add docs badge to README

    Hi there,

    I want to propose to add this badge to the README to show off inline-documentation: Inline docs

    The badge links to Inch CI and shows an evaluation by InchJS, a project that tries to raise the visibility of inline-docs (early adopters include forever, node-sass and when).

    The idea is to motivate aspiring Node developers to dive into Open Source projects and read the code. It's about engagement, because, while testing and code coverage are important, inline-docs are the humanly engaging factor in Open Source. This project is about making people less adverse to jumping into the code and see whats happening, because they are not left alone while doing so. I know that, because I put off reading other people's code way too long in my life.

    Although this is "only" a passion project, I really would like to hear your thoughts, critique and suggestions. Your status page is http://inch-ci.org/github/bigspaceship/shine.js

    What do you think?

    opened by rrrene 1
  • Does not work on touch devices (ie. iPad)

    Does not work on touch devices (ie. iPad)

    On my iPad the shadows don't follow my finger touch. What about making the light source the currently selected button or tab? If the button is hilighted like a led, it make sense making it the light source instead of the mouse cursor. It will works on touch devices too.

    invalid 
    opened by Emasoft 1
  • Can't get Shine to correspond to gyroscope title

    Can't get Shine to correspond to gyroscope title

    Hi, I'd like to know how to make the shadows correspond to gyroscope input on mobile devices, similar to how the Shine.js demo works.

    Can you please help?

    Thanks!

    opened by lostnotstranded 0
  • How to add mutiple text with Shinejs

    How to add mutiple text with Shinejs

    Hi there, I wanted to add 2 Titles with shadows one at the very top of the page and above the footer. When I add the second one to the page with shinejs, the 1st one gets disabled for cursor movements but has soft shadows. second one gets the cursor movements.

    Please suggest what I should do.

    Thank you

    opened by kannan6240 1
  • some suggest about css

    some suggest about css

    #1 add transform : translate3D(0,0,0) to shine-letter class. to use GPU accelerate #2 add media query disable text-shadow when print when print, text-shadow may made text difficult to read

    opened by wqj97 0
Javascript library enabling magnifying glass effect on an images

Magnifier.js Javascript library enabling magnifying glass effect on an images. Demo and documentation Features: Zoom in / out functionality using mous

Mark Rolich 808 Dec 18, 2022
"shuffle-text" is JavaScript text effect library such as cool legacy of Flash.

ShuffleText This is the JavaScript library for text effect such as Flash contents. Setup Script Install <script src="shuffle-text.js"></script> NPM In

Yasunobu Ikeda 96 Dec 24, 2022
⌨️ A tiny library for creating a typing effect on specified text element.

⌨️ TinyTyper - a tiny library for creating a typing effect on specified text element. Demo Size (It's really tiny) Minimized: 2.9KB Gziped: 1.1KB Inst

Korney Vasilchenko 175 Sep 29, 2021
A little library that can be used for bursting particles effects on buttons and other elements

Particle Effects for Buttons Bursting particles effects for buttons. By Luis Manuel. Article on Codrops Demo Credits anime.js Basic usage The Particle

Codrops 1.2k Jan 1, 2023
Javascript and SVG odometer effect library with motion blur

SVG library for transitioning numbers with motion blur JavaScript odometer or slot machine effect library for smoothly transitioning numbers with moti

Mike Skowronek 793 Dec 27, 2022
Lazy Line Painter - A Modern JS library for SVG path animation

Lazy Line Painter lazylinepainter.info A Modern JS library for SVG path animation Getting Started | Documentation | Examples | Lazy Line Composer Gett

Cam O'Connell 1.9k Jan 3, 2023
🎨 Aquarelle is a watercolor effect component. Javascript library by @Ramotion

Aquarelle About This project is maintained by Ramotion, Inc. We specialize in the designing and coding of custom UI for Mobile Apps and Websites. Look

Ramotion 1.8k Dec 9, 2022
Liquideffect - Javascript Library for creating liquid effect on image and RGB effect on mouse direction.

LiquidEffect Javascript Library for creating liquid effect on image and RGB effect on mouse direction. Demo https://liquideffect.netlify.app/ Dependen

Rohail 8 May 6, 2022
A JavaScript library for advanced 2D slideshow with WebGL, that provides variety of beautiful effects

gl-slideshow An advanced 2D slideshow with WebGL, provides a variety of beautiful effects with GLSL power. Shaders are forked from https://gl-transiti

Akihiro Oyamada 68 Nov 28, 2022
Javascript library to draw and animate images on hover

Hover effect Javascript library to draw and animate images on hover. If this project help you, you like this library or you just want to thank me, you

Robin Delaporte 1.5k Dec 23, 2022
A tiny javascript library for obfuscating and revealing text in DOM elements

baffle.js A tiny javascript library for obfuscating and revealing text in DOM elements. camwiegert.github.io/baffle ~1.8kb gzipped ⚡ Dependency-free ?

Cam Wiegert 1.7k Dec 26, 2022
A JavaScript Typing Animation Library

Live Demo | View All Demos | View Full Docs | mattboldt.com Typed.js is a library that types. Enter in any string, and watch it type at the speed you'

Matt Boldt 12.6k Dec 31, 2022
Lightweight and fast Particle library written in JavaScript

Spark Particles Lightweight and fast Particle library written in JavaScript Zero Dependencies! Basic example Installation npm i spark-particles --save

Yury Petrov 11 May 9, 2022
A lightweight, efficient and easy-to-use Canvas library for building some cool particle effects.

JParticles · 中文 | English 官网:jparticles.js.org 特效列表 粒子运动 波纹运动 波纹进度条 雪花飘落 线条动画 介绍 JParticles(JavaScript Particles 的缩写)是一款基于 Canvas 的不依赖于其他库的轻量级 JavaScr

花祁 466 Dec 27, 2022
Javascript library to generate an infinite stream or a burst of image based particles on HTML canvas.

spxparticles Stream or a burst of image particles on HTML canvas Simple Javascript library for generating an infinine stream or a burst of image based

Tuomo Kulomaa 3 Dec 3, 2020
A JavaScript library for advanced 2D slideshow with WebGL, that provides variety of beautiful effects

gl-slideshow An advanced 2D slideshow with WebGL, provides a variety of beautiful effects with GLSL power. Shaders are forked from https://gl-transiti

Akihiro Oyamada 69 Jan 1, 2023
A library for pretty shadows.

shine.js A library for pretty shadows. See the working demo at http://bigspaceship.github.io/shine.js/. Get Started Install using bower: bower install

Big Spaceship 2.2k Dec 23, 2022
Pretty-print-json - 🦋 Pretty-print JSON data into HTML to indent and colorize (written in TypeScript)

pretty-print-json Pretty-print JSON data into HTML to indent and colorize (written in TypeScript) 1) Try It Out Interactive online tool to format JSON

Center Key 87 Dec 30, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022