Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
gradient-generator-ui
Advanced tools
Library to create a gradient generator in vanilla-js with interactive user interface in html
Visual and interactive gradient generator
Library to create a gradient generator in vanilla-js with interactive user interface in html
yarn add gradient-generator-ui
or
npm install gradient-generator-ui
Or with CDN links
<!-- Style -->
<link rel="stylesheet" href="https://unpkg.com/gradient-generator-ui@1.0.5/dist/gradient-generator.css" crossorigin>
<!-- Script -->
<script src="https://unpkg.com/gradient-generator-ui@1.0.5/dist/gradient-generator.js" crossorigin ></script>
const gradientRoot = document.getElementById('gradient-root');
const myColorGen = new GradientGenerator({
mainElement: gradientRoot,
initialColors: [
{ colorHex: '#ff0000', position: 0 },
{ colorHex: '#00ff00', position: 50 },
{ colorHex: '#0000ff', position: 100 },
],
});
const colors1 = myColorGen.generateColors(50);
console.log(colors1); // Generate 50 colors using the first values
myColorGen.addColors(
{ colorHex: '#fafa00', position: 80 },
{ colorHex: '#001919', position: 30 }
);
const colors2 = myColorGen.generateColors(100);
console.log(colors2); // Generate 100 colors using the first values and the news
see example here
const myColorGen = new GradientGenerator();
const colors1 = myColorGen.generateColors();
console.log(colors1); // Generate 100 colors using the default values
myColorGen.addColors(
{ colorHex: '#fafa00', position: 80 },
{ colorHex: '#001919', position: 30 }
);
const colors2 = myColorGen.generateColors(100);
console.log(colors2); // Generate 100 colors using the default values and the news
See this example here
const gradientRoot = document.getElementById('gradient-root');
const myColorGen = new GradientGenerator({ mainElement: gradientRoot });
const myGenManager = myColorGen.createUIManager({ keepChanges: false });
const addBtn = document.getElementById('add');
addBtn.addEventListener('click', () => {
myGenManager.setAddMode();
});
const cancelBtn = document.getElementById('cancel');
cancelBtn.addEventListener('click', () => {
myGenManager.cancelAddMode();
});
See this example here
Constructor Options:
mainElement
(default: null) - pass a empty HTMLElement root of the gradient.initialColors
(default: [
{ colorHex: '#ff0000', position: 10 },
{ colorHex: '#ffff00', position: 40 },
{ colorHex: '#00ff77', position: 70 } ]) - pass an array of objects with a hexadecimal color and relative position (0 - 100)generateColors(size = 100)
- Generate the intermediate colors accord an expected number of colors generated
addColors(...{ colorHex, position })
- Add one or many new intermediate color with ther respective relative position
getGradientColors()
- Get the gradient generator colors ordered by position
setGradientColors([{colorHex, position}])
- Reset the gradient generator colors base
createUIManager(ManagerConstructorOptions)
- Get a new Generator Manager with this generator to interact with the user interface.
Constructor Options:
generator
: GradientGenerator - Pass the generator to managekeepChanges
(default: true) - keep the changes on the interface in each interactionactivateAddMode()
- Activates the interaction with the user interface to add a new element on click on the main element
cancelAddMode()
- Deactivate the interaction with the user interface to add new elements
restoreColors()
- if keepChanges
is false, it restores the colors of the last restore point
saveColors()
- Create a new restore point with current colors
Edison Peñuela – @EdisonPeM – edisonpe961206@hotmail.com
Distributed under the MIT license. See LICENSE
for more information.
git checkout -b feature/fooBar
)git commit -am 'Add some fooBar'
)git push origin feature/fooBar
)FAQs
Library to create a gradient generator in vanilla-js with interactive user interface in html
The npm package gradient-generator-ui receives a total of 0 weekly downloads. As such, gradient-generator-ui popularity was classified as not popular.
We found that gradient-generator-ui demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.