Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with PIXIjs #163

Open
igorcouto opened this issue May 24, 2020 · 4 comments
Open

Integration with PIXIjs #163

igorcouto opened this issue May 24, 2020 · 4 comments

Comments

@igorcouto
Copy link

Hi guys,

Did you see possibility on integration with PIXIJS Custom Sprites?

Thanks!

@pshihn
Copy link
Collaborator

pshihn commented May 24, 2020

I have not used pixijs, so cannot say.
But I have a proof of concept version of roughjs that renders using webgl.
What exactly are you thinking of?

@igorcouto
Copy link
Author

I'm thinking in integrating it in PIXI Custom components, using graphics(that in underlying implementation uses a canvas context).

Somethink like that, but using rough. Then we will have acess to PIXI Library. It will awesome.

const Rectangle = PixiComponent('Rectangle', {
create: () => new PIXI.Graphics(),
applyProps: (g, _, props) => {
const { fill, x, y, width, height } = props

  g.clear()
  g.beginFill(fill)
  g.drawRect(x, y, width, height)
  g.endFill()
}

})

@StringKe
Copy link

StringKe commented Aug 5, 2021

I'm thinking in integrating it in PIXI Custom components, using graphics(that in underlying implementation uses a canvas context).

Somethink like that, but using rough. Then we will have acess to PIXI Library. It will awesome.

const Rectangle = PixiComponent('Rectangle', {
create: () => new PIXI.Graphics(),
applyProps: (g, _, props) => {
const { fill, x, y, width, height } = props

  g.clear()
  g.beginFill(fill)
  g.drawRect(x, y, width, height)
  g.endFill()
}

})

you can try this

image

roughGenerator

import rough from 'roughjs/bundled/rough.esm';

import RoughType from 'roughjs';

declare type RoughGenerator = ReturnType<typeof RoughType.generator>;

const generator = rough.generator(undefined);
const roughGeneratorInstance = generator as RoughGenerator;

export const roughGenerator = roughGeneratorInstance;
        const rectangle = roughGenerator.rectangle(0, 0, 100, 100);
        rectangle.sets.forEach(step => {
            if (step.type === 'path') {
                step.ops.forEach(({op, data}) => {

                    const [cp1x, cp1y, cp2x, cp2y, x, y] = data;
                    switch (op) {
                        case "bcurveTo":
                            buttonDraw.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y)
                            break;
                        case "lineTo":
                            buttonDraw.lineTo(cp1x, cp1y)
                            break;
                        case "move":
                            buttonDraw.moveTo(cp1x, cp1y)
                            break;
                        default:
                            break;
                    }
                })
            }
        });

@stylustrader
Copy link

I have not used pixijs, so cannot say. But I have a proof of concept version of roughjs that renders using webgl. What exactly are you thinking of?

Def interested in webgl version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants