0.1.2 • Published 3 years ago

react-native-figures v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

About

react-native-figures is an attempt to streamline the implementation of various shapes for quick and easy usage. It offers an option to pass an array of figures into a container or to just manage individual shapes yourself.

Shapes

Currently react-native-figures supports the following shape types:

- Circle 
- Donut
- Square
- DiamondNarrow
- CutDiamond
- Triangle

Examples

Shapes Container style:

import React from "react";
import { View } from "react-native";
import { Shapes } from "react-native-figures";

export const Example = () => {
  return (
    <View>
      <Shapes
        figureColor="red"
        figures={[
          {
            type: "circle",
            x: "50%",
            y: "50%",
            offsetX: -100,
            offsetY: -100,
            size: 200,
          },
          {
            type: "donut",
            color: "#1F85DE",
            x: "50%",
            y: "50%",
            offsetX: 100,
            offsetY: 75,
            size: 200,
          },
          {
            type: "triangle",
            size: 100,
            x: "10%",
            y: "15%",
            rotation: 10,
          },
        ]}
      />
    </View>
  );
};

Individual Shape Components:

import React from "react";
import { View } from "react-native";
import { Circle, Triangle, DiamondNarrow } from "react-native-figures";

export const Example = () => {
  return (
    <View>
      <Circle x="50%" y="50%" offsetX={-100} offsetY={-100} size={200} />
      <Triangle x="10%" y="15%" rotation={10} />
      <DiamondNarrow x="15%" y="45%" rotation={36} />
    </View>
  );
};

Props / Options

NameOptionsNote
typeSquare, Circle, Donut, DiamondNarrow, CutDiamond, TriangleOnly used in <Shapes/> container figure objects
sizeNumberIs scale 0.0-1.0 of screen size if scaling is enabled
colorColorColor per specific shape
figureColorColorDefault color for figures
figuresLits of figures (js objects) i.e [{ type: "circle" ...},{type: "square" ...}]Only used in <Shapes/> container
offsetXNumbered offset (i.e 50, 1, -100)Is scale 0.0-1.0 of screen width if scalingOffsets is enabled
offsetYNumbered offset (i.e 51, -49, 99)Is scale 0.0-1.0 of screen height if scalingOffsets is enabled
rotationNumbered rotation in Degrees
borderRadiusNumbered size for border radiusOnly works with Square
opacityFloat between 0 and 1 (i.e 0.4)
scalingtrue/falseEnable size to be considered a scale of 0.0-1.0 of screen size. Default: false
scalingOffsetstrue/falseEnable offsets to be considered in a scale of 0.0-1.0 of screen size. Default: false
sizeBasedOffsetstrue/falseEnabled offsets based on the size of the figure. Default: false

License

MIT © Devon (tek256)