(+) Costants.hs, (+) Unlicense, (^) README
This commit is contained in:
parent
17e5d43a36
commit
12218be75c
46
LICENSE
46
LICENSE
|
@ -1,30 +1,24 @@
|
||||||
Copyright Author name here (c) 2022
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
All rights reserved.
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
modification, are permitted provided that the following conditions are met:
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
notice, this list of conditions and the following disclaimer.
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
For more information, please refer to <http://unlicense.org/>
|
||||||
copyright notice, this list of conditions and the following
|
|
||||||
disclaimer in the documentation and/or other materials provided
|
|
||||||
with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of Author name here nor the names of other
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
10
README.md
10
README.md
|
@ -3,4 +3,14 @@ Amaranth is a small drawing app written in Haskell. It was
|
||||||
created as a small learning project, and it probably won't
|
created as a small learning project, and it probably won't
|
||||||
be continued.
|
be continued.
|
||||||
|
|
||||||
|
This code is licensed with The Unlicense. Learn more at
|
||||||
|
https://unlicense.org/.
|
||||||
|
|
||||||
|
# ⚙️ How to use
|
||||||
|
Amaranth comes with two modes with which you can draw on
|
||||||
|
the screen:
|
||||||
|
- **brush mode**, which you can use by hitting B on the keyboard, and
|
||||||
|
- **eraser mode**, which you can use by pressing E.
|
||||||
|
|
||||||
# 📸 Screenshots
|
# 📸 Screenshots
|
||||||
|
None by now. 😥
|
|
@ -26,6 +26,7 @@ source-repository head
|
||||||
library
|
library
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Canvas
|
Canvas
|
||||||
|
Costants
|
||||||
Lib
|
Lib
|
||||||
other-modules:
|
other-modules:
|
||||||
Paths_amaranth
|
Paths_amaranth
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Canvas where
|
module Canvas where
|
||||||
|
|
||||||
import Graphics.Gloss.Data.Picture ( Picture (Text), pictures )
|
import Graphics.Gloss.Data.Picture ( Picture (Text), pictures, scale )
|
||||||
import Graphics.Gloss.Interface.IO.Interact ( Event (EventKey), KeyState (Down), Key (Char) )
|
import Graphics.Gloss.Interface.IO.Interact ( Event (EventKey), KeyState (Down), Key (Char) )
|
||||||
|
|
||||||
data Canvas = Canvas {
|
data Canvas = Canvas {
|
||||||
|
@ -10,14 +10,11 @@ data Canvas = Canvas {
|
||||||
|
|
||||||
data Mode = Brush | Eraser deriving (Eq, Show)
|
data Mode = Brush | Eraser deriving (Eq, Show)
|
||||||
|
|
||||||
initial :: Canvas
|
showMode :: Canvas -> Picture
|
||||||
initial = Canvas {
|
showMode canv = scale 0.1 0.1 $ Text ( show (mode canv))
|
||||||
items = []
|
|
||||||
, mode = Brush
|
|
||||||
}
|
|
||||||
|
|
||||||
render :: Canvas -> Picture
|
render :: Canvas -> Picture
|
||||||
render canvas = pictures ( Text ( show (mode canvas)) : items canvas )
|
render canv = pictures ( showMode canv : items canv )
|
||||||
|
|
||||||
handle :: Event -> Canvas -> Canvas
|
handle :: Event -> Canvas -> Canvas
|
||||||
handle (EventKey (Char 'b') Down _ _ ) canv = canv { mode = Brush }
|
handle (EventKey (Char 'b') Down _ _ ) canv = canv { mode = Brush }
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
module Costants where
|
||||||
|
|
||||||
|
import Canvas
|
||||||
|
import Graphics.Gloss
|
||||||
|
|
||||||
|
display :: Display
|
||||||
|
display = InWindow "Amaranth" (500, 500) (0,0)
|
||||||
|
|
||||||
|
background :: Color
|
||||||
|
background = white
|
||||||
|
|
||||||
|
initial :: Canvas
|
||||||
|
initial = Canvas {
|
||||||
|
items = []
|
||||||
|
, mode = Brush
|
||||||
|
}
|
19
src/Lib.hs
19
src/Lib.hs
|
@ -1,14 +1,15 @@
|
||||||
module Lib where
|
module Lib where
|
||||||
|
|
||||||
import Graphics.Gloss
|
import Graphics.Gloss
|
||||||
import Canvas as C
|
import Canvas
|
||||||
|
import Costants
|
||||||
-- Variables
|
|
||||||
display :: Display
|
|
||||||
display = InWindow "Amaranth" (500, 500) (0,0)
|
|
||||||
|
|
||||||
background :: Color
|
|
||||||
background = white
|
|
||||||
|
|
||||||
app :: IO ()
|
app :: IO ()
|
||||||
app = play Lib.display background 60 C.initial C.render C.handle C.update
|
app = play
|
||||||
|
Costants.display -- Display type
|
||||||
|
Costants.background -- Background
|
||||||
|
60 -- FPS
|
||||||
|
Costants.initial -- Initial world
|
||||||
|
Canvas.render -- Render function
|
||||||
|
Canvas.handle -- Input hadler
|
||||||
|
Canvas.update -- Update function (unused, since we don't have to make animations)
|
||||||
|
|
Loading…
Reference in New Issue