-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
awb99
committed
Sep 30, 2024
1 parent
842db0d
commit a2bc9bd
Showing
3 changed files
with
77 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(ns rtable.render.pixi.arearange | ||
(:require | ||
[tech.v3.dataset :as tmlds] | ||
["pixi.js" :as pixi :refer [Application Container Graphics Text]] | ||
[rtable.render.pixi.scale :refer [scale-bars scale-col]] | ||
[rtable.color :refer [set-color]] | ||
)) | ||
|
||
|
||
(defn add-bar [graphics step-px height col1 col2 color idx row] | ||
(let [; x | ||
bar-width step-px | ||
x-center (* idx step-px) | ||
x x-center | ||
; y | ||
c1 (min height (max 0 (get row col1))) | ||
c2 (min height (max 0 (get row col2))) | ||
y (min c1 c2) | ||
height (abs (- c1 c2))] | ||
; BAR | ||
(println "adding range-bar x: " x "y: " y | ||
" c1: " c1 " c2: " c2 " width: " bar-width " height: " height "color: " color) | ||
(.rect graphics x y bar-width height) | ||
(.fill graphics (clj->js {:color color | ||
:alpha 0.5 | ||
})); | ||
;(.stroke graphics (clj->js {:width 1 :color 0xffffff})) | ||
|
||
)) | ||
|
||
(defn draw-range [state container height price-range col1 col2 color] | ||
(let [{:keys [ds-visible step-px]} @state | ||
color2 (set-color color) | ||
ds (-> ds-visible | ||
(scale-col height price-range col1) | ||
(scale-col height price-range col2)) | ||
rows (tmlds/rows ds) | ||
graphics (Graphics.)] | ||
;(println "scaled ds:") | ||
;(println ds-visible) | ||
(doall (map-indexed (partial add-bar graphics step-px height col1 col2 color2) rows)) | ||
(.addChild container graphics) | ||
(println "draw-bars done."))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters