Skip to content

Commit

Permalink
adjusted colors in plasma
Browse files Browse the repository at this point in the history
  • Loading branch information
ittna committed Apr 2, 2016
1 parent d4934e8 commit d566670
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Plasma.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Plasma(plasma) where
module Plasma(plasma, main) where

import Graphics.Element exposing (..)
import Math.Vector3 exposing (..)
Expand All @@ -24,6 +24,10 @@ mesh = Triangle
)
]

main : Signal Element
main =
Signal.map3 plasma Window.width Window.height (Signal.foldp (+) 0 (fps 30))

plasma : Int -> Int -> Float -> Element
plasma w h t =
webgl (w,h) [ render vertexShader fragmentShader mesh { perspective = (makeOrtho2D 0 1 0 1), t = t / 100 } ]
Expand Down Expand Up @@ -51,6 +55,13 @@ varying vec3 pos;
const float pi = 3.1415926;
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main () {
vec2 c = 2.0 * (pos.xy + vec2(sin(t / 5.0), cos(t / 3.0)));
Expand All @@ -60,6 +71,6 @@ void main () {
float v = v1 + v2 + v3;
gl_FragColor = vec4(0.3 * (sin(v * pi) + 1.0), 0.4 * (sin(v * pi + 2.0 * pi / 3.0) + 1.0), 0.5 * (sin(v * pi + 4.0 * pi / 3.0) + 1.0), 1.0);
gl_FragColor = vec4(hsv2rgb(vec3(v / 2.0, 0.99, 1.0)), 1.0);
}
|]

0 comments on commit d566670

Please sign in to comment.