Skip to content

Commit b9fc07b

Browse files
committed
Add mult, blend, and add to stdlib
1 parent 0df306f commit b9fc07b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

std.yin

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ mask c0 c1 = let
199199
b = vec3 a a a * c0.rgb
200200
in vec4 b.r b.g b.b a
201201

202+
add : Vec4 -> Vec4 -> Float -> Vec4
203+
add c0 c1 amount = (c0 + c1) * cast4 amount + c0 * cast4 (1.0 - amount)
204+
205+
blend : Vec4 -> Vec4 -> Float -> Vec4
206+
blend c0 c1 amount = c0 * cast4 (1.0 - amount) + c1 * cast4 amount
207+
208+
mult : Vec4 -> Vec4 -> Float -> Vec4
209+
mult c0 c1 amount = c0 * cast4 (1.0 - amount) + c1 * cast4 amount
210+
202211
diff : Vec4 -> Vec4 -> Vec4
203212
diff c0 c1 = let
204213
difference = c0.rgb - c1.rgb
@@ -226,7 +235,7 @@ osc st time freq sync offset = let
226235

227236
modulate : Vec2 -> Vec4 -> Float -> Vec2
228237
modulate st color amount = let
229-
a = color.xy * vec2 amount amount
238+
a = color.xy * cast2 amount
230239
in st + a
231240

232241
# TODO why did the type checker choke so bad on this

0 commit comments

Comments
 (0)