Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
C
catchvoid
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Joris
catchvoid
Commits
44fa9fbf
Commit
44fa9fbf
authored
Mar 07, 2015
by
Joris Guyonvarch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decomposition of view into two files: page and game
parent
17a58e0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
96 deletions
+107
-96
src/Main.elm
src/Main.elm
+2
-2
src/View/Game.elm
src/View/Game.elm
+99
-0
src/View/Page.elm
src/View/Page.elm
+6
-94
No files found.
src/Main.elm
View file @
44fa9fbf
...
...
@@ -13,10 +13,10 @@ import Update.Update (update)
import
Input
(
getInput
)
import
View
.
Page
(
page
)
import
View
.
Page
(
page
View
)
main
:
Signal
Html
main
=
Signal
.
map
page
game
main
=
Signal
.
map
page
View
game
game
:
Signal
Game
game
=
...
...
src/View/Game.elm
0 → 100644
View file @
44fa9fbf
module
View
.
Game
(
gameView
)
where
import
List
import
Graphics
.
Collage
(
..
)
import
Graphics
.
Element
(
Element
)
import
Color
(
..
)
import
Text
(
..
)
import
Text
import
Model
.
Vec2
(
Vec2
)
import
Model
.
Player
(
..
)
import
Model
.
Game
(
Game
)
import
Model
.
Point
(
..
)
import
Model
.
Board
(
boardSize
)
import
Model
.
Config
(
..
)
gameView
:
Game
->
Element
gameView
{
time
,
score
,
player
,
cloud
,
bestScore
}
=
let
whitePointForms
=
List
.
map
(
pointForm
time
(
configColor
White
))
(
cloud
.
points
White
)
blackPointForms
=
List
.
map
(
pointForm
time
(
configColor
Black
))
(
cloud
.
points
Black
)
forms
=
boardForms
++
playerForms
player
++
whitePointForms
++
blackPointForms
++
scoreForms
score
++
bestScoreForms
bestScore
in
collage
(
truncate
boardSize
.
x
)
(
truncate
boardSize
.
y
)
forms
boardForms
:
List
Form
boardForms
=
[
filled
boardColor
(
rect
boardSize
.
x
boardSize
.
y
)]
boardColor
:
Color
boardColor
=
rgb
103
123
244
playerForms
:
Player
->
List
Form
playerForms
player
=
let
playerColor
=
configColor
player
.
config
in
[
circleForm
player
.
pos
playerSize
playerColor
]
playerColor
:
Color
playerColor
=
rgb
224
224
224
pointForm
:
Float
->
Color
->
Point
->
Form
pointForm
time
color
point
=
let
pos
=
pointMove
point
time
in
circleForm
pos
pointSize
color
configColor
:
Config
->
Color
configColor
config
=
case
config
of
White
->
rgb
240
240
240
Black
->
rgb
14
17
33
circleForm
:
Vec2
->
Float
->
Color
->
Form
circleForm
pos
size
color
=
let
outline
=
circle
size
|>
filled
outlineColor
inside
=
circle
(
size
-
1
)
|>
filled
color
in
group
[
outline
,
inside
]
|>
move
(
pos
.
x
,
pos
.
y
)
outlineColor
:
Color
outlineColor
=
rgb
34
34
34
scoreForms
:
Int
->
List
Form
scoreForms
score
=
let
text
=
(
toString
score
)
scorePos
=
{
x
=
0.0
,
y
=
boardSize
.
y
/
2
-
30
}
in
[
textForm
text
scorePos
centered
]
bestScoreForms
:
Int
->
List
Form
bestScoreForms
bestScore
=
if
(
bestScore
>
0
)
then
let
text
=
"
Record: "
++
(
toString
bestScore
)
pos
=
{
x
=
-
boardSize
.
x
/
2
+
100
,
y
=
-
boardSize
.
y
/
2
+
30
}
in
[
textForm
text
pos
leftAligned
]
else
[]
textForm
:
String
->
Vec2
->
(
Text
->
Element
)
->
Form
textForm
content
pos
alignment
=
let
textElement
=
fromString
content
|>
Text
.
height
30
|>
typeface
[
"
calibri"
,
"
arial"
]
|>
Text
.
color
textColor
|>
bold
|>
alignment
in
textElement
|>
toForm
|>
move
(
pos
.
x
,
pos
.
y
)
textColor
:
Color
textColor
=
rgb
14
17
33
src/View/Page.elm
View file @
44fa9fbf
module
View
.
Page
(
page
(
page
View
)
where
import
List
import
Graphics
.
Collage
(
..
)
import
Graphics
.
Element
(
Element
)
import
Color
(
..
)
import
Text
(
..
)
import
Text
import
Html
(
..
)
import
Html
.
Attributes
(
..
)
import
Html
.
Attributes
as
A
import
Json
.
Encode
(
string
)
import
Model
.
Vec2
(
Vec2
)
import
Model
.
Player
(
..
)
import
Model
.
Game
(
Game
)
import
Model
.
Point
(
..
)
import
Model
.
Board
(
boardSize
)
import
Model
.
Config
(
..
)
page
:
Game
->
Html
page
game
=
import
View
.
Game
(
gameView
)
pageView
:
Game
->
Html
pageView
game
=
div
[]
[
h1
[]
[
text
"
cAtchVoid"
]
,
div
[
id
"
game"
]
[
fromElement
<<
displayGame
<|
game
]
[
fromElement
<<
gameView
<|
game
]
,
p
[]
[
text
"
Catch the points of your color, avoid the other points."
]
...
...
@@ -52,83 +44,3 @@ page game =
]
]
displayGame
:
Game
->
Element
displayGame
{
time
,
score
,
player
,
cloud
,
bestScore
}
=
let
whitePointForms
=
List
.
map
(
pointForm
time
(
configColor
White
))
(
cloud
.
points
White
)
blackPointForms
=
List
.
map
(
pointForm
time
(
configColor
Black
))
(
cloud
.
points
Black
)
forms
=
boardForms
++
playerForms
player
++
whitePointForms
++
blackPointForms
++
scoreForms
score
++
bestScoreForms
bestScore
in
collage
(
truncate
boardSize
.
x
)
(
truncate
boardSize
.
y
)
forms
boardForms
:
List
Form
boardForms
=
[
filled
boardColor
(
rect
boardSize
.
x
boardSize
.
y
)]
boardColor
:
Color
boardColor
=
rgb
103
123
244
playerForms
:
Player
->
List
Form
playerForms
player
=
let
playerColor
=
configColor
player
.
config
in
[
circleForm
player
.
pos
playerSize
playerColor
]
playerColor
:
Color
playerColor
=
rgb
224
224
224
pointForm
:
Float
->
Color
->
Point
->
Form
pointForm
time
color
point
=
let
pos
=
pointMove
point
time
in
circleForm
pos
pointSize
color
configColor
:
Config
->
Color
configColor
config
=
case
config
of
White
->
rgb
240
240
240
Black
->
rgb
14
17
33
circleForm
:
Vec2
->
Float
->
Color
->
Form
circleForm
pos
size
color
=
let
outline
=
circle
size
|>
filled
outlineColor
inside
=
circle
(
size
-
1
)
|>
filled
color
in
group
[
outline
,
inside
]
|>
move
(
pos
.
x
,
pos
.
y
)
outlineColor
:
Color
outlineColor
=
rgb
34
34
34
scoreForms
:
Int
->
List
Form
scoreForms
score
=
let
text
=
(
toString
score
)
scorePos
=
{
x
=
0.0
,
y
=
boardSize
.
y
/
2
-
30
}
in
[
textForm
text
scorePos
centered
]
bestScoreForms
:
Int
->
List
Form
bestScoreForms
bestScore
=
if
(
bestScore
>
0
)
then
let
text
=
"
Record: "
++
(
toString
bestScore
)
pos
=
{
x
=
-
boardSize
.
x
/
2
+
100
,
y
=
-
boardSize
.
y
/
2
+
30
}
in
[
textForm
text
pos
leftAligned
]
else
[]
textForm
:
String
->
Vec2
->
(
Text
->
Element
)
->
Form
textForm
content
pos
alignment
=
let
textElement
=
fromString
content
|>
Text
.
height
30
|>
typeface
[
"
calibri"
,
"
arial"
]
|>
Text
.
color
textColor
|>
bold
|>
alignment
in
textElement
|>
toForm
|>
move
(
pos
.
x
,
pos
.
y
)
textColor
:
Color
textColor
=
rgb
14
17
33
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment