packages feed

gloss-export-0.1.0.0: app/Export.hs

module Main where

import Graphics.Gloss.Data.Color
import Graphics.Gloss.Data.Picture
import Graphics.Gloss.Data.Bitmap
import Graphics.Gloss
import Graphics.Gloss.Export

size :: (Int, Int)
size = (1500, 1000)

shorthand     = exportPictureToPNG size white

main :: IO ()
main = do
    bmp <- loadBMP "loadme.bmp"
    let pic = Pictures [bmp, Color red $ Polygon [(-80,0), (0,80), (80,0)], Circle 80, Text "text"]
    exportPictureToPNG    (400,400) white "comprehensive.png" pic
    exportPictureToBitmap (400,400) white "comprehensive.bmp" pic
    exportPictureToTga    (400,400) white "comprehensive.tga" pic
    exportPictureToTiff   (400,400) white "comprehensive.tiff" pic
    -- display (InWindow "" (100,80) (0, 0)) white pic
    shorthand "bmp.png"  (bmp)
    shorthand "circle.png"  (circle 25)
    exportPictureToPNG (500,500) white "circles.png" (Pictures (map circle [0,10..250]))
    -- background seems limited to  (1853,1025) beyond that it's transparent
    let f = "top_and_right_margin_transparent_bg_on_my_machine.png"
    let wby2 = 1853 / 2
    let hby2 = 1025 / 2
    let p = Pictures [Translate wby2 hby2 $ ThickCircle 10 80
                     ,Translate wby2 hby2 $ ThickCircle 10 80
                     ,Color blue $ Line [(-wby2, hby2),(wby2, -hby2)]
                     ,ThickCircle 10 80]
    exportPictureToPNG (1900,1050) white f p
    
    let stack = (Pictures [ Color blue   $ poly 49  --100x100
                          , Color red    $ poly 30  -- 60x60
                          , Color yellow $ poly 20  -- 40x40
                          , Color green  $ poly 10  -- 20x20
                          , Color white  $ poly  5  -- 10x10
                          ]
                )
    
    exportPictureToPNG (10,10) white "p10.png" stack
    exportPictureToPNG (20,20) white "p20.png" stack
    exportPictureToPNG (40,40) white "p40.png" stack
    exportPictureToPNG (60,60) white "p60.png" stack
    exportPictureToPNG (100,100) white "p100.png" stack
    
    exportPicturesToPNG    (1000,1000) white "growing_polgons%d.png"  (Color blue . poly) [200,250..500]
    exportPicturesToBitmap (1000,1000) white "growing_polgons%d.bmp"  (Color blue . poly) [200,250..500]
    exportPicturesToTga    (1000,1000) white "growing_polgons%d.tga"  (Color blue . poly) [200,250..500]
    exportPicturesToTiff   (1000,1000) white "growing_polgons%d.tiff" (Color blue . poly) [200,250..500]
    exportPicturesToGif 10 LoopingNever  (1000,1000) red "growing_polgons.gif" (Color blue . poly) [200,250..500]


textFloats :: [Float]
textFloats = [0,1..10]

poly :: Float -> Picture
poly l = Polygon [(-l,l),( l,l),(l,-l),(-l,-l)]