Coder Social home page Coder Social logo

katachidraw's Introduction

Katachidraw

SVG based drawing tool and react-native component

Katachidraw means like "Let's make shapes" in Japanese.

CI npm size discord

What is this

There are two aspects: User's perspective and developer's perspective

What is this for users

This is a drawing tool that can produce an SVG file. It's primarily for mobile, but works for desktop too. One of the goals is to draw freely and create smoother shapes.

Visit https://katachidraw.vercel.app/ in your browser.

Tested with:

  • iPhone Mobile Safari
  • MacOS Google Chrome

What is this for developers

This is a reusable drawing library that can be embeded in your React app. It's built with following libraries:

It's published as npm package: https://www.npmjs.com/package/katachidraw

Community

We have a channel #katachidraw to discuss both about the usage and the development in our Discord server.

Contribution

Feel free to use the library under the MIT license. If you find bugs, please file issues. Pull requests are also welcome and there are some issues filed for a start.

katachidraw's People

Contributors

brentvatne avatar dai-shi avatar michellstefanii 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  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  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  avatar  avatar  avatar

katachidraw's Issues

feat: draw shapes

in advance to #9, we want rather simple shape drawing. lines, circles, rectangles.

feat: improve history feature

  • make the circle draggable
  • would be nice to add a play button to auto play history
  • maybe we want a commit button not to remove history accidentally?
  • [performance] might be better to cache atom for shape object (in weak map), but that doesn't improve anything?

[UI] Selecting shapes in RN is not easy

while #28 isn't a technical issue, selecting shapes with fingers is not easy. maybe we should add a drag selector mode for RN. I wonder how it can be done without introducing a mode...

Idea: Grouped strokes.

When marks are made in rapid sequence, treat them as a group. For example, if I write an H with three strokes, I would probably want to edit / position those three together as a group.

I’ve been working this out for my Telestrator app, where related marks should fade out together. (Or else the beginning of a word will start fading out as you’re writing the end of the word). In that case, I’ve found that waiting about one second after a stroke is enough to “complete” a group of related marks.

Invariant Violation: requireNativeComponent: "RNSVGPath" was not found in the UIManager

I'm on expo 44 and everything is working fine on Expo Go.
But when I hot reload updates after expo publish, the android app crashes with the error bellow

code:

import { useSetAtom } from "jotai";
import { Canvas } from "katachidraw/src/library";
import React, { useCallback, useEffect, useRef, useState } from "react";
import { Dimensions, Pressable } from "react-native";
import { captureRef } from "react-native-view-shot";

import { sketchUriAtom } from "@/atoms";
import Icon from "@/components/Icon";
import { useThemeColor, View } from "@/components/Themed";
import { RootStackScreenProps } from "@/types";

const width = Dimensions.get("window").width;
const height = Dimensions.get("window").height;

export default function SketchScreen({ route, navigation }: RootStackScreenProps<"About">) {
  const [isCapturing, setIsCapturing] = useState(false);
  const viewRef = useRef(null);

  const setSketchUri = useSetAtom(sketchUriAtom);
  const tintColor = useThemeColor({}, "tint");

  const onPress = useCallback(async () => {
    setIsCapturing(true);
    await new Promise((end) => setTimeout(end, 200));
    const result = await captureRef(viewRef, {
      result: "tmpfile",
      height,
      width,
      quality: 1,
      format: "png",
    });
    setSketchUri(result);
    setIsCapturing(false);
    navigation.goBack();
  }, [viewRef]);

  useEffect(() => {
    navigation.setOptions({
      headerRight: () => (
        <Pressable onPress={onPress}>
          <Icon name="check" color={tintColor} />
        </Pressable>
      ),
    });
  }, []);

  return (
    <View ref={viewRef} collapsable={false}>
      <Canvas
        width={width}
        height={height}
        sliderPosition={isCapturing ? [0, 0] : undefined}
        toolbarPosition={isCapturing ? [-100, 0] : undefined}
      />
    </View>
  );
}

versions:

"katachidraw": "^0.4.0",
"react-native": "^0.64.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-native-svg": "12.1.1",
"@xstate/inspect": "^0.6.5"

image

feat: Add Shapes tool (ellipse/circle, rectangle/square, triangle, star), Line tool, Arrow tool; Add text tool with font and color selector

In comparison to http://tbolis.github.io/showcase/react-sketch/ this has a lot of potential relying on SVG drawing.

It is missing the Shapes tools which would be useful to add.

It is also missing Text tools which would allow the user to easily create text blocks with different font stylings.

Finally, the ability to rotate and scale selected items would be awesome.

If you add these, it would be greatly appreciated and a much more powerful tool.

https://editor.method.ac/ has some great shapes to look at.

react and react-dom version conflicts

When using alongside expo compatible dependencies, the react and react-dom version is pinned to ^17.0.1
This library is pinned to 17.0.2, which causes version mismatch and crashes expo driven app.

Suggested solution:
move react and react-dom to peerDepencies and devDependencies

feat: shape resizing

as we don't change stroke width, we are likely that we want to resize images.

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.