mirror of https://github.com/status-im/reagent.git
Added some circles
This commit is contained in:
parent
b25facab63
commit
bc607852ef
|
@ -1,6 +1,6 @@
|
|||
(ns components
|
||||
(:require [reagent.core :as r]
|
||||
[geometry :refer [x y] :as g]))
|
||||
[geometry :refer [x y dist] :as g]))
|
||||
|
||||
(def point-defaults
|
||||
{:stroke "black"
|
||||
|
@ -46,3 +46,13 @@
|
|||
[segment a b]
|
||||
[segment b c]
|
||||
[segment c a]])
|
||||
|
||||
|
||||
(defn circle [c r]
|
||||
[:circle
|
||||
{:cx (x c)
|
||||
:cy (y c)
|
||||
:r (dist c r)
|
||||
:stroke-width 2
|
||||
:stroke "black"
|
||||
:fill "rgba(0,0,0,0)"}])
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
(defn root []
|
||||
[:g
|
||||
[c/triangle @p1 @p2 @p3]
|
||||
[c/circle @p1 @p2]
|
||||
[c/circle @p2 @p3]
|
||||
[c/circle @p3 @p1]
|
||||
[c/draggable-point p1 mouse-info]
|
||||
[c/draggable-point p2 mouse-info]
|
||||
[c/draggable-point p3 mouse-info]])
|
||||
|
@ -48,4 +51,3 @@
|
|||
"The corners are draggable"]
|
||||
[root]]
|
||||
(by-id "app")))
|
||||
|
||||
|
|
|
@ -24,5 +24,7 @@
|
|||
(rand-point -1 2 -1 2))
|
||||
|
||||
|
||||
|
||||
(defn dist [p1 p2]
|
||||
(js/Math.sqrt (+ (js/Math.pow (- (x p2) (x p1)) 2)
|
||||
(js/Math.pow (- (y p2) (y p1)) 2))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue