Budeme spolu programovat v Clojure. V project.clj mám [cljfx "1.9.5"] a v hlavičce…
- User
Budeme spolu programovat v Clojure. V project.clj mám [cljfx "1.9.5"] a v hlavičce souboru (:require [cljfx.api :as fx]) - vymysli prosím něco krátkého, ale zajímavého!
Assistant
Skvělá volba pro rychlý projekt! Co takhle jednoduchá interaktivní barevná paleta, kde uživatel kliká na tlačítka a mění barvu pozadí?
(ns cljfx-color-picker.core (:require [cljfx.api :as fx])) (def colors {:red "-fx-base: #ff6961;" :green "-fx-base: #88d8b0;" :blue "-fx-base: #729fcf;"}) (defn color-button [color] {:fx/type :button :text (name color) :style (-fx-base (get colors color)) :on-action #(swap! fx/context assoc :background (get colors color))}) (fx/on-fx-thread (fx/create-component {:fx/type :stage :showing true :title "Color Picker" :scene {:fx/type :scene :stylesheets [":modena/modena.css"] :root {:fx/type :v-box :spacing 10 :padding "20" :style (fx/watch {:background "-fx-base: #ffffff;"}) :children (map color-button (keys colors))}}}))
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.