svg-clj icon indicating copy to clipboard operation
svg-clj copied to clipboard

README example code issue

Open stelcodes opened this issue 3 years ago • 1 comments

Hi Adam! Idk if you remember but I was watching your streams earlier this year. I've finally got around to trying out this library. I'm having an issue with the blossom example code. In particular:

(defn petal
  [cpts]
  (let [beza (apply path/bezier cpts)
        bezb (apply path/bezier (flip-y cpts))
        shape (tf/merge-paths beza bezb)
        ctr (tf/centroid shape)]
    (-> shape
        (tf/rotate -90)
        (tf/translate (utils/v* ctr [-1 -1])))))

(def petal-03
  (-> (tf/merge-paths petal-01 petal-02)
      (tf/style {:fill "#a8e6cf"})))

These functions in examples/blossom.cljc reference svg-clj.transforms/merge-paths which does not currently exist and produces this error:

Syntax error compiling at (examples/blossom.cljc:20:15).
No such var: tf/merge-paths

Full report at:
/tmp/clojure-8102567249478100193.edn

I tried changing this function to svg-clj.paths/merge-paths but the output svg looks wonky. 2021-12-27_00:39:37_screenshot

stelcodes avatar Dec 27 '21 08:12 stelcodes

Hi Stelcodes. I remember you from the streams :). I do believe it was you road tripping around the US right? I hope your travels went (are going!?) well.

I’m happy you’re trying this library out and I am grateful for you pointing out the inconsistency here with the example.

I’ve had some trouble with merging paths so I’ll have to try design a more robust solution and a better test suite for this part of the code.

In the meantime, I’m curious if you might work around the wonkiness with some floating point “adjustments”. I’m not at a computer to properly try this yet, but in the petal code if you adjust rotations from 90 degrees to, say, 90.01 or 89.99, you may see different output

adam-james-v avatar Dec 27 '21 18:12 adam-james-v