Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-zdog

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-zdog

React-fiber renderer for zdog

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is react-zdog?

react-zdog is a React wrapper for Zdog, a pseudo-3D engine for canvas and SVG. It allows you to create and animate 3D-like illustrations using a simple and intuitive API.

What are react-zdog's main functionalities?

Creating Shapes

This code demonstrates how to create a basic shape using react-zdog. The `Shape` component is used to draw a simple shape with a specified stroke and color.

```jsx
import React from 'react';
import { Illustration, Shape } from 'react-zdog';

const MyShape = () => (
  <Illustration>
    <Shape
      stroke={20}
      color="#636"
    />
  </Illustration>
);

export default MyShape;
```

Animating Shapes

This code demonstrates how to animate a shape using react-zdog. The `useRef` and `useEffect` hooks are used to rotate the shape continuously.

```jsx
import React, { useRef, useEffect } from 'react';
import { Illustration, Shape } from 'react-zdog';

const AnimatedShape = () => {
  const shapeRef = useRef(null);

  useEffect(() => {
    const animate = () => {
      shapeRef.current.rotate.y += 0.03;
      requestAnimationFrame(animate);
    };
    animate();
  }, []);

  return (
    <Illustration>
      <Shape
        ref={shapeRef}
        stroke={20}
        color="#636"
      />
    </Illustration>
  );
};

export default AnimatedShape;
```

Combining Shapes

This code demonstrates how to combine multiple shapes using the `Group` component in react-zdog. The `Group` component allows you to group multiple shapes together and manipulate them as a single entity.

```jsx
import React from 'react';
import { Illustration, Shape, Group } from 'react-zdog';

const CombinedShapes = () => (
  <Illustration>
    <Group>
      <Shape
        stroke={20}
        color="#636"
      />
      <Shape
        translate={{ x: 40 }}
        stroke={20}
        color="#E62"
      />
    </Group>
  </Illustration>
);

export default CombinedShapes;
```

Other packages similar to react-zdog

Keywords

FAQs

Package last updated on 29 Aug 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc