Skip to content

Commit

Permalink
Merge pull request #18 from Quamolit/docs
Browse files Browse the repository at this point in the history
add usages in README
  • Loading branch information
TCXX committed Feb 5, 2020
2 parents 365c74d + f8305fd commit bb26dfd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@

Phlox(WIP)
Phlox
----

> Pixi.js DSL in ClojureScript
> Pixi.js DSL in ClojureScript, inspired by Virtual DOMs. Currently only a small subset of Pixi.js features is supported, good part is how swapping on code changes is available.
Previews http://repo.quamolit.org/phlox/ .

### Usage

WIP
[![Clojars Project](https://img.shields.io/clojars/v/quamolit/phlox.svg)](https://clojars.org/quamolit/phlox)

```edn
[quamolit/phlox "0.0.1"]
```

`render!` to add canvas to `<body/>`:

```clojure
(ns app.main
(:require [phlox.core :refer [defcomp render! create-list
rect circle text container graphics]]
[phlox.util :refer [hslx]]))

(defcomp comp-demo [data]
(rect
{:options {:x 800, :y 40, :width 60, :height 34},
:fill (hslx 40 80 80),
:on {:pointerdown (fn [e d!] (d! :demo nil))}}
(text
{:text "Demo",
:position {:x 808, :y 44},
:style {:fill (hslx 120 80 20), :font-size 18, :font-family "Josefin Sans"}})))

(defonce *store (atom nil))

(defn dispatch! [op op-data]
(reset! *store (updater @*store op op-data)))

(defn main []
(render! (comp-demo data) dispatch! {}))

(defn reload! []
(render! (comp-container @*store) dispatch! {:swap? true}))
```

### Spec

Expand Down Expand Up @@ -121,7 +157,7 @@ Draw star:

### Workflow

Workflow https://github.com/mvc-works/calcit-workflow
Workflow https://github.com/Quamolit/phlox-workflow

### License

Expand Down
2 changes: 1 addition & 1 deletion calcit.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -4900,7 +4900,7 @@
|j $ {} (:type :leaf) (:by |rJG4IHzWf) (:at 1574007929065) (:text |props') (:id |IH1ZPSoHq_)
|n $ {} (:type :expr) (:by |rJG4IHzWf) (:at 1574182791167) (:id |F5YT6SF4ZM)
:data $ {}
|T $ {} (:type :leaf) (:by |rJG4IHzWf) (:at 1574182791167) (:text |set-pivot) (:id |L8qZjuiWrj)
|T $ {} (:type :leaf) (:by |rJG4IHzWf) (:at 1580919816901) (:text |set-alpha) (:id |L8qZjuiWrj)
|b $ {} (:type :leaf) (:by |rJG4IHzWf) (:at 1574182798964) (:text |target) (:id |qxn_T3Z67h)
|j $ {} (:type :expr) (:by |rJG4IHzWf) (:at 1574182791167) (:id |Y16wRoaqz_)
:data $ {}
Expand Down
2 changes: 1 addition & 1 deletion meyvn.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{:pom {:group-id "quamolit",
:artifact-id "phlox",
:version "0.0.1",
:version "0.0.2-a1",
:name "Pixi.js DSL in ClojureScript"}
:packaging {:jar {:enabled true
:remote-repository {:id "clojars"
Expand Down
2 changes: 1 addition & 1 deletion src/phlox/render.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
(when (not= (:rotation props) (:rotation props'))
(set-rotation target (:rotation props)))
(when (not= (:pivot props) (:pivot props')) (set-pivot target (:pivot props)))
(when (not= (:alpha props) (:alpha props')) (set-pivot target (:alpha props)))
(when (not= (:alpha props) (:alpha props')) (set-alpha target (:alpha props)))
(update-events target (-> element :props :on) (-> old-element :props :on) dispatch!)))

(defn update-text [element old-element target]
Expand Down

0 comments on commit bb26dfd

Please sign in to comment.