atlas-0: Skyline rectangle packing

Copyright(c) 2019-2021 Edward Kmett
LicenseBSD-2-Clause OR Apache-2.0
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Atlas

Contents

Description

skyline packing using stb_rect_pack.h

Synopsis

Documentation

data Atlas s Source #

Instances
Eq (Atlas s) Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

(==) :: Atlas s -> Atlas s -> Bool #

(/=) :: Atlas s -> Atlas s -> Bool #

Ord (Atlas s) Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

compare :: Atlas s -> Atlas s -> Ordering #

(<) :: Atlas s -> Atlas s -> Bool #

(<=) :: Atlas s -> Atlas s -> Bool #

(>) :: Atlas s -> Atlas s -> Bool #

(>=) :: Atlas s -> Atlas s -> Bool #

max :: Atlas s -> Atlas s -> Atlas s #

min :: Atlas s -> Atlas s -> Atlas s #

Show (Atlas s) Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

showsPrec :: Int -> Atlas s -> ShowS #

show :: Atlas s -> String #

showList :: [Atlas s] -> ShowS #

create :: (HasCallStack, PrimMonad m) => Int -> Int -> m (Atlas (PrimState m)) Source #

Create a packing context.

createExplicit :: HasCallStack => PrimMonad m => Int -> Int -> Maybe Int -> m (Atlas (PrimState m)) Source #

Initialization with an optional node count, when node count < width is used this results in quantization unless setAllowOutOfMem is enabled. When no value is supplied, it defaults to the width of the Atlas.

reset :: PrimMonad m => Atlas (PrimState m) -> m () Source #

Reinitialize an atlas with the same parameters

Setup

data Heuristic Source #

Constructors

BottomLeft

bottom-left sort-height

BestFirst

best first sort-height

Instances
Bounded Heuristic Source # 
Instance details

Defined in Data.Atlas.Internal

Enum Heuristic Source # 
Instance details

Defined in Data.Atlas.Internal

Eq Heuristic Source # 
Instance details

Defined in Data.Atlas.Internal

Ord Heuristic Source # 
Instance details

Defined in Data.Atlas.Internal

Read Heuristic Source # 
Instance details

Defined in Data.Atlas.Internal

Show Heuristic Source # 
Instance details

Defined in Data.Atlas.Internal

Ix Heuristic Source # 
Instance details

Defined in Data.Atlas.Internal

Lift Heuristic Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

lift :: Heuristic -> Q Exp #

Default Heuristic Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

def :: Heuristic

setHeuristic :: PrimMonad m => Atlas (PrimState m) -> Heuristic -> m () Source #

setAllowOutOfMem :: PrimMonad m => Atlas (PrimState m) -> Bool -> m () Source #

Using a context

data Pt Source #

Use and cast back and forth to ints instead for more natural API?

Constructors

Pt Int Int 
Instances
Eq Pt Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

(==) :: Pt -> Pt -> Bool #

(/=) :: Pt -> Pt -> Bool #

Num Pt Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

(+) :: Pt -> Pt -> Pt #

(-) :: Pt -> Pt -> Pt #

(*) :: Pt -> Pt -> Pt #

negate :: Pt -> Pt #

abs :: Pt -> Pt #

signum :: Pt -> Pt #

fromInteger :: Integer -> Pt #

Ord Pt Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

compare :: Pt -> Pt -> Ordering #

(<) :: Pt -> Pt -> Bool #

(<=) :: Pt -> Pt -> Bool #

(>) :: Pt -> Pt -> Bool #

(>=) :: Pt -> Pt -> Bool #

max :: Pt -> Pt -> Pt #

min :: Pt -> Pt -> Pt #

Read Pt Source # 
Instance details

Defined in Data.Atlas.Internal

Show Pt Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

showsPrec :: Int -> Pt -> ShowS #

show :: Pt -> String #

showList :: [Pt] -> ShowS #

Lift Pt Source # 
Instance details

Defined in Data.Atlas.Internal

Methods

lift :: Pt -> Q Exp #

pack Source #

Arguments

:: (PrimMonad m, Traversable f) 
=> Atlas (PrimState m)

The atlas you want to pack these rectangles into.

-> (a -> Pt)

for each item you want to pack, extract the size.

-> (Maybe Pt -> a -> b)

when some fail to pack this will be called, with Just a position for each that succeeded, and Nothing for any that it failed on. The successes and failures may well be out of order.

-> (Pt -> a -> c)

when all succeed this will be called with each position.

-> f a

A container full of things that you'd like to pack into the atlas.

-> m (Either (f b) (f c))

Either a mixture of successes and failures, or a successful pack.

pack1 :: PrimMonad m => Atlas (PrimState m) -> Pt -> m (Maybe Pt) Source #

Add one rectangle to the Atlas. Using pack can yield significantly better packing than calling this one rectangle at a time.

packM Source #

Arguments

:: (PrimBase m, Traversable f) 
=> Atlas (PrimState m)

The Atlas you want to pack these rectangles into.

-> (a -> m Pt)

for each item you want to pack, extract the size, with effects in m

-> (Maybe Pt -> a -> b)

when some fail to pack this will be called, with Just a position for each that succeeded, and Nothing for any that it failed on. The successes and failures may well be out of order.

-> (Pt -> a -> c)

when all succeed, this will be called with each position.

-> f a

A container full of things that you'd like to pack into the atlas.

-> m (Either (f b) (f c))

Either a mixture of successes and failures, or a successful pack.