Skip to content

Commit

Permalink
fixed bugs in fract
Browse files Browse the repository at this point in the history
  • Loading branch information
dktr0 committed Oct 25, 2024
1 parent 24c7642 commit 6cc332d
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 86 deletions.
168 changes: 84 additions & 84 deletions punctual.js

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion src/Expr.purs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ instance Expr Float where

instance Channels Float where channels _ = 1

derive instance Eq Float
derive instance Generic Float _
instance Show Float where
show x = genericShow x


data Vec2 =
Vec2Constant Number Number |
Expand Down Expand Up @@ -116,6 +121,11 @@ instance Expr Vec2 where

instance Channels Vec2 where channels _ = 2

derive instance Eq Vec2
derive instance Generic Vec2 _
instance Show Vec2 where
show x = genericShow x


data Vec3 =
Vec3Constant Number Number Number |
Expand Down Expand Up @@ -149,6 +159,11 @@ instance Expr Vec3 where

instance Channels Vec3 where channels _ = 3

derive instance Eq Vec3
derive instance Generic Vec3 _
instance Show Vec3 where
show x = genericShow x


data Vec4 =
Vec4Constant Number Number Number Number |
Expand Down Expand Up @@ -182,6 +197,11 @@ instance Expr Vec4 where

instance Channels Vec4 where channels _ = 1

derive instance Eq Vec4
derive instance Generic Vec4 _
instance Show Vec4 where
show x = genericShow x


floatsToVec2s :: NonEmptyList Float -> NonEmptyList Vec2
floatsToVec2s = concat <<< unfoldr1 unconsFloatsToVec2s
Expand Down Expand Up @@ -567,7 +587,7 @@ tan :: forall a. Expr a => a -> a
tan = unaryFunction Number.tan (function1 "tan")

fract :: forall a. Expr a => a -> a
fract = unaryFunction (\x -> Prelude.mod x 1.0) (function1 "fract")
fract = unaryFunction (\x -> Number.abs $ Number.remainder x 1.0) (function1 "fract")


-- Arithmetic operations
Expand Down
2 changes: 1 addition & 1 deletion src/W.purs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ ampdb :: Sample -> W Sample
ampdb x = assign $ "20 * Math.log10(" <> showSample x <> ")"

fract :: Sample -> W Sample
fract x = assign $ showSample x <> "%1"
fract x = assign $ "Math.abs(" <> showSample x <> "%1)"

operator :: (Number -> Number -> Number) -> String -> Sample -> Sample -> W Sample
operator f _ (Left x) (Left y) = pure $ Left (f x y)
Expand Down

0 comments on commit 6cc332d

Please sign in to comment.