├── dev-src ├── tests │ ├── core.cljs │ └── composite_updates.cljs ├── webserver │ └── servefromjar.clj └── examples │ ├── hello │ └── hello.cljs │ ├── cupcake │ └── cupcake.cljs │ ├── preloader │ └── preloader.cljs │ └── interactive │ └── interactive.cljs ├── docs └── clickablesprites.png ├── dev-resources ├── public │ ├── examples │ │ ├── assets │ │ │ ├── cherry.png │ │ │ ├── bg_castle.png │ │ │ ├── creamPink.png │ │ │ ├── cupCake.png │ │ │ ├── creamChoco.png │ │ │ ├── creamMocha.png │ │ │ ├── assets │ │ │ │ ├── cherry.png │ │ │ │ ├── cupCake.png │ │ │ │ ├── bg_castle.png │ │ │ │ ├── creamPink.png │ │ │ │ ├── creamChoco.png │ │ │ │ ├── creamMocha.png │ │ │ │ ├── creamVanilla.png │ │ │ │ ├── lollipopGreen.png │ │ │ │ ├── comic_neue_angular_bold_0.png │ │ │ │ ├── comic_neue_angular_bold.bmfc │ │ │ │ └── comic_neue_angular_bold.fnt │ │ │ ├── creamVanilla.png │ │ │ ├── lollipopGreen.png │ │ │ ├── comic_neue_angular_bold_0.png │ │ │ ├── comic_neue_angular_bold.bmfc │ │ │ └── comic_neue_angular_bold.fnt │ │ ├── cupcake │ │ │ ├── cupcake.min.html │ │ │ └── cupcake.html │ │ ├── hello │ │ │ └── hello.html │ │ ├── preloader │ │ │ └── preloader.html │ │ └── interactive │ │ │ └── interactive.html │ └── index.html └── private │ └── html │ └── tests.html ├── src └── omreactpixi │ ├── abbrev.clj │ ├── core.clj │ ├── core.cljs │ └── abbrev.cljs ├── .gitignore ├── NOTICE ├── README.md ├── project.clj └── LICENSE /dev-src/tests/core.cljs: -------------------------------------------------------------------------------- 1 | (ns tests.core 2 | (:require [cemerick.cljs.test :as t])) 3 | 4 | -------------------------------------------------------------------------------- /docs/clickablesprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/docs/clickablesprites.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/cherry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/cherry.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/bg_castle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/bg_castle.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/creamPink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/creamPink.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/cupCake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/cupCake.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/creamChoco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/creamChoco.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/creamMocha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/creamMocha.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/cherry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/assets/cherry.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/cupCake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/assets/cupCake.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/creamVanilla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/creamVanilla.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/lollipopGreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/lollipopGreen.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/bg_castle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/assets/bg_castle.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/creamPink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/assets/creamPink.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/creamChoco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/assets/creamChoco.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/creamMocha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/assets/creamMocha.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/creamVanilla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/assets/creamVanilla.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/lollipopGreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/assets/lollipopGreen.png -------------------------------------------------------------------------------- /dev-resources/private/html/tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/comic_neue_angular_bold_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/comic_neue_angular_bold_0.png -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/comic_neue_angular_bold_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Izzimach/om-react-pixi/HEAD/dev-resources/public/examples/assets/assets/comic_neue_angular_bold_0.png -------------------------------------------------------------------------------- /dev-resources/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Examples

4 | Hello world 5 | A cupcake 6 | A cupcake (minimized) 7 | Preloader 8 | Interactive 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/omreactpixi/abbrev.clj: -------------------------------------------------------------------------------- 1 | (ns omreactpixi.abbrev) 2 | 3 | ;; 4 | ;; abbreviated version similar to that used in om-tools 5 | ;; 6 | 7 | 8 | (defmacro defn-pixi-element-abbrev [tag] 9 | (let [jsname (symbol "js" (str "ReactPIXI." (name tag))) 10 | cljname (symbol (clojure.string/lower-case (name tag)))] 11 | `(defn ~cljname [opts# & children#] 12 | (let [[opts# children#] (element-args opts# children#)] 13 | (apply React.createElement 14 | ~jsname 15 | (cljs.core/into-array (cons opts# children#))))))) 16 | -------------------------------------------------------------------------------- /dev-resources/public/examples/cupcake/cupcake.min.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/omreactpixi/core.clj: -------------------------------------------------------------------------------- 1 | ;; macros need to be in a clojure (not clojurescript) file 2 | 3 | (ns omreactpixi.core) 4 | 5 | ;; for some reason I made react-pixi components camelcase, 6 | ;; so here we convert the names so that they are called as lowercase 7 | ;; names in clojurescript 8 | 9 | (defmacro defn-pixi-element [tag] 10 | (let [jsname (symbol "js" (str "ReactPIXI." (name tag))) 11 | cljname (symbol (clojure.string/lower-case (name tag)))] 12 | `(defn ~cljname [opts# & children#] 13 | (apply React.createElement 14 | ~jsname 15 | (cljs.core/into-array (cons opts# children#)))))) 16 | -------------------------------------------------------------------------------- /src/omreactpixi/core.cljs: -------------------------------------------------------------------------------- 1 | (ns omreactpixi.core 2 | (:require-macros [omreactpixi.core :as orp]) 3 | (:require [goog.events :as events] 4 | [om.core :as om :include-macros true] 5 | [om.dom :as dom :include-macros true] 6 | [clojure.string :as string])) 7 | 8 | ;; 9 | ;; need to make these more automatic, om-style 10 | ;; 11 | 12 | (orp/defn-pixi-element Stage) 13 | (orp/defn-pixi-element Text) 14 | (orp/defn-pixi-element BitmapText) 15 | (orp/defn-pixi-element Sprite) 16 | (orp/defn-pixi-element DisplayObjectContainer) 17 | (orp/defn-pixi-element SpriteBatch) 18 | (orp/defn-pixi-element TilingSprite) 19 | 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # leiningen build artifacts 11 | out 12 | out-min 13 | target 14 | pom.xml 15 | -init.clj 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # leiningen git-deps storage 21 | .lein-git-deps 22 | .lein-repl-history 23 | .nrepl-port 24 | 25 | 26 | # vim temp files 27 | *~ 28 | *.swp 29 | 30 | # Compiled binary addons (http://nodejs.org/api/addons.html) 31 | build/Release 32 | 33 | # Dependency directory 34 | # Deployed apps should consider commenting this line out: 35 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git 36 | node_modules 37 | -------------------------------------------------------------------------------- /dev-resources/public/examples/hello/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /dev-resources/public/examples/preloader/preloader.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | The Comic Neue font is public domain create by Craig Rozynski (comicneue.com) 2 | 3 | The following bitmap font files derived from Comic Neue are public domain: 4 | - examples/assets/comic_neue_angular_bold.fnt 5 | - examples/assets/comic_neue_angular_bold_0.png 6 | 7 | The following graphics files in examples/assets are CC0 (public domain), created by Kenney Vleugels (www.kenney.nl): 8 | - bg_castle.png 9 | - cupCake.png 10 | - lollipopGreen.png 11 | - cherry.png 12 | - creamChoco.png 13 | - creamMocha.png 14 | - creamPink.png 15 | - creamVanilla.png 16 | 17 | The following files are Copyright 2013-2014 Mathew Groves and included under the MIT License: 18 | - vendor/pixi.js 19 | - vendor/pixi.dev.js 20 | 21 | -------------------------------------------------------------------------------- /dev-resources/public/examples/interactive/interactive.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/omreactpixi/abbrev.cljs: -------------------------------------------------------------------------------- 1 | (ns omreactpixi.abbrev 2 | (:require-macros [omreactpixi.abbrev :as abbrev]) 3 | (:require [goog.events :as events] 4 | [clojure.string :as string])) 5 | 6 | (defn element-args [opts children] 7 | (cond 8 | (nil? opts) [nil children] 9 | (map? opts) [(clj->js opts) children] 10 | (object? opts) [opts children] 11 | :else [nil (cons opts children)])) 12 | 13 | 14 | (abbrev/defn-pixi-element-abbrev Stage) 15 | (abbrev/defn-pixi-element-abbrev Text) 16 | (abbrev/defn-pixi-element-abbrev BitmapText) 17 | (abbrev/defn-pixi-element-abbrev Sprite) 18 | (abbrev/defn-pixi-element-abbrev SpriteBatch) 19 | (abbrev/defn-pixi-element-abbrev DisplayObjectContainer) 20 | (abbrev/defn-pixi-element-abbrev TilingSprite) 21 | -------------------------------------------------------------------------------- /dev-resources/public/examples/cupcake/cupcake.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /dev-src/webserver/servefromjar.clj: -------------------------------------------------------------------------------- 1 | (ns webserver.servefromjar 2 | (require [ring.middleware.file :refer [wrap-file]] 3 | [ring.middleware.file-info :refer [wrap-file-info]] 4 | [compojure.core :refer [defroutes GET]] 5 | [compojure.route :refer [files resources]])) 6 | 7 | (defn handler [request] 8 | {:status 200 9 | :headers {"Content-Type" "text/html"} 10 | :body (System/getProperty "user.dir") }) 11 | 12 | (def statichandler 13 | (-> handler 14 | (wrap-file (System/getProperty "user.dir")) 15 | (wrap-file-info))) 16 | 17 | ;; 18 | ;; The react-pixi javascript files are stored in the react-pixi jar, 19 | ;; so we need the handler to serve those files properly. For any other 20 | ;; request the handler will rely on standard static file serving. 21 | ;; 22 | 23 | (defroutes reactpixifromjar 24 | (resources "/react-pixi" {:root "react_pixi"}) 25 | (files "/" {:root "(dev-resources/public|resources/public)"})) 26 | 27 | 28 | -------------------------------------------------------------------------------- /dev-src/examples/hello/hello.cljs: -------------------------------------------------------------------------------- 1 | (ns omreactpixi.examples.hello 2 | (:require [goog.events :as events] 3 | [om.core :as om :include-macros true] 4 | [om.dom :as dom :include-macros true] 5 | [omreactpixi.abbrev :as pixi :include-macros true] 6 | [clojure.string :as string] 7 | [figwheel.client :as fw])) 8 | 9 | (enable-console-print!) 10 | 11 | (defonce app-state (atom {:hello "hello"})) 12 | 13 | (defn game [app owner] 14 | (om/component 15 | (if (:loaded app) 16 | (pixi/text {:text (:hello app)}) 17 | (pixi/displayobjectcontainer 18 | {} 19 | (pixi/text {:text "loading"}))))) 20 | 21 | 22 | (defn main [] 23 | (om/root 24 | (fn [app owner] 25 | (reify 26 | om/IRender 27 | (render [_] 28 | (pixi/stage {:width 640 29 | :height 480 30 | :backgroundcolor 0x888888 31 | :ref "stage"} 32 | (om/build game app))))) 33 | app-state 34 | {:target (. js/document (getElementById "my-app"))})) 35 | 36 | 37 | (main) 38 | 39 | (fw/start { 40 | :on-jsload (fn [] (print "reloaded"))}) 41 | 42 | -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/comic_neue_angular_bold.bmfc: -------------------------------------------------------------------------------- 1 | # AngelCode Bitmap Font Generator configuration file 2 | fileVersion=1 3 | 4 | # font settings 5 | fontName=Comic Neue Angular 6 | fontFile=../../../Fonts/comic-neue-1.1/ComicNeue-Angular-Bold.ttf 7 | charSet=0 8 | fontSize=40 9 | aa=1 10 | scaleH=100 11 | useSmoothing=1 12 | isBold=0 13 | isItalic=0 14 | useUnicode=1 15 | disableBoxChars=1 16 | outputInvalidCharGlyph=0 17 | dontIncludeKerningPairs=0 18 | useHinting=1 19 | renderFromOutline=0 20 | useClearType=1 21 | 22 | # character alignment 23 | paddingDown=0 24 | paddingUp=0 25 | paddingRight=0 26 | paddingLeft=0 27 | spacingHoriz=1 28 | spacingVert=1 29 | useFixedHeight=0 30 | forceZero=0 31 | 32 | # output file 33 | outWidth=256 34 | outHeight=256 35 | outBitDepth=32 36 | fontDescFormat=1 37 | fourChnlPacked=0 38 | textureFormat=png 39 | textureCompression=0 40 | alphaChnl=0 41 | redChnl=4 42 | greenChnl=4 43 | blueChnl=4 44 | invA=0 45 | invR=0 46 | invG=0 47 | invB=0 48 | 49 | # outline 50 | outlineThickness=0 51 | 52 | # selected chars 53 | chars=0-0,13,32-93,95,97-126,160,162-163,165,169,171,173-174,176,182,187,191 54 | 55 | # imported icon images 56 | -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/comic_neue_angular_bold.bmfc: -------------------------------------------------------------------------------- 1 | # AngelCode Bitmap Font Generator configuration file 2 | fileVersion=1 3 | 4 | # font settings 5 | fontName=Comic Neue Angular 6 | fontFile=../../../Fonts/comic-neue-1.1/ComicNeue-Angular-Bold.ttf 7 | charSet=0 8 | fontSize=40 9 | aa=1 10 | scaleH=100 11 | useSmoothing=1 12 | isBold=0 13 | isItalic=0 14 | useUnicode=1 15 | disableBoxChars=1 16 | outputInvalidCharGlyph=0 17 | dontIncludeKerningPairs=0 18 | useHinting=1 19 | renderFromOutline=0 20 | useClearType=1 21 | 22 | # character alignment 23 | paddingDown=0 24 | paddingUp=0 25 | paddingRight=0 26 | paddingLeft=0 27 | spacingHoriz=1 28 | spacingVert=1 29 | useFixedHeight=0 30 | forceZero=0 31 | 32 | # output file 33 | outWidth=256 34 | outHeight=256 35 | outBitDepth=32 36 | fontDescFormat=1 37 | fourChnlPacked=0 38 | textureFormat=png 39 | textureCompression=0 40 | alphaChnl=0 41 | redChnl=4 42 | greenChnl=4 43 | blueChnl=4 44 | invA=0 45 | invR=0 46 | invG=0 47 | invB=0 48 | 49 | # outline 50 | outlineThickness=0 51 | 52 | # selected chars 53 | chars=0-0,13,32-93,95,97-126,160,162-163,165,169,171,173-174,176,182,187,191 54 | 55 | # imported icon images 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | om-react-pixi 2 | ============= 3 | 4 | ![Interactive example](docs/clickablesprites.png) 5 | 6 | Bindings for [Om](https://github.com/swannodette/om) to let you create and 7 | control [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) sprites from ClojureScript. 8 | 9 | A simple example displaying text on a 400px by 300px canvas: 10 | 11 | ``` 12 | (defn simplestage [cursor] 13 | (om/component 14 | (pixi/stage #js {:width 400 :height 300} 15 | (pixi/text #js {:x 100 :y 100 :text "argh!"})))) 16 | ``` 17 | 18 | ## How to Include and Use 19 | 20 | The latest version is 0.5.0. In your `project.clj` include this dependency: 21 | 22 | ``` 23 | [org.clojars.haussman/om-react-pixi "0.5.0"] 24 | ``` 25 | 26 | This will also include [react-pixi](https://github.com/Izzimach/react-pixi/) 27 | which itself includes react 0.13.1. 28 | 29 | Standard components are in the `omreactpixi.core` namespace. There are also abbreviated forms that are based on the 30 | forms used by [om-tools](https://github.com/Prismatic/om-tools) which are located in `omreactpixi.abbrev`. 31 | 32 | In either case you may want to pull in the functions using the `:as` form: 33 | 34 | ``` 35 | [omreactpixi.abbrev :as pixi] 36 | ``` 37 | 38 | so that you can refer to components using (for example) `pixi/stage` or `pixi/sprite`. 39 | 40 | ## Provided Forms 41 | 42 | Includes the standard items from [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/): 43 | 44 | - Stage 45 | - Sprite 46 | - SpriteBatch 47 | - TilingSprite 48 | - Text 49 | - BitmapText 50 | - DisplayObjectContainer 51 | 52 | ## Running the examples 53 | 54 | Build the examples using cljsbuild 55 | 56 | ``` 57 | lein cljsbuild once 58 | ``` 59 | 60 | The examples can be driven by figwheel, allowing you to edit the interactive 61 | example source and auto-reload 62 | 63 | ``` 64 | lein figwheel interactive 65 | ``` 66 | 67 | ## Running Tests 68 | 69 | Tests are run inside slimerjs. 70 | 71 | ``` 72 | npm install slimerjs 73 | lein cljsbuild test 74 | ``` 75 | 76 | -------------------------------------------------------------------------------- /dev-src/examples/cupcake/cupcake.cljs: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; the cupcake example using some extras: 3 | ;; - the abbreviated version of pixi components found in 'omreactpixi.abbrev' 4 | ;; - defcomponentk version of defcomponent from om-tools, which uses fnk syntax 5 | ;; 6 | 7 | (ns omreactpixi.examples.cupcake 8 | (:require-macros [cljs.core.async.macros :refer [go]]) 9 | (:require [goog.events :as events] 10 | [om.core :as om :include-macros true] 11 | [schema.core :as schema] 12 | [om-tools.core :as omtools :include-macros true] 13 | [omreactpixi.abbrev :as pixi] 14 | [clojure.string :as string] 15 | [cljs.core.async :as async :refer [>! js/window .-innerWidth inset) 57 | h (-> js/window .-innerHeight inset)] 58 | (swap! appstate #(-> % (assoc :width w) (assoc :height h))) 59 | (om/root cupcakestage appstate 60 | {:target (.getElementById js/document "my-app")}))) 61 | 62 | 63 | ;; gotta load the bitmap font first or else pixi bombs out 64 | (defonce needtopreload (atom true)) 65 | 66 | (defn preloadthenstart [startfunc] 67 | (let [fontloader (PIXI.BitmapFontLoader. (assetpath "comic_neue_angular_bold.fnt"))] 68 | (swap! needtopreload (fn [_] false)) 69 | (.on fontloader "loaded" startfunc) 70 | (.load fontloader))) 71 | 72 | (if @needtopreload 73 | (preloadthenstart startcupcakes) 74 | (startcupcakes)) 75 | 76 | ;; enable dynamic reloading via figwheel 77 | (fw/watch-and-reload 78 | :jsload-callback (fn [] (print "reloaded!"))) 79 | 80 | -------------------------------------------------------------------------------- /dev-src/examples/preloader/preloader.cljs: -------------------------------------------------------------------------------- 1 | (ns omreactpixi.examples.preloader 2 | (:require-macros [cljs.core.async.macros :refer [go]]) 3 | (:require [goog.events :as events] 4 | [om.core :as om :include-macros true] 5 | [om.dom :as dom :include-macros true] 6 | [omreactpixi.core :as pixi :include-macros true] 7 | [clojure.string :as string] 8 | [cljs.core.async :as async :refer [>! ! js/window .-innerWidth inset) 122 | h (-> js/window .-innerHeight inset)] 123 | (swap! appstate #(-> % (assoc :width w) (assoc :height h))) 124 | (om/root interactivestage appstate 125 | {:target (.getElementById js/document "my-app")}))) 126 | 127 | ;; gotta load the bitmap font first or else pixi bombs out 128 | (defonce needtopreload (atom true)) 129 | 130 | (defn preloadthenstart [startfunc] 131 | (let [fontloader (PIXI.BitmapFontLoader. (assetpath "comic_neue_angular_bold.fnt"))] 132 | (swap! needtopreload (fn [_] false)) 133 | (.on fontloader "loaded" startfunc) 134 | (.load fontloader))) 135 | 136 | (if @needtopreload 137 | (preloadthenstart startinteractiveapp) 138 | (startinteractiveapp)) 139 | 140 | ;; enable dynamic reloading via figwheel 141 | (fw/watch-and-reload 142 | :jsload-callback (fn [] (print "reloaded!"))) 143 | 144 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Unless noted otherwise in the file NOTICE, files in om-react-pixi are 2 | Copyright (c) 2014 Gary Haussmann and covered by the Apache License, Version 2.0 3 | 4 | Apache License 5 | Version 2.0, January 2004 6 | http://www.apache.org/licenses/ 7 | 8 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 9 | 10 | 1. Definitions. 11 | 12 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 13 | 14 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 17 | 18 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 19 | 20 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 21 | 22 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 23 | 24 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 25 | 26 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 27 | 28 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 29 | 30 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 31 | 32 | 2. Grant of Copyright License. 33 | 34 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 35 | 36 | 3. Grant of Patent License. 37 | 38 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 39 | 40 | 4. Redistribution. 41 | 42 | You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 43 | 44 | You must give any other recipients of the Work or Derivative Works a copy of this License; and 45 | You must cause any modified files to carry prominent notices stating that You changed the files; and 46 | You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 47 | If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. 48 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 49 | 50 | 5. Submission of Contributions. 51 | 52 | Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 53 | 54 | 6. Trademarks. 55 | 56 | This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 57 | 58 | 7. Disclaimer of Warranty. 59 | 60 | Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 61 | 62 | 8. Limitation of Liability. 63 | 64 | In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 65 | 66 | 9. Accepting Warranty or Additional Liability. 67 | 68 | While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 69 | 70 | END OF TERMS AND CONDITIONS 71 | 72 | -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/comic_neue_angular_bold.fnt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /dev-resources/public/examples/assets/assets/comic_neue_angular_bold.fnt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | --------------------------------------------------------------------------------