From 0489a092bcae859c2a54ed5c51397177c3d28f2b Mon Sep 17 00:00:00 2001 From: jgk Date: Fri, 12 Mar 2021 15:25:07 +0100 Subject: [PATCH] First implementation of quadratic bezier curve shader --- shader/Old/basicTexture.frag | 15 ++++++++++++ shader/Old/basicTexture.geom | 36 +++++++++++++++++++++++++++++ shader/Old/basicTexture.vert | 20 ++++++++++++++++ shader/Old/circle.frag | 18 +++++++++++++++ shader/Old/circle.geom | 33 ++++++++++++++++++++++++++ shader/Old/circle.vert | 19 +++++++++++++++ shader/Old/fadeCircle.frag | 16 +++++++++++++ shader/Old/fadeCircle.geom | 30 ++++++++++++++++++++++++ shader/Old/fadeCircle.vert | 15 ++++++++++++ shader/Old/fullFadeCircle.frag | 12 ++++++++++ shader/Old/fullFadeCircle.geom | 30 ++++++++++++++++++++++++ shader/Old/fullFadeCircle.vert | 12 ++++++++++ shader/bezierQuad.frag | 19 +++++++++++++++ shader/bezierQuad.geom | 28 +++++++++++++++++++++++ shader/bezierQuad.vert | 16 +++++++++++++ src/Dodge/Item/Weapon.hs | 23 +++++++++++++++++++ src/Dodge/Rendering.hs | 8 +++++-- src/Picture.hs | 4 ++++ src/Picture/Data.hs | 2 ++ src/Picture/Preload.hs | 11 ++++++++- src/Picture/Tree.hs | 42 +++++++--------------------------- 21 files changed, 372 insertions(+), 37 deletions(-) create mode 100644 shader/Old/basicTexture.frag create mode 100644 shader/Old/basicTexture.geom create mode 100644 shader/Old/basicTexture.vert create mode 100644 shader/Old/circle.frag create mode 100644 shader/Old/circle.geom create mode 100644 shader/Old/circle.vert create mode 100644 shader/Old/fadeCircle.frag create mode 100644 shader/Old/fadeCircle.geom create mode 100644 shader/Old/fadeCircle.vert create mode 100644 shader/Old/fullFadeCircle.frag create mode 100644 shader/Old/fullFadeCircle.geom create mode 100644 shader/Old/fullFadeCircle.vert create mode 100644 shader/bezierQuad.frag create mode 100644 shader/bezierQuad.geom create mode 100644 shader/bezierQuad.vert diff --git a/shader/Old/basicTexture.frag b/shader/Old/basicTexture.frag new file mode 100644 index 000000000..a1cefb0e9 --- /dev/null +++ b/shader/Old/basicTexture.frag @@ -0,0 +1,15 @@ +#version 430 core +out vec4 FragColor; + +in vec4 gColor; +in vec2 gTex; + +uniform sampler2D aTexture; + +void main() +{ + FragColor = texture(aTexture, gTex) * gColor; +// FragColor = texture(aTexture, vTexCoord); +// FragColor = gColor; +// FragColor = vec4 (1,1,1,1); +} diff --git a/shader/Old/basicTexture.geom b/shader/Old/basicTexture.geom new file mode 100644 index 000000000..a3e1851e4 --- /dev/null +++ b/shader/Old/basicTexture.geom @@ -0,0 +1,36 @@ +#version 430 core +layout (points) in; +layout (triangle_strip, max_vertices = 4) out; +in vec4 vColor []; +in vec2 vTexCoord []; +out vec4 gColor; +out vec2 gTex; +void main() +{ + vec3 cenPos = gl_in[0].gl_Position.xyz; + float size = vTexCoord[0].y; + //float size = 0.05; + gColor = vColor[0]; + float texPos = vTexCoord[0].x; + + gl_Position = vec4 (cenPos.x - size*0.5, cenPos.y - size, cenPos.z , 1); + //gl_Position = vec4 (0, 0 , 5 , 1); + gTex = vec2 (texPos*0.0078125, 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x - size*0.5, cenPos.y + size, cenPos.z , 1); + //gl_Position = vec4 (0, 0.5 , 5 , 1); + gTex = vec2 (texPos*0.0078125, 0); + EmitVertex(); + gl_Position = vec4 (cenPos.x + size*0.5, cenPos.y - size, cenPos.z , 1); + //gl_Position = vec4 (0.5, 0.5 , -5 , 1); + gTex = vec2 ((texPos+1)*0.0078125, 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x + size*0.5, cenPos.y + size, cenPos.z , 1); + gTex = vec2 ((texPos+1)*0.0078125, 0); + //gl_Position = vec4 (0.5, 0 , -5 , 1); + EmitVertex(); + + + EndPrimitive(); + +} diff --git a/shader/Old/basicTexture.vert b/shader/Old/basicTexture.vert new file mode 100644 index 000000000..cc19a07cd --- /dev/null +++ b/shader/Old/basicTexture.vert @@ -0,0 +1,20 @@ +#version 430 core +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec4 aColor; +layout (location = 2) in vec2 aTexCoord; + +uniform vec2 winSize; +uniform float zoom; +uniform vec2 translation; +uniform float rotation; + +out vec4 vColor; +out vec2 vTexCoord; + +void main() +{ + gl_Position = vec4(aPos, 1.0); + vColor = aColor; + vTexCoord = aTexCoord; +} + diff --git a/shader/Old/circle.frag b/shader/Old/circle.frag new file mode 100644 index 000000000..1396eaf73 --- /dev/null +++ b/shader/Old/circle.frag @@ -0,0 +1,18 @@ +#version 430 core +in vec4 gColor; +in vec2 cenPosT; +in float gRad; +out vec4 fColor; +out float gl_FragDepth; + +void main() +{ + vec2 pos = gl_FragCoord.xy; + // fColor = vec4( gColor.xyz , 0 ); + // fColor = vec4( gColor.xyz , 1 - step(distance(pos,cenPos.xy),gRad) ); + // fColor = vec4( gColor.xyz , distance(pos,cenPos.xy)/gRad ); +// fColor = vec4( gColor.rgb, gColor.a * (1-step(gRad/2,distance(pos,cenPosT))) ); + gl_FragDepth = max(gl_FragCoord.z , step(gRad/2,distance(pos,cenPosT))); + fColor = gColor; +} +//note it is the fragdepth that stops this from being square diff --git a/shader/Old/circle.geom b/shader/Old/circle.geom new file mode 100644 index 000000000..2096c3d45 --- /dev/null +++ b/shader/Old/circle.geom @@ -0,0 +1,33 @@ +#version 430 core +layout (points) in; +layout (triangle_strip, max_vertices = 4) out; +in vec4 vColor []; +in float vRad []; +out vec4 gColor; +out float gRad; +out vec2 cenPosT; + +uniform vec2 winSize; +uniform float zoom; + +void main() +{ + vec3 cenPos = gl_in[0].gl_Position.xyz; + //cenPos = vec3 (0.5,0,0); + gColor = vColor[0]; + gRad = vRad[0] * zoom * 2; +// gRad = 0.2; + + cenPosT = vec2 ( (cenPos.x + 1) * 0.5 * winSize.x , (cenPos.y + 1) * 0.5 * winSize.y); + + gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y - gRad/winSize.y, cenPos.z , 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y - gRad/winSize.y, cenPos.z , 1); + EmitVertex(); + + EndPrimitive(); +} diff --git a/shader/Old/circle.vert b/shader/Old/circle.vert new file mode 100644 index 000000000..e7e584a65 --- /dev/null +++ b/shader/Old/circle.vert @@ -0,0 +1,19 @@ +#version 430 core +layout (location = 0) in vec3 position; +layout (location = 1) in vec4 color; +layout (location = 2) in float rad; +out vec4 vColor; +out float vRad; + +uniform vec2 winSize; +uniform float zoom; +uniform vec2 translation; +uniform float rotation; +uniform mat4 worldMat; + +void main() +{ + gl_Position = worldMat * vec4(position,1); + vColor = color; + vRad = rad; +} diff --git a/shader/Old/fadeCircle.frag b/shader/Old/fadeCircle.frag new file mode 100644 index 000000000..953111146 --- /dev/null +++ b/shader/Old/fadeCircle.frag @@ -0,0 +1,16 @@ +#version 430 core +in vec2 cenPosT; +in vec2 gParams; +out vec4 fColor; + +void main() +{ + vec2 pos = gl_FragCoord.xy; + float dist = min(1 , 2*distance(pos,cenPosT) / (gParams.x)); + //float c = pow(gParams.y*dist,2); + float c = gParams.y * pow(1-dist,2); + //float c = gParams.y; + fColor = vec4( c,c,c ,c ); +// fColor = vec4( 1,0,0 , 1); +// fColor = vec4( 1,0,0 , pow(dist,2) ); +} diff --git a/shader/Old/fadeCircle.geom b/shader/Old/fadeCircle.geom new file mode 100644 index 000000000..1f1122440 --- /dev/null +++ b/shader/Old/fadeCircle.geom @@ -0,0 +1,30 @@ +#version 430 core +layout (points) in; +layout (triangle_strip, max_vertices = 4) out; +in vec2 vParams []; +out vec2 gParams; +out vec2 cenPosT; + +uniform vec2 winSize; +uniform float zoom; + +void main() +{ + vec3 cenPos = gl_in[0].gl_Position.xyz; + //cenPos = vec3 (0.5,0,0); + gParams = vec2( vParams[0].x * zoom * 2, vParams[0].y); + float gRad = gParams.x; + + cenPosT = vec2 ( (cenPos.x + 1) * 0.5 * winSize.x , (cenPos.y + 1) * 0.5 * winSize.y); + + gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y + gRad/winSize.y, 0.9 , 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y + gRad/winSize.y, 0.9 , 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y - gRad/winSize.y, 0.9 , 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y - gRad/winSize.y, 0.9 , 1); + EmitVertex(); + + EndPrimitive(); +} diff --git a/shader/Old/fadeCircle.vert b/shader/Old/fadeCircle.vert new file mode 100644 index 000000000..0498314fe --- /dev/null +++ b/shader/Old/fadeCircle.vert @@ -0,0 +1,15 @@ +#version 430 core +layout (location = 0) in vec4 position; +out vec2 vParams; + +uniform vec2 winSize; +uniform float zoom; +uniform vec2 translation; +uniform float rotation; +uniform mat4 worldMat; + +void main() +{ + gl_Position = vec4(position.xy,0,1); + vParams = position.zw; +} diff --git a/shader/Old/fullFadeCircle.frag b/shader/Old/fullFadeCircle.frag new file mode 100644 index 000000000..45ca0c969 --- /dev/null +++ b/shader/Old/fullFadeCircle.frag @@ -0,0 +1,12 @@ +#version 430 core +in vec4 gColor; +in vec2 cenPosTrans; +in float gRad; +out vec4 fColor; + +void main() +{ + vec2 pos = gl_FragCoord.xy; + float dist = max(0 , 1 - 2 * distance(pos,cenPosTrans) / (gRad)); + fColor = vec4( gColor.xyz , pow(gColor.z*dist,2) ); +} diff --git a/shader/Old/fullFadeCircle.geom b/shader/Old/fullFadeCircle.geom new file mode 100644 index 000000000..4d696433c --- /dev/null +++ b/shader/Old/fullFadeCircle.geom @@ -0,0 +1,30 @@ +#version 430 core +layout (points) in; +layout (triangle_strip, max_vertices = 4) out; +in vec4 vColor []; +in float vRad []; +uniform vec2 winSize; +out vec4 gColor; +out float gRad; +out vec2 cenPosTrans; +void main() +{ + vec3 cenPos = gl_in[0].gl_Position.xyz; + vec2 cenPosa = cenPos.xy + vec2 (1,1); + cenPosTrans = vec2 (cenPosa * winSize * 0.5); + gColor = vColor[0]; + gRad = vRad[0]; + + gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y - gRad/winSize.y, cenPos.z , 1); + EmitVertex(); + gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y - gRad/winSize.y, cenPos.z , 1); + EmitVertex(); + + + EndPrimitive(); + +} diff --git a/shader/Old/fullFadeCircle.vert b/shader/Old/fullFadeCircle.vert new file mode 100644 index 000000000..2046f8894 --- /dev/null +++ b/shader/Old/fullFadeCircle.vert @@ -0,0 +1,12 @@ +#version 430 core +layout (location = 0) in vec3 position; +layout (location = 1) in vec4 color; +layout (location = 2) in float rad; +out vec4 vColor; +out float vRad; +void main() +{ + gl_Position = vec4(position,1); + vColor = color; + vRad = rad; +} diff --git a/shader/bezierQuad.frag b/shader/bezierQuad.frag new file mode 100644 index 000000000..5e415103e --- /dev/null +++ b/shader/bezierQuad.frag @@ -0,0 +1,19 @@ +#version 430 core +in vec4 gColor; +in vec3 gBoundingBox; + +out vec4 fColor; + +float x = gBoundingBox.x; +float y = gBoundingBox.y; +float z = gBoundingBox.z; + +void main() +{ + //float d = x - y - 1 + 2* sqrt(y); + float d = sqrt(x) + sqrt(y) - 1; +// if ( d < -0.1 || d > 0.1) { discard; } + fColor = gColor; + if ( d < -z*0.1 || d > z*0.1) { fColor = vec4 (0,1,0,1); } + if ( d < -0.1 || d > 0.1) { fColor = vec4 (0,0,1,1); } +} diff --git a/shader/bezierQuad.geom b/shader/bezierQuad.geom new file mode 100644 index 000000000..cb4d56003 --- /dev/null +++ b/shader/bezierQuad.geom @@ -0,0 +1,28 @@ +#version 430 core +layout (triangles) in; +layout (triangle_strip, max_vertices = 3) out; +in vec4 vColor[]; +out vec4 gColor; +out vec3 gBoundingBox; + +void main() +{ + vec3 pa = gl_in[0].gl_Position.xyz; + vec3 pb = gl_in[1].gl_Position.xyz; + vec3 pc = gl_in[2].gl_Position.xyz; + + gBoundingBox = vec3 (1,0,1); + gColor = vColor[0]; + gl_Position = vec4 (pa, 1); + EmitVertex(); + gBoundingBox = vec3 (0,0,-0.9); + gColor = vColor[1]; + gl_Position = vec4 (pb, 1); + EmitVertex(); + gBoundingBox = vec3 (0,1,1); + gColor = vColor[2]; + gl_Position = vec4 (pc, 1); + EmitVertex(); + + EndPrimitive(); +} diff --git a/shader/bezierQuad.vert b/shader/bezierQuad.vert new file mode 100644 index 000000000..aac780c96 --- /dev/null +++ b/shader/bezierQuad.vert @@ -0,0 +1,16 @@ +#version 430 core +layout (location = 0) in vec3 position; +layout (location = 1) in vec4 color; +out vec4 vColor; + +uniform vec2 winSize; +uniform float zoom; +uniform float rotation; +uniform vec2 translation; +uniform mat4 worldMat; + +void main() +{ + gl_Position = worldMat * vec4(position.xyz,1); + vColor = color; +} diff --git a/src/Dodge/Item/Weapon.hs b/src/Dodge/Item/Weapon.hs index a86829a03..7c75d599a 100644 --- a/src/Dodge/Item/Weapon.hs +++ b/src/Dodge/Item/Weapon.hs @@ -335,6 +335,11 @@ launcher = defaultGun , _itHammer = NoHammer , _itEffect = NoItEffect } +bezierGun = defaultGun + { _itName = "B-GUN" + , _wpFire = bezierTarget + } + remoteLauncher = defaultGun { _itName = "ROCKO-REM" , _itIdentity = RemoteLauncher @@ -1402,6 +1407,24 @@ grenadePic x = pictures [ color (dark $ dark green) $ circleSolid 5 $ scale 0.05 0.05 $ color green $ text $ show $ 1 + quot x 20 ] +bezierTarget :: Int -> World -> World +bezierTarget cid w = setTarget w + where + j = _crInvSel $ _creatures w IM.! cid + setTarget = set (creatures . ix cid . crInv . ix j . wpFire) $ bezierControl p + p = mouseWorldPos w + +bezierControl :: Point2 -> Int -> World -> World +bezierControl targetp cid w = shootWithSound 0 (mkBezierBul startp controlp targetp) cid w + where + controlp = mouseWorldPos w + cr = _creatures w IM.! cid + dir = _crDir cr + startp = _crPos cr +.+ rotateV dir (_crRad cr + 1,0) + +mkBezierBul :: Point2 -> Point2 -> Point2 -> Int -> World -> World +mkBezierBul startp controlp targetp cid w = w + fireRemoteLauncher :: Int -> World -> World fireRemoteLauncher cid w = setLocation $ resetFire $ resetName $ soundOnce (fromIntegral launcherSound) diff --git a/src/Dodge/Rendering.hs b/src/Dodge/Rendering.hs index 8e67c3085..353d9110a 100644 --- a/src/Dodge/Rendering.hs +++ b/src/Dodge/Rendering.hs @@ -75,6 +75,7 @@ worldPictures w -- , itLabels , ppLabels , btLabels + , testPic w ] where decPicts = IM.elems $ _decorations w @@ -119,6 +120,11 @@ worldPictures w ] where tst x y sc t = translate x y $ scale sc sc $ color white $ text t +testPic :: World -> [Picture] +testPic w = [setLayer 1 $ onLayerL [99] $ color red $ bezierQuad (-90,0) (90,-50) (-200,200) ] +-- $ uncurry translate (mouseWorldPos w) + + hudDrawings :: World -> Picture hudDrawings w = setLayer 1 $ (onLayer InvLayer) $ pictures @@ -463,8 +469,6 @@ displayHP n w = translate (halfWidth w-80) (halfHeight w-20) $ scale 0.2 0.2 $ text $ reverse $ take 5 $ (++ repeat ' ') $ reverse $ show $ _crHP $ _creatures w IM.! n -testPic w = blank - wallsForGloom :: World -> [(Point2,Point2,Point2,Point2)] wallsForGloom w = map (linePairs . _wlLine) $ filter (not . _wlIsSeeThrough) $ filter wallCastsShadow diff --git a/src/Picture.hs b/src/Picture.hs index a754cb544..d4790ccf5 100644 --- a/src/Picture.hs +++ b/src/Picture.hs @@ -4,6 +4,7 @@ module Picture ( module Picture.Data , polygon , polygonCol + , bezierQuad , arc , arcSolid , thickArc @@ -68,6 +69,9 @@ polygonCol :: [(Point2,RGBA)] -> Picture {-# INLINE polygonCol #-} polygonCol = PolygonCol 0 +bezierQuad :: Point2 -> Point2 -> Point2 -> Picture +bezierQuad a b c = BezierQuad 0 [a,b,c] + color :: RGBA -> Picture -> Picture {-# INLINE color #-} color c pic = OverPic id id 0 (const c) pic diff --git a/src/Picture/Data.hs b/src/Picture/Data.hs index 7fd4ea1f5..5cf63a2ed 100644 --- a/src/Picture/Data.hs +++ b/src/Picture/Data.hs @@ -22,6 +22,7 @@ import Data.Traversable data RenderType = RenderPoly [(Point3,Point4)] + | RenderBezQ [(Point3,Point4)] | RenderText [(Point3,Point4,Point3)] | RenderArc (Point3,Point4,Point4) | RenderLine [(Point3,Point4)] @@ -74,6 +75,7 @@ data Picture = Blank | Text Int String | Polygon Int [Point2] + | BezierQuad Int [Point2] | PolygonCol Int [(Point2,RGBA)] | Circle Int RGBA RGBA Float | ThickArc Int Float Float Float Float diff --git a/src/Picture/Preload.hs b/src/Picture/Preload.hs index a6df89073..b9fa41774 100644 --- a/src/Picture/Preload.hs +++ b/src/Picture/Preload.hs @@ -49,6 +49,9 @@ preloadRender = do [(0,3),(1,4),(2,3)] Points pokeCharStrat "data/texture/charMap.png" + bezierQuadShader + <- makeShader "bezierQuad" [vert,geom,frag] [(0,3),(1,4)] Triangles pokeBezQStrat + --the following vbo is set up to contain one fixed vertex dummyvbo <- genObjectName dummyptr <- mallocArray numDrawableElements @@ -61,7 +64,7 @@ preloadRender = do backgroundvao <- setupVAO [(0,4),(1,2)] return $ RenderData - { _listShaders = [bslist,lslist,cslist,aslist,eslist] + { _listShaders = [bslist,lslist,cslist,aslist,eslist,bezierQuadShader] , _dummyVBO = dummyvbo , _dummyPtr = dummyptr , _lightSourceShader = lsShad @@ -79,7 +82,13 @@ cleanUpRenderPreload pd = do freeShaderPointers $ _backgroundShader pd free $ _dummyPtr pd +{-# INLINE pokeBezQStrat #-} +pokeBezQStrat :: RenderType -> [[[Float]]] +pokeBezQStrat (RenderBezQ vs) = fmap (\((x,y,z),(r,g,b,a)) -> [[x,y,z],[r,g,b,a]]) vs +pokeBezQStrat _ = [] + {-# INLINE pokeTriStrat #-} +pokeTriStrat :: RenderType -> [[[Float]]] pokeTriStrat (RenderPoly vs) = fmap (\((x,y,z),(r,g,b,a)) -> [[x,y,z],[r,g,b,a]]) vs pokeTriStrat _ = [] diff --git a/src/Picture/Tree.hs b/src/Picture/Tree.hs index b259cfc88..679475507 100644 --- a/src/Picture/Tree.hs +++ b/src/Picture/Tree.hs @@ -8,13 +8,17 @@ import Geometry import Data.Bifunctor import Data.List +-- todo: refactor out the layer check somehow +-- consider generalising to alternative rather than using LTree picToLTree :: Maybe Int -> Picture -> LTree RenderType {-# INLINE picToLTree #-} picToLTree mx (Polygon i ps) = filtB mx i $ LLeaf $ RenderPoly $ zip (map zeroZ $ polyToTris ps) $ repeat black -picToLTree mx (PolygonCol i vs) = - filtB mx i $ LLeaf $ RenderPoly $ zip (map zeroZ $ polyToTris ps) $ polyToTris cs +picToLTree mx (PolygonCol i vs) + = filtB mx i $ LLeaf $ RenderPoly $ zip (map zeroZ $ polyToTris ps) $ polyToTris cs where (ps,cs) = unzip vs +picToLTree mx (BezierQuad i ps) + = filtB mx i $ LLeaf $ RenderBezQ $ zip (map zeroZ $ ps) $ repeat black picToLTree mx (Circle i colC colE r) = filtB mx i $ LLeaf $ RenderEllipse [( (-r, r,0), colC) ,( (-r,-r,0), colE) @@ -64,6 +68,7 @@ scaleT (x,y) (a,b,(o,s,t)) = (a,b,(o,s*x,t*y)) overPos :: (Point3 -> Point3) -> RenderType -> RenderType {-# INLINE overPos #-} overPos f (RenderPoly vs) = RenderPoly $ map (first $ f) vs +overPos f (RenderBezQ vs) = RenderBezQ $ map (first $ f) vs overPos f (RenderLine vs) = RenderLine $ map (first $ f) vs overPos f (RenderText vs) = RenderText $ map (\(a,b,c) -> (f a,b,c)) vs overPos f (RenderEllipse vs) = RenderEllipse $ map (first f) vs @@ -77,6 +82,7 @@ overRot _ ren = ren overCol :: (Point4 -> Point4) -> RenderType -> RenderType {-# INLINE overCol #-} overCol f (RenderPoly vs) = RenderPoly $ map (second $ f) vs +overCol f (RenderBezQ vs) = RenderBezQ $ map (second $ f) vs overCol f (RenderLine vs) = RenderLine $ map (second $ f) vs overCol f (RenderEllipse vs) = RenderEllipse $ map (second $ f) vs overCol f (RenderText vs) = RenderText $ map (\(a,b,c) -> (a,f b,c)) vs @@ -112,35 +118,3 @@ rotate3 :: Float -> Point3 -> Point3 rotate3 a (x,y,z) = (x',y',z) where (x',y') = rotateV a (x,y) ---picToAlt :: (Ap.Alternative f, Monoid (f RenderType)) => Int -> Picture -> f RenderType ---{-# INLINE picToAlt #-} ---picToAlt x (Polygon i ps) --- | i == x = Ap.pure $ RenderPoly $ zip (map zeroZ $ polyToTris ps) $ repeat black --- | otherwise = Ap.empty ---picToAlt x (PolygonCol i vs) --- | i /= x = Ap.empty --- | otherwise = --- let (ps,cs) = unzip vs --- in Ap.pure $ RenderPoly $ zip (map zeroZ $ polyToTris ps) $ polyToTris cs ---picToAlt x (Circle i r) --- | i == x = Ap.pure $ RenderCirc $ ((0,0,0),black,r) --- | otherwise = Ap.empty ---picToAlt x (Ellipse i (ax,ay) (bx,by) r) --- | i == x = Ap.pure $ RenderEllipse [((ax,ay+r,0),black) --- ,((ax,ay-r,0),black) --- ,((bx,by-r,0),black) --- ] --- | otherwise = Ap.empty ---picToAlt x (ThickArc i startA endA rad wdth) --- | i == x = Ap.pure $ RenderArc $ ((0,0,0),black,(startA,endA,rad,wdth)) --- | otherwise = Ap.empty ---picToAlt x (Line i ps) --- | i == x = Ap.pure $ RenderLine $ zip (map zeroZ $ doubleLine ps) $ repeat white --- | otherwise = Ap.empty ---picToAlt x (Text i s) --- | i == x = Ap.pure $ RenderText $ stringToList s --- | otherwise = Ap.empty ---picToAlt j Blank = Ap.empty ---picToAlt j (Pictures pics) = mconcat $ fmap (picToAlt j) pics - -