Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
feat: colored outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
prescientmoon committed Apr 22, 2020
1 parent 0996d07 commit eddd2b3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/Capability/Editor/Type.purs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Data.Set as Set
import Data.String.CodeUnits as String
import Data.Traversable (sequence)
import Data.Tuple (Tuple(..))
import Debug.Trace (trace)
import Lunarbox.Data.Dataflow.Class.Substituable (Substitution(..), apply, ftv)
import Lunarbox.Data.Dataflow.Type (TVarName(..), Type(..), typeBool, typeNumber, typeString)
import Lunarbox.Data.Editor.FunctionData (FunctionData, _FunctionDataInputs)
Expand Down Expand Up @@ -78,6 +79,12 @@ generateColorPair currentLocation pinType = do
color <- case pinType of
TVarariable name' -> Right $ RGB shade shade shade
where
a =
if currentLocation == InputPin 0 then
trace name' identity
else
unit

shade = seededInt (show name') 100 255
other -> note (UnableToColor other) $ typeToColor other
pure $ Tuple currentLocation color
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Editor/Add.purs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Lunarbox.Data.Editor.ExtendedLocation (ExtendedLocation(..))
import Lunarbox.Data.Editor.FunctionData (FunctionData)
import Lunarbox.Data.Editor.FunctionName (FunctionName)
import Lunarbox.Data.Editor.Location (Location)
import Lunarbox.Data.Editor.Node (Node(..))
import Lunarbox.Data.Editor.Node (Node(..), hasOutput)
import Lunarbox.Data.Editor.Node.NodeDescriptor (NodeDescriptor, describe)
import Lunarbox.Data.Editor.Node.PinLocation (Pin(..))
import Lunarbox.Data.Editor.Project (Project)
Expand Down Expand Up @@ -56,7 +56,7 @@ nodeInput typeMap name functionData =
, node
, functionData
, labels: mempty
, hasOutput: false
, hasOutput: hasOutput node
, colorMap:
either (const mempty) identity
$ generateTypeMap
Expand Down
11 changes: 7 additions & 4 deletions src/Component/Editor/Node.purs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Lunarbox.Data.Editor.Node.NodeData (NodeData(..))
import Lunarbox.Data.Editor.Node.PinLocation (Pin(..))
import Lunarbox.Svg.Attributes (Linecap(..), strokeDashArray, strokeLinecap, strokeWidth, transparent)
import Math (pi)
import Svg.Attributes (Color)
import Svg.Attributes as SA
import Svg.Elements as SE

Expand All @@ -42,13 +43,13 @@ type Actions a
= { select :: Maybe a
}

output :: forall r a. Boolean -> HTML r a
output false = HH.text ""
output :: forall r a. Boolean -> Color -> HTML r a
output false _ = HH.text ""

output true =
output true color =
SE.circle
[ SA.r 10.0
, SA.fill $ Just $ SA.RGB 118 255 0
, SA.fill $ Just color
]

constant :: forall r a. HTML r a
Expand All @@ -75,6 +76,8 @@ node { nodeData: NodeData { position }
]
[ overlays $ label <$> labels
, output hasOutput
$ fromMaybe transparent
$ Map.lookup OutputPin colorMap
, let
inputNames = Array.toUnfoldable $ _.name <$> inputs

Expand Down

0 comments on commit eddd2b3

Please sign in to comment.