85 lines
27 KiB
JSON
85 lines
27 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "react-native-svg@https://github.com/expo/react-native-svg/archive/5.5.1-exp.1.tar.gz",
|
|
"scope": null,
|
|
"escapedName": "react-native-svg",
|
|
"name": "react-native-svg",
|
|
"rawSpec": "https://github.com/expo/react-native-svg/archive/5.5.1-exp.1.tar.gz",
|
|
"spec": "https://github.com/expo/react-native-svg/archive/5.5.1-exp.1.tar.gz",
|
|
"type": "remote"
|
|
},
|
|
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/expo"
|
|
]
|
|
],
|
|
"_from": "https://github.com/expo/react-native-svg/archive/5.5.1-exp.1.tar.gz",
|
|
"_id": "react-native-svg@5.5.1",
|
|
"_inCache": true,
|
|
"_location": "/react-native-svg",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "react-native-svg@https://github.com/expo/react-native-svg/archive/5.5.1-exp.1.tar.gz",
|
|
"scope": null,
|
|
"escapedName": "react-native-svg",
|
|
"name": "react-native-svg",
|
|
"rawSpec": "https://github.com/expo/react-native-svg/archive/5.5.1-exp.1.tar.gz",
|
|
"spec": "https://github.com/expo/react-native-svg/archive/5.5.1-exp.1.tar.gz",
|
|
"type": "remote"
|
|
},
|
|
"_requiredBy": [
|
|
"/expo"
|
|
],
|
|
"_resolved": "https://github.com/expo/react-native-svg/archive/5.5.1-exp.1.tar.gz",
|
|
"_shasum": "0c6e373dbe63cfcbdd465f5b2965ebe011c8962f",
|
|
"_shrinkwrap": null,
|
|
"_spec": "react-native-svg@https://github.com/expo/react-native-svg/archive/5.5.1-exp.1.tar.gz",
|
|
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/expo",
|
|
"bugs": {
|
|
"url": "https://github.com/magicismight/react-native-svg/issues"
|
|
},
|
|
"dependencies": {
|
|
"color": "^2.0.1",
|
|
"lodash": "^4.16.6"
|
|
},
|
|
"description": "SVG library for react-native",
|
|
"devDependencies": {
|
|
"babel-eslint": "^6.1.2",
|
|
"eslint": "^2.13.1",
|
|
"eslint-plugin-react": "^4.3.0",
|
|
"react": "16.0.0-beta.5",
|
|
"react-native": "^0.49.0"
|
|
},
|
|
"homepage": "https://github.com/magicismight/react-native-svg#readme",
|
|
"keywords": [
|
|
"react-component",
|
|
"react-native",
|
|
"ios",
|
|
"android",
|
|
"SVG",
|
|
"ART",
|
|
"VML",
|
|
"gradient"
|
|
],
|
|
"license": "MIT",
|
|
"main": "./index.js",
|
|
"name": "react-native-svg",
|
|
"nativePackage": true,
|
|
"optionalDependencies": {},
|
|
"peerDependencies": {
|
|
"react-native": ">=0.50.0",
|
|
"react": "*",
|
|
"prop-types": "^15.5.8"
|
|
},
|
|
"readme": "## react-native-svg\n\n[![Version](https://img.shields.io/npm/v/react-native-svg.svg)](https://www.npmjs.com/package/react-native-svg)\n[![NPM](https://img.shields.io/npm/dm/react-native-svg.svg)](https://www.npmjs.com/package/react-native-svg)\n\n`react-native-svg` is built to provide a SVG interface to react native on both iOS and Android.\n\n[Check out the demo](https://getexponent.com/@rncommunity/react-native-svg-examples).\n\n## Features\n\n1. Supports most SVG elements and properties (Rect, Circle, Line, Polyline, Polygon, G ...).\n2. Easy to convert SVG code into ReactNative code.\n\n### Installation\n\n#### Automatic\n\n*With Expo, this is pre-installed. Jump ahead to [Usage](#Usage)*\n\n1. Install library from `npm`\n\n ```bash\n npm install react-native-svg --save\n ```\n \n # NOTICE:\n \n - react-native-svg >= 3.2.0 only supports react-native >= 0.29.0\n - react-native-svg >= 4.2.0 only supports react-native >= 0.32.0\n - react-native-svg >= 4.3.0 only supports react-native >= 0.33.0\n - react-native-svg >= 4.4.0 only supports react-native >= 0.38.0 and react >= 15.4.0\n - react-native-svg >= 4.5.0 only supports react-native >= 0.40.0 and react >= 15.4.0\n - react-native-svg >= 5.1.8 only supports react-native >= 0.44.0 and react == 16.0.0-alpha.6\n - react-native-svg >= 5.2.0 only supports react-native >= 0.45.0 and react == 16.0.0-alpha.12\n - react-native-svg >= 5.3.0 only supports react-native >= 0.46.0 and react == 16.0.0-alpha.12\n - react-native-svg >= 5.4.1 only supports react-native >= 0.47.0 and react == 16.0.0-alpha.12\n - react-native-svg >= 5.5.1 only supports react-native >= 0.50.0 and react == 16.0.0\n\n2. Link native code\n\n ```bash\n react-native link react-native-svg\n ```\n\n Or use `rnpm` instead:\n\n ```bash\n rnpm link react-native-svg\n ```\n \n#### Manual\n\n##### Android\n\n1. `npm install react-native-svg --save`\n\n2. Append the following lines to `android/settings.gradle`:\n\n\t```\n\tinclude ':react-native-svg'\n\tproject(':react-native-svg').projectDir = new File(rootProject.projectDir, \t'../node_modules/react-native-svg/android')\n\t```\n \n3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\n\n\t```\n compile project(':react-native-svg')\n\t```\n\n4. Open up `android/app/src/main/java/[...]/MainApplication.java\n - Add `import com.horcrux.svg.SvgPackage;` to the imports at the top of the file\n - Add `new SvgPackage()` to the list returned by the `getPackages()` method. Add a comma to the previous item if there's already something there.\n \n\n### <a name=\"Usage\">Usage</a>\n\nHere's a simple example. To render output like this:\n\n![SVG example](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/svg.png)\n\nUse the following code:\n\n```javascript\nimport Svg,{\n Circle,\n Ellipse,\n G,\n LinearGradient,\n RadialGradient,\n Line,\n Path,\n Polygon,\n Polyline,\n Rect,\n Symbol,\n Text,\n Use,\n Defs,\n Stop\n} from 'react-native-svg';\n\nclass SvgExample extends Component {\n render() {\n return (\n <Svg\n height=\"100\"\n width=\"100\"\n >\n <Circle\n cx=\"50\"\n cy=\"50\"\n r=\"45\"\n stroke=\"blue\"\n strokeWidth=\"2.5\"\n fill=\"green\"\n />\n <Rect\n x=\"15\"\n y=\"15\"\n width=\"70\"\n height=\"70\"\n stroke=\"red\"\n strokeWidth=\"2\"\n fill=\"yellow\"\n />\n </Svg>\n );\n }\n}\n```\n\n[Try this on Snack](https://snack.expo.io/r1hCVAaEZ)\n\n### Common props:\n\nName | Default | Description\n----------------|------------|--------------\nfill | '#000' | The fill prop refers to the color inside the shape.\nfillOpacity | 1 | This prop specifies the opacity of the color or the content the current object is filled with.\nfillRule | nonzero | The fillRule prop determines what side of a path is inside a shape, which determines how fill will paint the shape, can be `nonzero` or `evenodd` \nstroke | 'none' | The stroke prop controls how the outline of a shape appears.\nstrokeWidth | 1 | The strokeWidth prop specifies the width of the outline on the current object.\nstrokeOpacity | 1 | The strokeOpacity prop specifies the opacity of the outline on the current object.\nstrokeLinecap | 'square' | The strokeLinecap prop specifies the shape to be used at the end of open subpaths when they are stroked. Can be either `'butt'`, `'square'` or `'round'`.\nstrokeLinejoin | 'miter' | The strokeLinejoin prop specifies the shape to be used at the corners of paths or basic shapes when they are stroked. Can be either `'miter'`, `'bevel'` or `'round'`.\nstrokeDasharray | [] | The strokeDasharray prop controls the pattern of dashes and gaps used to stroke paths.\nstrokeDashoffset| null | The strokeDashoffset prop specifies the distance into the dash pattern to start the dash.\nx | 0 | Translate distance on x-axis.\ny | 0 | Translate distance on y-axis.\nrotate | 0 | Rotation degree value on the current object.\nscale | 1 | Scale value on the current object.\norigin | 0, 0 | Transform origin coordinates for the current object.\noriginX | 0 | Transform originX coordinates for the current object.\noriginY | 0 | Transform originY coordinates for the current object.\n\n\n### Supported elements:\n\n#### Svg\n\n```html\n<Svg\n height=\"100\"\n width=\"100\"\n>\n <Rect x=\"0\" y=\"0\" width=\"100\" height=\"100\" fill=\"black\" />\n <Circle cx=\"50\" cy=\"50\" r=\"30\" fill=\"yellow\" />\n <Circle cx=\"40\" cy=\"40\" r=\"4\" fill=\"black\" />\n <Circle cx=\"60\" cy=\"40\" r=\"4\" fill=\"black\" />\n <Path d=\"M 40 60 A 10 10 0 0 0 60 60\" stroke=\"black\" />\n</Svg>\n```\n\n### Rect\n\nThe <Rect> element is used to create a rectangle and variations of a rectangle shape:\n\n\n```html\n<Svg\n width=\"200\"\n height=\"60\"\n>\n <Rect\n x=\"25\"\n y=\"5\"\n width=\"150\"\n height=\"50\"\n fill=\"rgb(0,0,255)\"\n strokeWidth=\"3\"\n stroke=\"rgb(0,0,0)\"\n />\n</Svg>\n```\n\n![Rect](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/rect.png)\n\n Code explanation:\n\n * The width and height props of the <Rect> element define the height and the width of the rectangle.\n * The x prop defines the left position of the rectangle (e.g. x=\"25\" places the rectangle 25 px from the left margin).\n * The y prop defines the top position of the rectangle (e.g. y=\"5\" places the rectangle 5 px from the top margin).\n\n##### Circle\n\nThe <Circle> element is used to create a circle:\n\n```html\n<Svg\n height=\"100\"\n width=\"100\"\n>\n <Circle\n cx=\"50\"\n cy=\"50\"\n r=\"50\"\n fill=\"pink\"\n />\n</Svg>\n```\n\n![Rect](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/circle.png)\n\n Code explanation:\n\n * The cx and cy props define the x and y coordinates of the center of the circle. If cx and cy are omitted, the circle's center is set to (0,0)\n * The r prop defines the radius of the circle\n\n#### Ellipse\n\nThe <Ellipse> element is used to create an ellipse.\n\nAn ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius.\n\n```html\n<Svg\n height=\"100\"\n width=\"110\"\n>\n <Ellipse\n cx=\"55\"\n cy=\"55\"\n rx=\"50\"\n ry=\"30\"\n stroke=\"purple\"\n strokeWidth=\"2\"\n fill=\"yellow\"\n />\n</Svg>\n```\n![Rect](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/ellipse.png)\n\nCode explanation:\n\n* The cx prop defines the x coordinate of the center of the ellipse\n* The cy prop defines the y coordinate of the center of the ellipse\n* The rx prop defines the horizontal radius\n* The ry prop defines the vertical radius\n\n#### Line\n\nThe <Line> element is an SVG basic shape, used to create a line connecting two points.\n\n```html\n<Svg\n height=\"100\"\n width=\"100\"\n>\n <Line\n x1=\"0\"\n y1=\"0\"\n x2=\"100\"\n y2=\"100\"\n stroke=\"red\"\n strokeWidth=\"2\"\n />\n</Svg>\n```\n\n![Rect](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/line.png)\n\nCode explanation:\n\n* The x1 prop defines the start of the line on the x-axis.\n* The y1 prop defines the start of the line on the y-axis.\n* The x2 prop defines the end of the line on the x-axis.\n* The y2 prop defines the end of the line on the y-axis.\n\n#### Polygon\n\nThe <Polygon> element is used to create a graphic that contains at least three sides. Polygons are made of straight lines, and the shape is \"closed\" (all the lines connect up).\n\n```html\n<Svg\n height=\"100\"\n width=\"100\"\n>\n <Polygon\n points=\"40,5 70,80 25,95\"\n fill=\"lime\"\n stroke=\"purple\"\n strokeWidth=\"1\"\n />\n</Svg>\n```\n\n![Rect](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/polygon.png)\n\nCode explanation:\n\n* The points prop defines the x and y coordinates for each corner of the polygon\n\n#### Polyline\n\nThe <Polyline> element is used to create any shape that consists of only straight lines:\n\n```html\n<Svg\n height=\"100\"\n width=\"100\"\n>\n <Polyline\n points=\"10,10 20,12 30,20 40,60 60,70 95,90\"\n fill=\"none\"\n stroke=\"black\"\n strokeWidth=\"3\"\n />\n</Svg>\n```\n\n![Rect](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/polyline.png)\n\nCode explanation:\n\n* The points prop defines the x and y coordinates for each point of the polyline\n\n#### Path\n\nThe <Path> element is used to define a path.\n\nThe following commands are available for path data:\n\n * M = moveto\n * L = lineto\n * H = horizontal lineto\n * V = vertical lineto\n * C = curveto\n * S = smooth curveto\n * Q = quadratic Bézier curve\n * T = smooth quadratic Bézier curveto\n * A = elliptical Arc\n * Z = closepath\n\n`Note:` All of the commands above can also be expressed with lower letters. Capital letters means absolutely positioned, lower cases means relatively positioned.\n\n```html\n<Svg\n height=\"100\"\n width=\"100\"\n>\n <Path\n d=\"M25 10 L98 65 L70 25 L16 77 L11 30 L0 4 L90 50 L50 10 L11 22 L77 95 L20 25\"\n fill=\"none\"\n stroke=\"red\"\n />\n</Svg>\n```\n\n![Rect](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/path.png)\n\n\n#### Text\n\nThe <Text> element is used to define text.\n\n```html\n<Svg\n height=\"60\"\n width=\"200\"\n>\n <Text\n fill=\"none\"\n stroke=\"purple\"\n fontSize=\"20\"\n fontWeight=\"bold\"\n x=\"100\"\n y=\"20\"\n textAnchor=\"middle\"\n >STROKED TEXT</Text>\n</Svg>\n```\n\n![Text](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/text.png)\n\n#### TSpan\n\nThe <TSpan> element is used to draw multiple lines of text in SVG. Rather than having to position each line of text absolutely, the <TSpan> element makes it possible to position a line of text relatively to the previous line of text.\n\n```html\n<Svg\n height=\"160\"\n width=\"200\"\n>\n <Text y=\"20\" dx=\"5 5\">\n <TSpan x=\"10\" >tspan line 1</TSpan>\n <TSpan x=\"10\" dy=\"15\">tspan line 2</TSpan>\n <TSpan x=\"10\" dx=\"10\" dy=\"15\">tspan line 3</TSpan>\n </Text>\n <Text x=\"10\" y=\"60\" fill=\"red\" fontSize=\"14\">\n <TSpan dy=\"5 10 20\" >12345</TSpan>\n <TSpan fill=\"blue\" dy=\"15\" dx=\"0 5 5\">\n <TSpan>6</TSpan>\n <TSpan>7</TSpan>\n </TSpan>\n <TSpan dx=\"0 10 20\" dy=\"0 20\" fontWeight=\"bold\" fontSize=\"12\">89a</TSpan>\n </Text>\n <Text y=\"140\" dx=\"0 5 5\" dy=\"0 -5 -5\">delta on text</Text>\n</Svg>\n```\n\n![TSpan](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/tspan.png)\n\n#### TextPath\n\nIn addition to text drawn in a straight line, SVG also includes the ability to place text along the shape of a <Path> element. To specify that a block of text is to be rendered along the shape of a <Path>, include the given text within a <TextPath> element which includes an href attribute with a reference to a <Path> element.\n\n```html\n<Svg\n height=\"100\"\n width=\"200\"\n>\n <Defs>\n <Path\n id=\"path\"\n d={path}\n />\n </Defs>\n <G y=\"20\">\n <Text\n fill=\"blue\"\n\n >\n <TextPath href=\"#path\" startOffset=\"-10%\">\n We go up and down,\n <TSpan fill=\"red\" dy=\"5,5,5\">then up again</TSpan>\n </TextPath>\n </Text>\n <Path\n d={path}\n fill=\"none\"\n stroke=\"red\"\n strokeWidth=\"1\"\n />\n </G>\n</Svg>\n```\n\n![TextPath](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/text-path.png)\n\n#### G\n\nThe <G> element is a container used to group other SVG elements. Transformations applied to the g element are performed on all of its child elements, and any of its props are inherited by its child elements. It can also group multiple elements to be referenced later with the [<Use />](#use) element.\n\n```html\n<Svg\n height=\"100\"\n width=\"200\"\n>\n <G\n rotate=\"50\"\n origin=\"100, 50\"\n >\n <Line\n x1=\"60\"\n y1=\"10\"\n x2=\"140\"\n y2=\"10\"\n stroke=\"#060\"\n />\n\n <Rect\n x=\"60\"\n y=\"20\"\n height=\"50\"\n width=\"80\"\n stroke=\"#060\"\n fill=\"#060\"\n />\n\n <Text\n x=\"100\"\n y=\"75\"\n stroke=\"#600\"\n fill=\"#600\"\n textAnchor=\"middle\"\n >\n Text grouped with shapes</Text>\n </G>\n</Svg>\n```\n![G](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/g.png)\n\n#### Use\n\nThe <Use> element can reuse an SVG shape from elsewhere in the SVG document, including <G> elements and <Symbol> elements. The reused shape can be defined inside the [<Defs>](#defs) element (which makes the shape invisible until used) or outside.\n\n```html\n<Svg\n height=\"100\"\n width=\"300\"\n>\n <Defs>\n <G id=\"shape\">\n <G>\n <Circle cx=\"50\" cy=\"50\" r=\"50\" />\n <Rect x=\"50\" y=\"50\" width=\"50\" height=\"50\" />\n <Circle cx=\"50\" cy=\"50\" r=\"5\" fill=\"blue\" />\n </G>\n </G>\n </Defs>\n <Use href=\"#shape\" x=\"20\" y=\"0\"/>\n <Use href=\"#shape\" x=\"170\"y=\"0\" />\n</Svg>\n```\n\nThis example shows a <G> element defined inside a [<Defs>](#defs) element. This makes the <G> invisible unless referenced by a <Use> element.\n\nBefore the <G> element can be referenced, it must have an ID set on it via its id prop. The <Use> element references the <G> element via its `href` prop. Notice the # in front of the ID in the prop value.\n\nThe <Use> element specifies where to show the reused shapes via its x and y props. Notice that the shapes inside the <G> element are located at 0,0. That is done because their position is added to the position specified in the <Use> element.\n\n![use](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/use.png)\n\n\n#### Symbol\n\nThe SVG <Symbol> element is used to define reusable symbols. The shapes nested inside a <Symbol> are not displayed unless referenced by a <Use> element.\n\n```html\n<Svg\n height=\"150\"\n width=\"110\"\n>\n <Symbol id=\"symbol\" viewBox=\"0 0 150 110\" width=\"100\" height=\"50\">\n <Circle cx=\"50\" cy=\"50\" r=\"40\" strokeWidth=\"8\" stroke=\"red\" fill=\"red\"/>\n <Circle cx=\"90\" cy=\"60\" r=\"40\" strokeWidth=\"8\" stroke=\"green\" fill=\"white\"/>\n </Symbol>\n\n <Use\n href=\"#symbol\"\n x=\"0\"\n y=\"0\"\n />\n <Use\n href=\"#symbol\"\n x=\"0\"\n y=\"50\"\n width=\"75\"\n height=\"38\"\n />\n <Use\n href=\"#symbol\"\n x=\"0\"\n y=\"100\"\n width=\"50\"\n height=\"25\"\n />\n</Svg>\n```\n\n![Symbol](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/symbol.png)\n\n#### Defs\n\nThe <Defs> element is used to embed definitions that can be reused inside an SVG image. For instance, you can group SVG shapes together and reuse them as a single shape.\n\n#### Image\n\nThe <Image> element allows a raster image to be included in an Svg componenet.\n\n```html\n<Svg\n height=\"100\"\n width=\"100\"\n>\n <Defs>\n <ClipPath id=\"clip\">\n <Circle cx=\"50%\" cy=\"50%\" r=\"40%\"/>\n </ClipPath>\n </Defs>\n <Rect\n x=\"0\"\n y=\"0\"\n width=\"100%\"\n height=\"100%\"\n fill=\"red\"\n />\n <Rect\n x=\"5%\"\n y=\"5%\"\n width=\"50%\"\n height=\"90%\"\n />\n\n <Image\n x=\"5%\"\n y=\"5%\"\n width=\"50%\"\n height=\"90%\"\n preserveAspectRatio=\"xMidYMid slice\"\n opacity=\"0.5\"\n href={require('../image.jpg')}\n clipPath=\"url(#clip)\"\n />\n <Text\n x=\"50\"\n y=\"50\"\n textAnchor=\"middle\"\n fontWeight=\"bold\"\n fontSize=\"16\"\n fill=\"blue\"\n >HOGWARTS</Text>\n</Svg>\n```\n\n![Image](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/image.png)\n\n#### ClipPath\n\nThe <ClipPath> SVG element defines a clipping path. A clipping path is used/referenced using the clipPath property\n\n```html\n<Svg\n height=\"100\"\n width=\"100\"\n>\n <Defs>\n <RadialGradient id=\"grad\" cx=\"50%\" cy=\"50%\" rx=\"50%\" ry=\"50%\" fx=\"50%\" fy=\"50%\" gradientUnits=\"userSpaceOnUse\">\n <Stop\n offset=\"0%\"\n stopColor=\"#ff0\"\n stopOpacity=\"1\"\n />\n <Stop\n offset=\"100%\"\n stopColor=\"#00f\"\n stopOpacity=\"1\"\n />\n </RadialGradient>\n <ClipPath id=\"clip\">\n <G scale=\"0.9\" x=\"10\">\n <Circle cx=\"30\" cy=\"30\" r=\"20\"/>\n <Ellipse cx=\"60\" cy=\"70\" rx=\"20\" ry=\"10\" />\n <Rect x=\"65\" y=\"15\" width=\"30\" height=\"30\" />\n <Polygon points=\"20,60 20,80 50,70\" />\n <Text\n x=\"50\"\n y=\"30\"\n fontSize=\"32\"\n fonWeight=\"bold\"\n textAnchor=\"middle\"\n scale=\"1.2\"\n >Q</Text>\n </G>\n </ClipPath>\n </Defs>\n <Rect\n x=\"0\"\n y=\"0\"\n width=\"100\"\n height=\"100\"\n fill=\"url(#grad)\"\n clipPath=\"url(#clip)\"\n />\n</Svg>\n```\n\n![ClipPath](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/clip-path.png)\n\n#### LinearGradient\n\nThe <LinearGradient> element is used to define a linear gradient.\nThe <LinearGradient> element must be nested within a [<Defs>](#defs) tag. The [<Defs>](#defs) tag is short for definitions and contains definition of special elements (such as gradients).\n\nLinear gradients can be defined as horizontal, vertical or angular gradients:\n\n * Horizontal gradients are created when y1 and y2 are equal and x1 and x2 differ\n * Vertical gradients are created when x1 and x2 are equal and y1 and y2 differ\n * Angular gradients are created when x1 and x2 differ and y1 and y2 differ\n\n```html\n<Svg\n height=\"150\"\n width=\"300\"\n>\n <Defs>\n <LinearGradient id=\"grad\" x1=\"0\" y1=\"0\" x2=\"170\" y2=\"0\">\n <Stop offset=\"0\" stopColor=\"rgb(255,255,0)\" stopOpacity=\"0\" />\n <Stop offset=\"1\" stopColor=\"red\" stopOpacity=\"1\" />\n </LinearGradient>\n </Defs>\n <Ellipse cx=\"150\" cy=\"75\" rx=\"85\" ry=\"55\" fill=\"url(#grad)\" />\n</Svg>\n```\n\nCode explanation:\n\n * The id prop of the <LinearGradient> tag defines a unique name for the gradient\n * The x1, x2, y1,y2 props of the <LinearGradient> tag define the start and end position of the gradient\n * The color range for a gradient can be composed of two or more colors. Each color is specified with a <Stop> tag. The offset prop is used to define where the gradient color begin and end\n * The fill prop links the ellipse element to the gradient\n\n![LinearGradient](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/lineargradient.png)\n\n*NOTICE:*\nLinearGradient also supports percentage as prop:\n```html\n<LinearGradient id=\"grad\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\">\n <Stop offset=\"0%\" stopColor=\"rgb(255,255,0)\" stopOpacity=\"0\" />\n <Stop offset=\"100%\" stopColor=\"red\" stopOpacity=\"1\" />\n</LinearGradient>\n```\nThis result is same as the example before. But it's recommend to use exact number instead; it has performance advantages over using percentages.\n\n#### RadialGradient\n\nThe <RadialGradient> element is used to define a radial gradient. The <RadialGradient> element must be nested within a [<Defs>](#defs) tag. The [<Defs>](#defs) tag is short for definitions and contains definition of special elements (such as gradients).\n\n```html\n<Svg\n height=\"150\"\n width=\"300\"\n>\n <Defs>\n <RadialGradient id=\"grad\" cx=\"150\" cy=\"75\" rx=\"85\" ry=\"55\" fx=\"150\" fy=\"75\" gradientUnits=\"userSpaceOnUse\">\n <Stop\n offset=\"0\"\n stopColor=\"#ff0\"\n stopOpacity=\"1\"\n />\n <Stop\n offset=\"1\"\n stopColor=\"#83a\"\n stopOpacity=\"1\"\n />\n </RadialGradient>\n </Defs>\n <Ellipse cx=\"150\" cy=\"75\" rx=\"85\" ry=\"55\" fill=\"url(#grad)\" />\n</Svg>\n```\n\nCode explanation:\n\n * The id prop of the <radialGradient> tag defines a unique name for the gradient\n * The cx, cy and r props define the outermost circle and the fx and fy define the innermost circle\n * The color range for a gradient can be composed of two or more colors. Each color is specified with a <stop> tag. The offset prop is used to define where the gradient color begin and end\n * The fill prop links the ellipse element to the gradient\n\n![RadialGradient](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/radialgradient.png)\n\n#### Touch Events\n\nTouch events are supported in react-native-svg. These include:\n\n - `disabled`\n - `onPress`\n - `onPressIn`\n - `onPressOut`\n - `onLongPress`\n - `delayPressIn`\n - `delayPressOut`\n - `delayLongPress`\n\nYou can use these events to provide interactivity to your react-native-svg components.\n\n```html\n<Circle\n cx=\"50%\"\n cy=\"50%\"\n r=\"38%\"\n fill=\"red\"\n onPress={() => alert('Press on Circle')}\n/>\n```\n\n![TouchEvents](https://raw.githubusercontent.com/react-native-community/react-native-svg/master/screenShoots/touchevents.gif)\n\nFor more examples of touch in action, checkout the [TouchEvents.js examples](https://github.com/magicismight/react-native-svg-example/blob/master/examples/TouchEvents.js).\n\n### Run example:\n\n```bash\n\ngit clone https://github.com/magicismight/react-native-svg-example.git\ncd react-native-svg-example\nnpm i\n\n# run Android: react-native run-android\n# run iOS: react-native run-ios\n\n```\n\n\n### TODO:\n1. Add Native method for elements.\n2. Pattern element.\n3. Mask element.\n4. Marker element.\n5. Load Image from URL.\n6. Transform prop support.\n\n### Known issues:\n1. Unable to apply focus point of RadialGradient on Android.\n\n### Thanks:\n\n* [w3schools.com SVG Tutorial](http://www.w3schools.com/graphics/svg_intro.asp)\n* [SVG Tutorial](http://tutorials.jenkov.com/svg/index.html)\n* [MDN](https://developer.mozilla.org/en/docs/Web/SVG)\n",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/magicismight/react-native-svg.git"
|
|
},
|
|
"scripts": {
|
|
"lint": "eslint ./"
|
|
},
|
|
"version": "5.5.1"
|
|
}
|