meodai / poline

Esoteric Palette Generator Mico-Lib Interpolating HSL Color in cartesian space
https://meodai.github.io/poline/
MIT License
672 stars 33 forks source link

Help with implementing in a react project. #20

Closed HumidBrains closed 4 months ago

HumidBrains commented 4 months ago

@meodai I'd be very grateful for any pointers on how to implement Poline in react. I've tried for an eternity, but I'm simply too stupid to figure it out. I don't expect your time to be for free. ;)

meodai commented 4 months ago

hey! what specific feature are you trying to implement?

meodai commented 4 months ago

PS: not a react person, but I made a simple example: https://playcode.io/1891755

console.clear()

import React, { useState, useEffect } from 'react';
import { Poline } from 'poline/dist/index.mjs';

export function App(props) {
  const pol = new Poline({
    numPoints: 6,
  });

  const [colors, setColors] = useState(pol.colorsCSS);

  function rndColors () {
    pol.colors.forEach((point, i) => {
      pol.updateAnchorPoint({
        point,
        xyz: [Math.random(), Math.random(), Math.random()]
      });
    })

    setColors(pol.colorsCSS)
  }

  return (
    <div className='App' onClick={rndColors}>
      <h1>Hello React & Poline</h1>
      <ol>
        {colors.map(c => 
          <li style={{background: c}}></li>
        )}
      </ol>
    </div>
  );
}
HumidBrains commented 4 months ago

Hey David, thanks for such quick reply and for your example :) However, the palette colours I've managed to render myself, I should have mentioned that. It's your brilliant colour wheel I don't manage to render. I think you've built such an intuitive way to select palette colours and I have to say you're simply a colour genius. I was looking to implement both the colour wheel and the palette into a cms project that runs on Next.js.

I've seen that you render the wheel with p5, but I haven't managed to get it working in react. Any input on that?

meodai commented 4 months ago

the wheel itself is not part of the lib. Not sure to do this cleanly, especially if it needs to work with all kinds of libs. But its not too complex to build for a specific lib

HumidBrains commented 4 months ago

To me the UX provided by the wheel is what really sets poline apart and makes it so intuitive. I'd love to discuss with you how we can make it run in react.

meodai commented 4 months ago

@HumidBrains Hey I am sorry but I am quite busy with my current project. Feel free to hit me up again in a few weeks.