diff --git a/README.md b/README.md index 64e1759..b7018b6 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ estimation size: dy/dx = y/x range - format: (lower, upper): -(-10, 10) +(-20, 20) estimation size: 0.1 ``` diff --git a/app/Main.hs b/app/Main.hs index 1ecb331..bcb2530 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -7,6 +7,8 @@ module Main where import Graphics.Rendering.Chart.Backend.Cairo import Control.Lens import Data.Default.Class + import Data.Colour.SRGB + import Data.Colour main :: IO () main = do @@ -22,14 +24,18 @@ module Main where let chart = toRenderable layout where + color = opaque (sRGB 0.3 0.3 1) + layout = layout_title .~ "slope field" $ layout_plots .~ [vectors] $ def vectors = plotVectorField $ plot_vectors_values .~ field - $ plot_vectors_scale .~ 0 - $ plot_vectors_style . vector_head_style . point_radius .~ 0 + $ plot_vectors_scale .~ 1 + $ plot_vectors_grid .~ [] + $ plot_vectors_style . vector_head_style . point_color .~ color + $ plot_vectors_style . vector_line_style . line_color .~ color $ def renderableToFile def "slope-field.png" chart diff --git a/minusy.png b/minusy.png index b292932..9aa055e 100644 Binary files a/minusy.png and b/minusy.png differ diff --git a/slope-field.cabal b/slope-field.cabal index fe29535..cd5d0cb 100644 --- a/slope-field.cabal +++ b/slope-field.cabal @@ -1,5 +1,5 @@ name: slope-field -version: 0.1.0.0 +version: 0.1.0.1 synopsis: Visualize mathematical function's slope fields description: Visualize mathematical function's slope fields homepage: https://github.com/mdibaiee/slope-field @@ -31,6 +31,7 @@ executable slope-field , Chart-cairo , lens , data-default-class + , colour default-language: Haskell2010 source-repository head diff --git a/src/Lib.hs b/src/Lib.hs index 76c0dbe..b334a57 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -18,4 +18,9 @@ module Lib half = diff / 2 res = map (\(x, y) -> ((x - half, y), (half, d x y * diff))) pts inf = 1/0 - in filter (\((x0, y0), (x, y)) -> x < inf && y < inf && x > -inf && y > -inf) res + noinf = filter (\((x0, y0), (x, y)) -> x < inf && y < inf && x > -inf && y > -inf) res + (minx, miny) = head pts + (maxx, maxy) = last pts + limitX = min maxx . max minx + limitY = min maxy . max miny + in map (\((x0, y0), (x1, y1)) -> ((limitX x0, limitY y0), (limitX x1, limitY y1))) noinf diff --git a/xpy.png b/xpy.png index e60b64c..e7e79c5 100644 Binary files a/xpy.png and b/xpy.png differ diff --git a/xty.png b/xty.png index 41a2261..1f7804e 100644 Binary files a/xty.png and b/xty.png differ diff --git a/ydx.png b/ydx.png index 0f77588..0f4765b 100644 Binary files a/ydx.png and b/ydx.png differ