Textures.js ported to React. Fully isomorphic.
Switch branches/tags
Nothing to show
Clone or download
finnfiddle Merge pull request #1 from ahmedtarek2134/master
Update Readme and Create LICENSE file
Latest commit adc9f2c Apr 17, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo/src Initial commit from nwb v0.21.5 Feb 13, 2018
src v1.4.7 Apr 17, 2018
tests v1.4.7 Apr 17, 2018
.eslintrc v1.0.1 Feb 13, 2018
.gitignore Initial commit from nwb v0.21.5 Feb 13, 2018
.travis.yml Initial commit from nwb v0.21.5 Feb 13, 2018
CONTRIBUTING.md Initial commit from nwb v0.21.5 Feb 13, 2018
LICENSE Updated README file and added a LICENSE file too Feb 27, 2018
README.md Merge branch 'master' into master Apr 17, 2018
nwb.config.js Initial commit from nwb v0.21.5 Feb 13, 2018
package-lock.json v1.4.7 Apr 17, 2018
package.json v1.4.7 Apr 17, 2018

README.md

react-svg-textures ⭐️

Textures.js in React made simple ⚡️. react-svg-textures is a port of the Textures.js library as React components with multiple options via props for easy usage!

npm version

Installation

Using Yarn:

yarn add react-svg-textures

Using NPM:

npm install react-svg-textures

Usage

import React from 'react';
import { Lines } from 'react-svg-textures';

const Texture = () => (
  <svg width={200} height={200}>
    <Lines
      id='pattern'
      strokeWidth={10}
      stroke='purple'
      size={10}
      orientation='diagonal'
      background='blue'
    />
    <circle cx={100} cy={100} r={5} fill='url(#pattern)' />
  </svg>
);

export default Texture;

Available Props Options

import PropTypes from 'prop-types';
import { Lines, Circles, Paths } from 'react-svg-textures';

Lines.propTypes = {

    // size must be a number
    size: PropTypes.number,

    // strokeWidth must be a number
    strokeWidth: PropTypes.number,

    // orientation must be a string
    orientation: PropTypes.string,

    // shapeRendering must be a string
    shapeRendering: PropTypes.string,

    // stroke must be a string
    stroke: PropTypes.string,

    // background must be a string
    background: PropTypes.string,

    // id must be a string
    id: PropTypes.string

};

Circles.propTypes = {

    // size must be a number
    size: PropTypes.number,

    // strokeWidth must be a number
    strokeWidth: PropTypes.number,

    // stroke must be a string
    stroke: PropTypes.string,

    // background must be a string
    background: PropTypes.string,

    // id must be a string
    id: PropTypes.string,

    // complement must be a boolean
    complement: PropTypes.bool,

    // radius must be a number
    radius: PropTypes.number

};

Paths.propTypes = {

    // size must be a number
    size: PropTypes.number,

    // d must be 'squares', 'nylon', 'waves', 'woven', 'caps', 'crosses' or 'hexagons'
    d: PropTypes.oneOf([
        'squares',
        'nylon',
        'waves',
        'woven',
        'caps',
        'crosses',
        'hexagons'
    ])

    // strokeWidth must be a number
    strokeWidth: PropTypes.number,

    // shapeRendering must be a string
    shapeRendering: PropTypes.string,

    // stroke must be a string
    stroke: PropTypes.string,

    // background must be a string
    background: PropTypes.string,

    // id must be a string
    id: PropTypes.string,

};

License

MIT License

Copyright (c) 2018 Finn Fitzsimons

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.