bacteria 1.0 → 1.1
raw patch · 2 files changed
+12/−6 lines, 2 files
Files
- bacteria.cabal +1/−1
- bacteria.hs +11/−5
bacteria.cabal view
@@ -1,5 +1,5 @@ name: bacteria-version: 1.0+version: 1.1 synopsis: braindead utility to compose Xinerama backgrounds description: Compose a sequence of images by centering them on rectangles the size of the Xinerama screens available. Supports jpg, png, and gif input, and produces png output. category: Graphics
bacteria.hs view
@@ -11,14 +11,20 @@ bottom (Rectangle { rect_y = y, rect_height = h }) = fromIntegral y + fromIntegral h right (Rectangle { rect_x = x, rect_width = w }) = fromIntegral x + fromIntegral w --- TODO: scale down if too large addImages background images rectangles = sequence_ $ zipWith (addImage background) (cycle images) rectangles-addImage background image (Rectangle { rect_x = x, rect_y = y, rect_width = wr, rect_height = hr }) = do+addImage background image (Rectangle { rect_x = xr', rect_y = yr', rect_width = wr', rect_height = hr' }) = do (wi, hi) <- imageSize image- copyRegion (0, 0) (wi, hi) image- (fromIntegral x + fromIntegral wr `div` 2 - fromIntegral wi `div` 2,- fromIntegral y + fromIntegral hr `div` 2 - fromIntegral hi `div` 2)+ let w = min wi wr -- center a screen-sized block of the image, if it's too large+ h = min hi hr+ xi = max 0 ((wi - w) `div` 2)+ yi = max 0 ((hi - h) `div` 2)+ copyRegion (xi, yi) (w, h) image+ (xr + wr `div` 2 - w `div` 2,+ yr + hr `div` 2 - h `div` 2) background+ where+ [xr, yr] = map fromIntegral [xr', yr']+ [wr, hr] = map fromIntegral [wr', hr'] loadFile imageName = ($ imageName) $ case (take 4 &&& take 5) (reverse imageName) of ("gpj.",_) -> loadJpegFile