News for hackers. Stuff that matters.
Re:Clojure 1.12.0 is now available by fire_lake on Friday September 06, 2024 @02:07AM (#41463323)
Cool! You should post an example :)
Re:Clojure 1.12.0 is now available by geokon on Friday September 06, 2024 @04:01AM (#41464001)
Just tested it:

You run `clj` to get a Clojure REPL

Then you can for instance paste the following into the REPL

    (add-libs {'thi.ng/geom {:mvn/version "1.0.0-RC4"}})
    (use 'thi.ng.geom.viz.core)
    (use 'thi.ng.geom.svg.core)

    (->> {:x-axis (linear-axis
                {:domain [-10 310]
                    :range  [50 550]
                    :major  100
                    :minor  50
                    :pos    150})
        :y-axis (linear-axis
                {:domain  [0 4]
                    :range   [50 150]
                    :visible false})
        :data   [{:values  [[0 100] [10 90] [80 200] [250 300] [150 170] [110 120]
                            [210 280] [180 280] [160 240] [160 170]]
                    :attribs {:stroke-width "10px" :stroke-linecap "round" :stroke "#0af"}
                    :layout  svg-stacked-interval-plot}]}
        (svg-plot2d-cartesian)
        (svg {:width 600 :height 200})
        (serialize)
        symbol)
- the first line downloads a library and adds it to the running session

- the second and third line add the library to the REPL's default namespace

- the rest of the code makes an axis and plots some random values

- the output is then serialized and send out the REPL output

You should get a little SVG plot on the output

PS: Make sure you have version `1.12` by running with `clj --version`. If not, then (re)run the instructions here to get the latest version: https://clojure.org/guides/install_clojure

Re:Clojure 1.12.0 is now available by puredanger on Friday September 06, 2024 @09:09AM (#41465842)
Using (add-lib 'thi.ng/geom) is sufficient here - it uses the newest version by default.
Re:Clojure 1.12.0 is now available by diggan on Friday September 06, 2024 @11:52AM (#41467245)
Parent specified a RC version, does it automatically use the latest RC versions as well? AFAIK, it only uses the latest stable version, but I could be wrong, it happened before.
Re:Clojure 1.12.0 is now available by geokon on Friday September 06, 2024 @04:27AM (#41464126)
Here is an example playing with BooFCV's Java API

It'll pop up a little window displaying an image

    (add-libs {'org.boofcv/boofcv-all {:mvn/version "0.35"}})
    (import 'boofcv.alg.color.ColorRgb
            'boofcv.core.image.ConvertImage
            'boofcv.gui.ListDisplayPanel
            'boofcv.gui.image.ShowImages
            'boofcv.io.UtilIO
            'boofcv.io.image.ConvertBufferedImage
            'boofcv.io.image.UtilImageIO
            'boofcv.struct.image.GrayU8
            'boofcv.struct.image.ImageType
            'boofcv.struct.image.Planar
            'java.awt.image.BufferedImage)
    (let [image-url  "https://kxygk.github.io/web/chengdu.jpg"
          color (ConvertBufferedImage/convertFrom (UtilImageIO/loadImage image-url)
                                                  true,
                                                  (ImageType/pl 3 GrayU8))
          weighted (GrayU8. (.width color)
                            (.height color))
          gui (ListDisplayPanel.)]
      (ColorRgb/rgbToGray_Weighted color weighted)
      (.addImage gui
                 weighted
                 (str (.width color)
                      " "
                      (.height color)))
      (ShowImages/showWindow gui
                             "RGB222"
                             true))