Refonte sous forme de SPA

pull/1/head
Jean-Christophe Jameux 4 years ago
parent d6fdc6f159
commit 0cf2b871c8
  1. BIN
      elm-stuff/0.19.1/CalculateurDeNotes.elmi
  2. BIN
      elm-stuff/0.19.1/CalculateurDeNotes.elmo
  3. BIN
      elm-stuff/0.19.1/GenerateurDeProblemes.elmi
  4. BIN
      elm-stuff/0.19.1/GenerateurDeProblemes.elmo
  5. BIN
      elm-stuff/0.19.1/d.dat
  6. BIN
      elm-stuff/0.19.1/i.dat
  7. BIN
      elm-stuff/0.19.1/o.dat
  8. 9
      elm.json
  9. 5720
      index.html
  10. 1
      indexNu.html
  11. 17169
      prof.js
  12. BIN
      prof.min.js.gzhh
  13. 1
      prof.min.jshh
  14. 205
      src/CalculateurDeNotes.elm
  15. 53
      src/Couleur.elm
  16. 18
      src/Echologo.elm
  17. 134
      src/GenerateurDeProblemes.elm
  18. 64
      src/Main.elm
  19. 234
      src/Prof.elm
  20. 55
      src/Style.elm
  21. 213
      src/Test.elm

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -6,16 +6,20 @@
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"avh4/elm-color": "1.0.0",
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/file": "1.0.5",
"elm/html": "1.0.0",
"elm/parser": "1.1.0",
"elm/random": "1.0.0",
"elm/svg": "1.0.1",
"elm/url": "1.0.0",
"elm-community/random-extra": "3.2.0",
"jxxcarlson/meenylatex": "14.1.1",
"lynn/elm-arithmetic": "3.0.0",
"mdgriffith/elm-ui": "1.1.8"
"mdgriffith/elm-ui": "1.1.8",
"noahzgordon/elm-color-extra": "1.0.2"
},
"indirect": {
"Garados007/elm-svg-parser": "1.0.0",
@ -25,15 +29,14 @@
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm/regex": "1.0.0",
"elm/svg": "1.0.1",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2",
"elm-community/dict-extra": "2.4.0",
"elm-community/list-extra": "8.5.1",
"elm-community/maybe-extra": "5.2.1",
"elm-community/result-extra": "2.4.0",
"erlandsona/assoc-set": "1.1.0",
"fredcy/elm-parseint": "2.0.1",
"pablohirafuji/elm-syntax-highlight": "3.4.1",
"pilatch/flip": "1.0.0",
"pzp1997/assoc-list": "1.0.0",

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
<!DOCTYPE html><html><head></head><body><div id="a"></div><script src="./prof.js"></script><script>Elm.Prof.init({node:document.getElementById("a")})</script></body></html>

17169
prof.js

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because one or more lines are too long

@ -1,32 +1,22 @@
module CalculateurDeNotes exposing (..)
import Array exposing (..)
import Browser
import Browser exposing (Document)
import Element exposing (..)
import Element.Background as Background
import Element.Border as Border
import Element.Events exposing (..)
import Element.Font as Font
import Element.Input as Input
import File.Download
import Html exposing (Html)
import Parser exposing (..)
import Set
import Style exposing (..)
{-
-}
main =
Browser.element
{ init = init
, update = update
, subscriptions = subscriptions
, view = view
}
titre =
"Calculateur de notes"
@ -47,15 +37,13 @@ type alias Model =
}
init : () -> ( Model, Cmd Msg )
init _ =
( { bareme = ""
, reponsesCorrectes = ""
, reponsesEleves = ""
, eleves = []
}
, Cmd.none
)
init : Model
init =
{ bareme = ""
, reponsesCorrectes = ""
, reponsesEleves = ""
, eleves = []
}
@ -159,73 +147,124 @@ subscriptions model =
-}
view : Model -> Html Msg
view : Model -> Element Msg
view model =
layout [ width fill, height fill ] <|
row
[ spacing grandEspacement
, padding tresGrandEspacement
row
[ spacing grandEspacement
, padding tresGrandEspacement
, height fill
, width fill
]
[ column
[ spacing petitEspacement
, height fill
, width fill
, clip
, scrollbars
, clip
]
[ column
[ spacing petitEspacement
, height fill
, width fill
[ Input.multiline
[ height fill
, clip
, scrollbars
]
[ Input.multiline [ height <| maximum 300 fill, clip, scrollbars ]
{ onChange = NouveauBareme
, label = Input.labelAbove [] <| text "Barème"
, placeholder =
Just <|
Input.placeholder [] <|
text "Entrer le barème sous la forme +3 -1, +2 -1"
, text = model.bareme
, spellcheck = False
}
, Input.multiline [ height <| maximum 300 fill, clip, scrollbars ]
{ onChange = NouvellesReponsesCorrectes
, label = Input.labelAbove [] <| text "Réponses correctes"
, placeholder =
Just <|
Input.placeholder [] <|
text "Entrer les réponses correctes pour chaque sujet"
, text = model.reponsesCorrectes
, spellcheck = False
, width fill
, Background.color <| vert 0.2
, Border.rounded 8
, Border.innerShadow
{ blur = 10
, color = rgb255 10 10 10
, offset = ( 0.3, 0.4 )
, size = 2
}
, Input.multiline [ height <| maximum 300 fill, clip, scrollbars ]
{ onChange = NouvellesReponsesEleves
, label = Input.labelAbove [] <| text "Réponses des élèves"
, placeholder =
Just <|
Input.placeholder [] <|
text "Entrer les réponses des élèves"
, text = model.reponsesEleves
, spellcheck = False
]
{ onChange = NouveauBareme
, label = Input.labelAbove [] <| text "Barème"
, placeholder =
Just <|
Input.placeholder [] <|
text "Entrer le barème sous la forme +3 -1, +2 -1"
, text = model.bareme
, spellcheck = False
}
, Input.multiline
[ height fill
, clip
, scrollbars
, width fill
, Background.color <| vert 0.2
, Border.rounded 8
, Border.innerShadow
{ blur = 10
, color = rgb255 10 10 10
, offset = ( 0.3, 0.4 )
, size = 2
}
]
, column [ spacing petitEspacement, height fill, width fill ]
[ text <|
"Moyenne : "
++ String.fromFloat (moyenne model.eleves)
++ " Écart type : "
++ String.fromFloat (ecartType model.eleves)
, Input.button []
{ onPress = Just TelechargerNotes
, label = text "Télécharger le fichier de notes"
{ onChange = NouvellesReponsesCorrectes
, label = Input.labelAbove [] <| text "Réponses correctes"
, placeholder =
Just <|
Input.placeholder [] <|
text "Entrer les réponses correctes pour chaque sujet"
, text = model.reponsesCorrectes
, spellcheck = False
}
, Input.multiline
[ height fill
, clip
, scrollbars
, width fill
, Background.color <| vert 0.2
, Border.rounded 8
, Border.innerShadow
{ blur = 10
, color = rgb255 10 10 10
, offset = ( 0.3, 0.4 )
, size = 2
}
, voirNotes model.eleves
]
{ onChange = NouvellesReponsesEleves
, label = Input.labelAbove [] <| text "Réponses des élèves"
, placeholder =
Just <|
Input.placeholder [] <|
text "Entrer les réponses des élèves"
, text = model.reponsesEleves
, spellcheck = False
}
]
, column
[ spacing petitEspacement
, height fill
, width fill
]
[ text <|
"Moyenne : "
++ String.fromFloat (moyenne model.eleves)
++ " Écart type : "
++ String.fromFloat (ecartType model.eleves)
, bouton TelechargerNotes "Télécharger le fichier de notes"
, voirNotes model.eleves
]
]
voirNotes : Eleves -> Element Msg
voirNotes rpnsEleves =
table []
table
[ height fill
, width fill
, clip
, scrollbars
, padding petitEspacement
, Background.color <| vert 0.2
, Border.rounded 8
, Border.innerShadow
{ blur = 10
, color = rgb255 10 10 10
, offset = ( 0.3, 0.4 )
, size = 2
}
]
{ data = rpnsEleves
, columns =
[ { header = Element.text "Numéro étudiant"
@ -278,18 +317,6 @@ voirNotesOrg rpnsEleves =
++ String.concat (List.map ligne rpnsEleves)
petitEspacement =
20
grandEspacement =
5 * petitEspacement // 4
tresGrandEspacement =
25 * petitEspacement // 16
{-

@ -0,0 +1,53 @@
module Couleur exposing (Couleur)
type alias Couleur =
{ rouge : Float
, vert : Float
, bleu : Float
}
plusSombre : Float -> Couleur -> Couleur
plusSombre taux { red, green, blue, alpha } =
if red < green && red < blue then
let
nouveauRouge =
red * taux
nouveauPasRouge =
nouveauRouge - red
in
{ red = nouveauRouge
, green = green + nouveauPasRouge
, blue = blue + nouveauPasRouge
, alpha = alpha
}
else if green < blue then
let
nouveauVert =
green * taux
nouveauPasVert =
nouveauVert - green
in
{ red = red + nouveauPasVert
, green = nouveauVert
, blue = blue + nouveauPasVert
, alpha = alpha
}
else
let
nouveauBleu =
blue * taux
nouveauPasBleu =
nouveauBleu - blue
in
{ red = red + nouveauPasBleu
, green = green + nouveauPasBleu
, blue = blue + nouveauBleu
, alpha = alpha
}

@ -0,0 +1,18 @@
module Echologo exposing (echologo)
import Element exposing (..)
import Svg exposing (..)
import Svg.Attributes as SvgA exposing (cx, cy, d, r, strokeWidth, viewBox)
echologo taille =
html <|
svg [ viewBox "0 0 30 30", SvgA.height <| String.fromInt taille ]
[ circle [ cx "15", cy "15", r "15", SvgA.fill "#64c29b", strokeWidth "0" ] []
, g [ SvgA.fill "#fff", strokeWidth "0" ]
[ circle [ cx "13.8", cy "9", r "2" ] []
, path [ d "M 12.3,6.4019238 A 3,3 0 0 0 11.201924,10.5 5,5 0 0 1 12.3,2.1592831 a 3,3 0 0 0 0,4.2426407" ] []
, path [ d "m13.8 6a3 3 0 0 1 3 3 6 6 0 0 1 8.485281 0 8 8 0 0 0-11.485281-3" ] []
, path [ d "M 12.3,11.598076 A 3,3 0 0 0 16.398076,10.5 13,13 0 0 1 12.3,28.568639 a 12,12 0 0 0 0,-16.970563" ] []
]
]

@ -1,12 +1,13 @@
module GenerateurDeProblemes exposing (..)
import Browser
import Browser exposing (Document)
import Element exposing (..)
import Element.Background as Background
import Element.Border as Border
import Element.Events exposing (..)
import Element.Font as Font
import Element.Input as Input
import File.Download
import Fraction as F exposing (Fraction)
import Html exposing (Attribute, Html, button, div, iframe, input, p, section, textarea)
import List as L
@ -17,25 +18,11 @@ import Random.Extra
import Random.List
import Set
import String as S
import Style exposing (..)
{-
-}
main =
Browser.element
{ init = init
, update = update
, subscriptions = subscriptions
, view = view
}
titre =
"Générateur de proplèmes"
@ -54,13 +41,11 @@ type alias Model =
}
init : () -> ( Model, Cmd Msg )
init _ =
( { structureDuSujet = ""
, sujetGenere = ""
}
, Cmd.none
)
init : Model
init =
{ structureDuSujet = ""
, sujetGenere = ""
}
@ -142,41 +127,78 @@ subscriptions model =
-}
view : Model -> Html Msg
view : Model -> Element Msg
view model =
layout [] <|
row [ spacing grandEspacement, padding tresGrandEspacement, height fill, width fill, clip, scrollbars ]
[ Input.multiline [ height <| maximum 800 fill, clip, scrollbars ]
{ onChange = StructureDuSujet
, label = Input.labelHidden "chose"
, placeholder = Just <| Input.placeholder [] <| text "Structure du sujet"
, text = model.structureDuSujet
, spellcheck = True
row
[ spacing grandEspacement
, padding tresGrandEspacement
, height fill
, width fill
, scrollbars
]
[ Input.multiline
[ height fill
, width fill
, clip
, scrollbars
, Background.color <| vert 0.2
, Border.rounded 8
, Border.innerShadow
{ blur = 10
, color = rgb255 10 10 10
, offset = ( 0.3, 0.4 )
, size = 2
}
, column [ spacing petitEspacement, height fill, width fill ]
[ Input.button []
{ onPress = Just GenererSujetAleatoire
, label = text "Générer 89 sujets alétoires pour QuizScan"
}
, Input.button []
{ onPress = Just GenererVariantesSujet
, label = text "Générer les variantes du sujet pour EvalBox"
]
{ onChange = StructureDuSujet
, label = Input.labelHidden "chose"
, placeholder =
Just <|
Input.placeholder [] <|
text "Structure du sujet"
, text = model.structureDuSujet
, spellcheck = True
}
, column [ spacing petitEspacement, height fill, width fill, scrollbars ]
-- L'attibut scrollbars présent dans la liste ci-dessus ^^^^^^^^^^
-- est nécessaire pour que l'élément ci-dessous ne s'étende pas !
[ paragraph []
[ text
"""
Pour générer 89 sujets alétoires appuyer sur QuizScan et
pour générer toutes les variantes du sujet appuyer sur EvalBox.
"""
]
, row
[ width fill
, padding petitEspacement
, spacing tresGrandEspacement
]
[ bouton GenererSujetAleatoire "QuizScan"
, bouton GenererVariantesSujet "EvalBox"
]
, el
--^^ Cet élément ci
[ height fill
, width fill
, clip
, scrollbars
--^^^^^^^^^^ Cet attribut ne suffit pas
, padding petitEspacement
, Background.color <| vert 0.2
, Border.rounded 8
, Border.innerShadow
{ blur = 10
, color = rgb255 10 10 10
, offset = ( 0.3, 0.4 )
, size = 2
}
, el [ height <| maximum 800 fill, clip, scrollbars ] <| text model.sujetGenere
]
<|
text model.sujetGenere
]
petitEspacement =
20
grandEspacement =
5 * petitEspacement // 4
tresGrandEspacement =
25 * petitEspacement // 16
]
@ -712,6 +734,8 @@ variantesBloc blcs =
[ Entete [ Texte "Je ne peux pas prendre en charge une telle imbrication :(" ] [] ]
VraiFaux prps ->
--pourri
--qcmsDepuisVraiFauxx [ Texte "La proposition suivante est-elle correcte ?" ]
[ VraiFaux prps ]
QCM mcr prps ->

@ -1,64 +0,0 @@
module Main exposing (..)
-- Press buttons to increment and decrement a counter.
--
-- Read how it works:
-- https://guide.elm-lang.org/architecture/buttons.html
--
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
-- MAIN
main =
Browser.sandbox { init = init, update = update, view = view }
-- MODEL
type alias Model = Int
init : Model
init =
0
-- UPDATE
type Msg
= Increment
| Decrement
update : Msg -> Model -> Model
update msg model =
case msg of
Increment ->
model + 1
Decrement ->
model - 1
-- VIEW
view : Model -> Html Msg
view model =
div []
[ button [ onClick Decrement ] [ text "-" ]
, div [] [ text (String.fromInt model) ]
, button [ onClick Increment ] [ text "+" ]
]

@ -0,0 +1,234 @@
module Prof exposing (main)
import Browser
import Browser.Navigation as Nav
import CalculateurDeNotes
import Echologo exposing (..)
import Element exposing (..)
import Element.Background as Background
import Element.Border as Border
import Element.Events exposing (..)
import Element.Font as Font
import GenerateurDeProblemes
import Html exposing (Html)
import Html.Attributes
import Style exposing (..)
import Url
{-
-}
main : Program () Model Msg
main =
Browser.application
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
, onUrlChange = UrlChanged
, onUrlRequest = LinkClicked
}
-- MODEL
type alias Model =
{ key : Nav.Key
, url : Url.Url
, page : Page
, modeleGenerateurDeProblemes : GenerateurDeProblemes.Model
, modeleCalculateurDeNotes : CalculateurDeNotes.Model
}
type Page
= GenerateurDeProblemes
| CalculateurDeNotes
init : () -> Url.Url -> Nav.Key -> ( Model, Cmd Msg )
init flags url key =
case url.fragment of
Just "CalculateurDeNotes" ->
( Model key
url
CalculateurDeNotes
GenerateurDeProblemes.init
CalculateurDeNotes.init
, Cmd.none
)
Just "GenerateurDeProblemes" ->
( Model key
url
GenerateurDeProblemes
GenerateurDeProblemes.init
CalculateurDeNotes.init
, Cmd.none
)
_ ->
( Model key
{ url | fragment = Just "GenerateurDeProblemes" }
GenerateurDeProblemes
GenerateurDeProblemes.init
CalculateurDeNotes.init
, Nav.pushUrl key (Url.toString { url | fragment = Just "GenerateurDeProblemes" })
)
-- UPDATE
type Msg
= LinkClicked Browser.UrlRequest
| UrlChanged Url.Url
| CalculateurDeNotesMsg CalculateurDeNotes.Msg
| GenerateurDeProblemesMsg GenerateurDeProblemes.Msg
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case ( msg, model.page ) of
( LinkClicked urlRequest, _ ) ->
case urlRequest of
Browser.Internal url ->
( model, Nav.pushUrl model.key (Url.toString url) )
Browser.External href ->
( model, Nav.load href )
( UrlChanged url, _ ) ->
case url.fragment of
Just "CalculateurDeNotes" ->
( { model
| url = url
, page = CalculateurDeNotes
}
, Cmd.none
)
Just "GenerateurDeProblemes" ->
( { model
| url = url
, page = GenerateurDeProblemes
}
, Cmd.none
)
_ ->
( { model
| url = { url | fragment = Just "GenerateurDeProblemes" }
, page = GenerateurDeProblemes
}
, Nav.pushUrl model.key (Url.toString { url | fragment = Just "GenerateurDeProblemes" })
)
( GenerateurDeProblemesMsg message, GenerateurDeProblemes ) ->
let
( nouveauModele, commande ) =
GenerateurDeProblemes.update message
model.modeleGenerateurDeProblemes
in
( { model
| modeleGenerateurDeProblemes = nouveauModele
}
, Cmd.map GenerateurDeProblemesMsg commande
)
( CalculateurDeNotesMsg message, CalculateurDeNotes ) ->
let
( nouveauModele, commande ) =
CalculateurDeNotes.update message model.modeleCalculateurDeNotes
in
( { model
| modeleCalculateurDeNotes = nouveauModele
}
, Cmd.map CalculateurDeNotesMsg commande
)
_ ->
( model, Cmd.none )
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions _ =
Sub.none
-- VIEW
view : Model -> Browser.Document Msg
view model =
case model.page of
CalculateurDeNotes ->
{ title = CalculateurDeNotes.titre
, body =
[ CalculateurDeNotes.view model.modeleCalculateurDeNotes
|> Element.map CalculateurDeNotesMsg
|> designGeneral CalculateurDeNotes.titre
]
}
GenerateurDeProblemes ->
{ title = GenerateurDeProblemes.titre
, body =
[ GenerateurDeProblemes.view model.modeleGenerateurDeProblemes
|> Element.map GenerateurDeProblemesMsg
|> designGeneral GenerateurDeProblemes.titre
]
}
designGeneral titre elm =
layout
[ height fill
, width fill
, padding tresGrandEspacement
, Background.color <| vert 0.2
]
<|
column
[ height fill
, width fill
, Background.color <| vert 0
, Border.rounded 13
]
[ row []
[ echologo 135
, el
[ Font.size 120
, Font.color <| vert 0.2
, Font.shadow
{ offset = ( 2, 2 )
, blur = 3
, color = vert 1
}
]
<|
text titre
]
, elm
]
viewLink : String -> Html msg
viewLink path =
Html.li [] [ Html.a [ Html.Attributes.href path ] [ Html.text path ] ]

@ -0,0 +1,55 @@
module Style exposing (..)
import Color
import Color.Manipulate
import Element exposing (..)
import Element.Background as Background
import Element.Border as Border
import Element.Input as Input
{-| HSL = 155, 43.5, 57.6
-}
echoVert =
Color.fromRgba
{ red = 100 / 255
, green = 194 / 255
, blue = 155 / 255
, alpha = 255 / 255
}
vert t =
fromRgb <|
Color.toRgba <|
Color.Manipulate.lighten t echoVert
petitEspacement =
20
grandEspacement =
5 * petitEspacement // 4
tresGrandEspacement =
25 * petitEspacement // 16
bouton fonction label =
Input.button
[ centerY
, padding petitEspacement
, Background.color <| vert -0.2
, Border.rounded 8
, Border.shadow
{ blur = 10
, color = rgb255 10 10 10
, offset = ( 0.3, 0.4 )
, size = 2
}
]
{ onPress = Just fonction
, label = text label
}

@ -1,9 +1,12 @@
module Test exposing (..)
import Browser
import Debug exposing (todo)
import Element exposing (..)
import Element.Input as Input
import Html exposing (Html)
import Svg exposing (circle, g, path, svg)
import Svg.Attributes as SvgA exposing (color, cx, cy, r, strokeWidth, viewBox, x, y)
@ -46,16 +49,202 @@ update (NouveauTexte texte) model =
view : Model -> Html Msg
view model =
layout [ width fill, height fill ] <|
row []
[ Input.multiline [ height <| maximum 300 fill, clip, scrollbars ]
{ onChange = NouveauTexte
, label = Input.labelAbove [] <| text "Test"
, placeholder =
Just <|
Input.placeholder [] <|
text "Entrer le texte"
, text = String.toUpper model.texte
, spellcheck = False
}
, text model.texte
column [ padding 100, centerX, centerY ]
[ html <|
svg [ SvgA.height "100", SvgA.width "512" ]
[ rectangleRouge
]
, html <|
svg [ SvgA.height "100", SvgA.width "512" ]
[ rectangleVert
]
, html <|
svg [ SvgA.height "100", SvgA.width "512" ]
[ rectangleVertBis
]
, html <|
svg [ SvgA.height "100", SvgA.width "512" ]
[ rectangleBleu
]
, html <|
svg [ SvgA.height "100", SvgA.width "512" ]
[ rectangleBleuBis
]
, html <|
svg [ SvgA.height "100", SvgA.width "512" ]
[ rectangleCyan
]
, html <|
svg [ SvgA.height "100", SvgA.width "512" ]
[ rectangleGris
]
, html <|
svg [ SvgA.height "100", SvgA.width "512" ]
[ rectangleGrisBis
]
, html <|
svg [ SvgA.height "768", SvgA.width "768" ]
[ carreBleu
]
]
trait n r v b =
Svg.rect
[ x (String.fromFloat n)
, SvgA.fill <| "rgb(" ++ String.fromFloat r ++ "," ++ String.fromFloat v ++ "," ++ String.fromFloat b ++ ")"
, SvgA.color <| "rgb(" ++ String.fromFloat r ++ "," ++ String.fromFloat v ++ "," ++ String.fromFloat b ++ ")"
, SvgA.width "1"
, SvgA.height "100"
, y "0"
]
[]
point xCoord yCoord r v b =
Svg.rect
[ x (String.fromFloat xCoord)
, SvgA.fill <| "rgb(" ++ String.fromFloat r ++ "," ++ String.fromFloat v ++ "," ++ String.fromFloat b ++ ")"
, SvgA.color <| "rgb(" ++ String.fromFloat r ++ "," ++ String.fromFloat v ++ "," ++ String.fromFloat b ++ ")"
, SvgA.width "2"
, SvgA.height "2"
, y (String.fromFloat yCoord)
]
[]
rectangleRouge =
g [] <|
List.map (\x -> trait x (x * 0.9) 0 0) range
++ List.map (\x -> trait (x + 256) (255 * 0.9) (x * 0.9) (x * 0.9)) range
rectangleVertBis =
g [] <|
List.map (\x -> trait x 0 x 0) range
++ List.map (\x -> trait (x + 256) x 255 x) range
rectangleVert =
g [] <|
List.map (\x -> trait x 0 (x * 0.8) 0) range
++ List.map (\x -> trait (x + 256) (x * 0.8) (255 * 0.8) (x * 0.8)) range
rectangleBleu =
g [] <|
List.map (\x -> trait x 0 0 x) range
++ List.map (\x -> trait (x + 256) (x * 0.9) x 255) range
carreBleu =
g [] <| List.map (\( x, y ) -> point (3 * x) (3 * y) x y 255) carre
rectangleBleuBis =
let
f x =
128 + 30 * (logBase e (4 + x) - logBase e (260 - x))
in
g [] <|
List.map (\x -> trait x 0 0 (f x)) range
++ List.map (\x -> trait (x + 256) (f x) (f x) 255) range
rectangleGris =
g [] <|
List.map (\x -> trait x (x / 2) (x / 2) (x / 2)) range
++ List.map (\x -> trait (x + 256) (128 + x / 2) (128 + x / 2) (128 + x / 2)) range
rectangleGrisBis =
let
f x =
128 + 30 * (logBase e (4 + x) - logBase e (260 - x))
in
g [] <|
List.map (\x -> trait (2 * x) (f x) (f x) (f x)) range
++ List.map (\x -> trait (2 * x + 1) (f x) (f x) (f x)) range
rectangleCyan =
g [] <|
List.map (\x -> trait x 0 (x * 0.3) x) range
++ List.map (\x -> trait (x + 256) x (x + 0.3 * (255 - x)) 255) range
range =
List.map ((\x -> x / 10) << toFloat) <| List.range 0 2550
carre =
let
f n =
List.map (Tuple.pair n << toFloat) <| List.range 0 255
in
List.concatMap (f << toFloat) <| List.range 0 255
type alias Couleur =
{ rouge : Float
, vert : Float
, bleu : Float
}
type alias CouleurRvb =
{ rouge : Float
, vert : Float
, bleu : Float
}
versRvb : Couleur -> CouleurRvb
versRvb { rouge, vert, bleu } =
if rouge < vert && vert < bleu then
todo "bla"
else
todo "bla"
plusSombre : Float -> Couleur -> Couleur
plusSombre taux { rouge, vert, bleu } =
if rouge < vert && rouge < bleu then
let
nouveauRouge =
rouge * taux
nouveauPasRouge =
nouveauRouge - rouge
in
{ rouge = nouveauRouge
, vert = vert + nouveauPasRouge
, bleu = bleu + nouveauPasRouge
}
else if vert < bleu then
let
nouveauVert =
vert * taux
nouveauPasVert =
nouveauVert - vert
in
{ rouge = rouge + nouveauPasVert
, vert = nouveauVert
, bleu = bleu + nouveauPasVert
}
else
let
nouveauBleu =
bleu * taux
nouveauPasBleu =
nouveauBleu - bleu
in
{ rouge = rouge + nouveauPasBleu
, vert = vert + nouveauPasBleu
, bleu = bleu + nouveauBleu
}

Loading…
Cancel
Save