<commit_before>module Graphics.WebGL (mapTriangle, zipTriangle, loadTex, model, webgl) where

{-| The WebGL API is for high performance drawing.

# Triangle Convenience Functions
@docs Triangle, mapTriangle, zipTriangle

# Shaders
Shaders are created using glsl blocks. 

vertex : Shader { a | pos : V3 } {} {}
vertex = [glsl|

attribute vec3 pos;

void main () {
  gl_Position = vec4(pos,1.0);
}

|]

# WebGL Element
@docs webgl

-}

import Graphics.Element (Element)
import Http (Response)
import Native.Graphics.WebGL
import Signal (Signal)

unsafeCoerceGLSL : String -> Shader attr unif vary
unsafeCoerceGLSL = Native.Graphics.WebGL.unsafeCoerceGLSL

type Triangle a = (a,a,a)

mapTriangle : (a -> b) -> Triangle a -> Triangle b
mapTriangle f (x,y,z) = (f x, f y, f z)

zipTriangle : (a -> b -> c) -> Triangle a -> Triangle b -> Triangle c
zipTriangle f (x,y,z) (x',y',z') = (f x x', f y y', f z z')

data Shader attr unif vary = Shader

data Texture = Texture

loadTex : String -> Signal (Response Texture)
loadTex = Native.Graphics.WebGL.loadTex

data Model = Model 

model : Shader attr unif vary -> Shader {} unif vary -> [Triangle attr] -> unif -> Model
model = Native.Graphics.WebGL.model

webgl : (Int,Int) -> [Model] -> Element
webgl = Native.Graphics.WebGL.webgl<commit_msg>docs that are compatible with elm-get<commit_after>module Graphics.WebGL (mapTriangle, zipTriangle, loadTex, model, webgl) where

{-| The WebGL API is for high performance drawing.

# Triangle Convenience Functions
@docs mapTriangle, zipTriangle

# Shaders
Shaders are created using glsl blocks. 

vertex : Shader { a | pos : V3 } {} {}
vertex = [glsl|

attribute vec3 pos;

void main () {
  gl_Position = vec4(pos,1.0);
}

\]

# WebGL Element
@docs loadTex, model, webgl

-}

import Graphics.Element (Element)
import Http (Response)
import Native.Graphics.WebGL
import Signal (Signal)

unsafeCoerceGLSL : String -> Shader attr unif vary
unsafeCoerceGLSL = Native.Graphics.WebGL.unsafeCoerceGLSL

{-| An alias for a 3-tuple -}
type Triangle a = (a,a,a)

{-| Apply a function to each vertex -}
mapTriangle : (a -> b) -> Triangle a -> Triangle b
mapTriangle f (x,y,z) = (f x, f y, f z)

{-| Apply an arity-2 function element-wise on 2 triangles -}
zipTriangle : (a -> b -> c) -> Triangle a -> Triangle b -> Triangle c
zipTriangle f (x,y,z) (x',y',z') = (f x x', f y y', f z z')

{-| Opaque Shader Type -}
data Shader attr unif vary = Shader

{-| Opaque Texture Type -}
data Texture = Texture

{-| Load an image url as a texture -}
loadTex : String -> Signal (Response Texture)
loadTex = Native.Graphics.WebGL.loadTex

{-| Opaque Model Type -}
data Model = Model 

{-| A model is a collection of a fragment shader, a vertex shader, attribute data, and uniform data. -}
model : Shader attr unif vary -> Shader {} unif vary -> [Triangle attr] -> unif -> Model
model = Native.Graphics.WebGL.model

{-| Render a WebGL scene with the given dimensions and models -}
webgl : (Int,Int) -> [Model] -> Element
webgl = Native.Graphics.WebGL.webgl
{'fraction_non_alphanumeric': 0.12586949320967208, 'fraction_numerical': 0.004306061609804571, 'mean_word_length': 3.786053882725832, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2334081', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1041, 'n_words': 365}