Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FFI to EffectFnX types #90

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
forgot to uncurry setLineCapImpl and setLineJoinImpl
gbagan committed May 10, 2023
commit c1d56f86fb2fe53a4c774968a459de457d023a17
20 changes: 10 additions & 10 deletions src/Graphics/Canvas.purs
Original file line number Diff line number Diff line change
@@ -275,13 +275,13 @@ data LineCap = Round | Square | Butt

derive instance eqLineCap :: Eq LineCap

foreign import setLineCapImpl :: Context2D -> String -> Effect Unit
foreign import setLineCapImpl :: EffectFn2 Context2D String Unit

-- | Set the current line cap type.
setLineCap :: Context2D -> LineCap -> Effect Unit
setLineCap context Round = setLineCapImpl context "round"
setLineCap context Square = setLineCapImpl context "square"
setLineCap context Butt = setLineCapImpl context "butt"
setLineCap context Round = runEffectFn2 setLineCapImpl context "round"
setLineCap context Square = runEffectFn2 setLineCapImpl context "square"
setLineCap context Butt = runEffectFn2 setLineCapImpl context "butt"

-- Note that we can't re-use `Round` from LineCap, so I've added `Join` to all of these

@@ -290,13 +290,13 @@ data LineJoin = BevelJoin | RoundJoin | MiterJoin

derive instance eqLineJoin :: Eq LineJoin

foreign import setLineJoinImpl :: Context2D -> String -> Effect Unit
foreign import setLineJoinImpl :: EffectFn2 Context2D String Unit

-- | Set the current line join type.
setLineJoin :: Context2D -> LineJoin -> Effect Unit
setLineJoin context BevelJoin = setLineJoinImpl context "bevel"
setLineJoin context RoundJoin = setLineJoinImpl context "round"
setLineJoin context MiterJoin = setLineJoinImpl context "miter"
setLineJoin context BevelJoin = runEffectFn2 setLineJoinImpl context "bevel"
setLineJoin context RoundJoin = runEffectFn2 setLineJoinImpl context "round"
setLineJoin context MiterJoin = runEffectFn2 setLineJoinImpl context "miter"

-- | Enumerates the different types of composite operations and blend modes.
data Composite
@@ -665,12 +665,12 @@ textBaseline ctx = unsafeParseTextBaseline <$> runEffectFn1 textBaselineImpl ctx
unsafeParseTextBaseline align = unsafeThrow $ "invalid TextBaseline: " <> align
-- ^ dummy to silence compiler warnings

foreign import setTextBaselineImpl :: Context2D -> String -> Effect Unit
foreign import setTextBaselineImpl :: EffectFn2 Context2D String Unit

-- | Set the current text baseline.
setTextBaseline :: Context2D -> TextBaseline -> Effect Unit
setTextBaseline ctx textbaseline =
setTextBaselineImpl ctx (toString textbaseline)
runEffectFn2 setTextBaselineImpl ctx (toString textbaseline)
where
toString BaselineTop = "top"
toString BaselineHanging = "hanging"