Giter Site home page Giter Site logo

mooyoul / geo-pattern Goto Github PK

View Code? Open in Web Editor NEW
37.0 37.0 2.0 2.16 MB

Create beautiful generative geometric background images from a string ✨ TypeScript port of jasonlong/geo_pattern. Supports both Node.js and Browser.

Home Page: https://mooyoul.github.io/geo-pattern/

License: MIT License

TypeScript 88.36% HTML 4.65% JavaScript 7.00%
background design image pattern patterns

geo-pattern's Introduction

@prescott/geo-pattern

Build Status Github Pages Status Semantic Release enabled npm bundle size (minified, gzipped) Renovate enabled MIT license

Cover Image

Create beautiful generative geometric background images from a string ✨

@prescott/geo-pattern has visual regression tests and perfectly matches to the original geo-pattern gem outputs!

Live Demo

https://mooyoul.github.io/geo-pattern/

E2E Test Status

Browser Status Build
IE 11 BrowserStack Status ES5 Build
Edge Latest BrowserStack Status ES6 Build
Firefox Latest BrowserStack Status ES6 Build
Edge 15 BrowserStack Status ES6 Build
Chrome Latest BrowserStack Status ES6 Build, Native Build
macOS Safari Latest BrowserStack Status ES6 Build
iOS Safari Latest BrowserStack Status ES6 Build
iPadOS Safari Latest BrowserStack Status ES6 Build
Android Tab Chrome Latest BrowserStack Status ES6 Build
Android Chrome Latest BrowserStack Status ES6 Build

Getting Started

$ npm install @prescott/geo-pattern --save

API

generate(params: GeneratePatternParams) => Promise<Pattern>

interface GeneratePatternParams {
  input: string;
  patterns?: string[];
  color?: string;
  baseColor?: string;
}

interface Pattern {
  background?: Background;
  structure?: Structure;
  width: number;
  height: number;
  toSVG(): string;
  toDataURL(): string;
}
import { generate } from "@prescott/geo-pattern";
const pattern = await generate({ input: "lorem ipsum" });
const svg = pattern.toSVG();
const dataUri = pattern.toDataURL();

Browser Builds

@prescott/geo-pattern provides browser builds.

All browser builds require Promise, Map, Set, and TextEncoder. You should polyfill missing features if you need to support legacy browsers.

Currently, There are four types of Browser Build.

Type Path Notes
Default (CommonJS) dist/browser Use this build if you're using bundler like Webpack.
ES5 (UMD) browser/es5 Use this build if you want to support legacy browsers (e.g. IE 11)
ES6 (UMD) browser/es6 Use this build if you want to support modern browers only
Native (UMD) browser/native Use this build if you want to support cutting-edge browsers only

About "Native" Build

Native build uses browser built-in hash function (Crypto Subtle API)

Use @prescott/geo-pattern using unpkg

<!-- ES6 Target Build -->
<script type="text/javascript" src="https://unpkg.com/@prescott/geo-pattern/browser/es6"></script>

<!-- Native Build -->
<script type="text/javascript" src="https://unpkg.com/@prescott/geo-pattern/browser/native"></script>

<!-- ES5 Target Build (for Compat, requires Promise, Map, Set, and TextEncoder polyfill -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.6.5/core.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/@prescott/geo-pattern/browser/es5"></script>

Wishlists

  • Smaller library size

Changelog

See CHANGELOG.

Testing

$ npm run test:spec # for unit test
$ npm run test:e2e:node # for Node.js integration test
$ npm run test:e2e:browser # for Browser integration test using locally installed chrome
$ npm run test:e2e:browserstack # for Browser compability test using BrowserStack

BrowserStack Logo

@prescott/geo-pattern uses BrowserStack for compatibility testing.

Build

$ npm run build

Related

TBD

Diagram

Dependency Graph

Dependency Graph

Credits

geo-pattern was originally wrote by Jason Long. It can't be done without his efforts.

Kudos for his amazing work! <3

License

MIT

See full license on mooyoul.mit-license.org

geo-pattern's People

Contributors

mooyoul avatar renovate-bot avatar renovate[bot] avatar semantic-release-bot 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

Watchers

 avatar  avatar  avatar

Forkers

rheehot safia

geo-pattern's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @types/common-tags to v1.8.4
  • chore(deps): update dependency @types/debug to v4.1.12
  • chore(deps): update dependency @types/env-ci to v3.1.4
  • chore(deps): update dependency @types/jsdom to v21.1.6
  • chore(deps): update dependency @types/selenium-webdriver to v4.1.22
  • chore(deps): update dependency @types/sinon to v10.0.20
  • chore(deps): update dependency browserstack-local to v1.5.5
  • chore(deps): update dependency ts-node to v10.9.2
  • fix(deps): update dependency @types/color to v3.0.6
  • chore(deps): update dependency @rollup/plugin-node-resolve to v15.2.3
  • chore(deps): update dependency chai to v4.4.1 (chai, @types/chai)
  • chore(deps): update dependency execa to v7.2.0
  • chore(deps): update dependency mocha to v10.4.0 (mocha, @types/mocha)
  • chore(deps): update dependency semantic-release to v21.1.2
  • chore(deps): update webdriverio monorepo to v8.38.0 (@wdio/browserstack-service, @wdio/cli, @wdio/local-runner, @wdio/mocha-framework, @wdio/spec-reporter, @wdio/static-server-service, webdriverio)
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update actions/upload-artifact action to v4
  • chore(deps): update dependency @types/sinon to v17
  • chore(deps): update dependency chai to v5
  • chore(deps): update dependency core-js to v3
  • chore(deps): update dependency execa to v9
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency jsdom to v24
  • chore(deps): update dependency rollup to v4
  • chore(deps): update dependency sinon to v18
  • chore(deps): update peaceiris/actions-gh-pages action to v4
  • chore(deps): update semantic-release monorepo (major) (env-ci, semantic-release)
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/gh-pages.yml
  • actions/checkout v1
  • actions/setup-node v1
  • peaceiris/actions-gh-pages v3
.github/workflows/main.yml
  • actions/checkout v1
  • actions/setup-node v1
  • actions/upload-artifact v2
html
integration-test/browser/es5.html
  • core-js 2.6.11
npm
package.json
  • @types/color ^3.0.1
  • color ^3.1.2
  • tiny-sha1 ^0.2.1
  • @prescott/commitlint-preset 1.0.3
  • @prescott/semantic-release-config 1.0.1
  • @prescott/tslint-preset 1.0.1
  • @rollup/plugin-commonjs 25.0.2
  • @rollup/plugin-node-resolve 15.1.0
  • @rollup/plugin-typescript 11.1.1
  • @types/chai 4.3.5
  • @types/common-tags 1.8.1
  • @types/debug 4.1.8
  • @types/env-ci 3.1.1
  • @types/jsdom 21.1.1
  • @types/mocha 10.0.1
  • @types/node 12.20.55
  • @types/selenium-webdriver 4.1.15
  • @types/sharp 0.29.4
  • @types/sinon 10.0.15
  • @wdio/browserstack-service 8.11.2
  • @wdio/cli 8.11.2
  • @wdio/local-runner 8.11.2
  • @wdio/mocha-framework 8.11.0
  • @wdio/spec-reporter 8.11.2
  • @wdio/static-server-service 8.11.0
  • axios 1.4.0
  • browserstack-local 1.5.3
  • chai 4.3.7
  • chai-image 3.0.0
  • chromedriver 96.0.0
  • common-tags 1.8.2
  • debug 4.3.4
  • env-ci 9.1.1
  • execa 7.1.1
  • husky 8.0.3
  • jsdom 22.1.0
  • mocha 10.2.0
  • rollup 2.79.1
  • semantic-release 21.0.5
  • sharp 0.30.5
  • sinon 15.2.0
  • ts-node 10.9.1
  • tslib 2.5.3
  • tslint 6.1.3
  • typescript 4.9.5
  • wdio-chromedriver-service 8.1.1
  • webdriverio 8.11.2

  • Check this box to trigger a request for Renovate to run again on this repository

[Question] What is the difference between "baseColor" and "color"

Hello ! I am using your library in a personal project to generate nice backgrounds for my app and I am testing out some things. I can successfully generate patterns and limit the color space using the "color" parameter when generating the pattern but I don't understand what baseColordoes.

Based on this: https://github.com/mooyoul/geo-pattern/blob/master/src/color-preset.ts#L14 is it correct to assume that the baseColor is returned by default if coloris not specified ? 🤔

Cheers and thanks for porting this lib, I had my eyes on the original ruby implementation for years and I am happy I finally have a project to use it in

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

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.