From 12218be75c4fd652aec5cb2772c8dd7a137b91ff Mon Sep 17 00:00:00 2001 From: Francesco <7frapar@gmail.com> Date: Sun, 31 Jul 2022 16:01:13 +0200 Subject: [PATCH] (+) Costants.hs, (+) Unlicense, (^) README --- LICENSE | 46 ++++++++++++++++++++-------------------------- README.md | 12 +++++++++++- amaranth.cabal | 1 + src/Canvas.hs | 11 ++++------- src/Costants.hs | 16 ++++++++++++++++ src/Lib.hs | 19 ++++++++++--------- 6 files changed, 62 insertions(+), 43 deletions(-) create mode 100644 src/Costants.hs diff --git a/LICENSE b/LICENSE index 342c588..00d2e13 100644 --- a/LICENSE +++ b/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 -modification, are permitted provided that the following conditions are met: +In jurisdictions that recognize copyright laws, the author or authors +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 - notice, this list of conditions and the following disclaimer. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +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 - 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. +For more information, please refer to \ No newline at end of file diff --git a/README.md b/README.md index 4fb214e..e516faf 100644 --- a/README.md +++ b/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 be continued. -# 📸 Screenshots \ No newline at end of file +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 +None by now. 😥 \ No newline at end of file diff --git a/amaranth.cabal b/amaranth.cabal index 0c242d0..cd8ec36 100644 --- a/amaranth.cabal +++ b/amaranth.cabal @@ -26,6 +26,7 @@ source-repository head library exposed-modules: Canvas + Costants Lib other-modules: Paths_amaranth diff --git a/src/Canvas.hs b/src/Canvas.hs index 1cd8135..39ae518 100644 --- a/src/Canvas.hs +++ b/src/Canvas.hs @@ -1,6 +1,6 @@ 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) ) data Canvas = Canvas { @@ -10,14 +10,11 @@ data Canvas = Canvas { data Mode = Brush | Eraser deriving (Eq, Show) -initial :: Canvas -initial = Canvas { - items = [] -, mode = Brush -} +showMode :: Canvas -> Picture +showMode canv = scale 0.1 0.1 $ Text ( show (mode canv)) render :: Canvas -> Picture -render canvas = pictures ( Text ( show (mode canvas)) : items canvas ) +render canv = pictures ( showMode canv : items canv ) handle :: Event -> Canvas -> Canvas handle (EventKey (Char 'b') Down _ _ ) canv = canv { mode = Brush } diff --git a/src/Costants.hs b/src/Costants.hs new file mode 100644 index 0000000..5e7e1cf --- /dev/null +++ b/src/Costants.hs @@ -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 +} \ No newline at end of file diff --git a/src/Lib.hs b/src/Lib.hs index 5393e8f..ccd7346 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -1,14 +1,15 @@ module Lib where import Graphics.Gloss -import Canvas as C - --- Variables -display :: Display -display = InWindow "Amaranth" (500, 500) (0,0) - -background :: Color -background = white +import Canvas +import Costants 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)