Skip to content

Instantly share code, notes, and snippets.

@ocharles

ocharles/wat.hs Secret

Created March 15, 2018 16:54
Show Gist options
  • Save ocharles/2c36ebc4eadae5602479ead97cb9917e to your computer and use it in GitHub Desktop.
Save ocharles/2c36ebc4eadae5602479ead97cb9917e to your computer and use it in GitHub Desktop.
where
rasteriseGerber
:: Gerber.GerberFile
->
OpenCV.CvExcept
( Diagrams.Transformation Diagrams.V2 Double
, OpenCV.Mat
( 'OpenCV.S [ 'OpenCV.D, 'OpenCV.D ] )
( 'OpenCV.S 1 )
( 'OpenCV.S Word8 )
)
rasteriseGerber commands = do
let
diagram =
case Gerber.drawDiagram commands of
Left e ->
error e
Right a ->
a
( space, pixels ) =
Diagrams.renderDiaT
Diagrams.Rasterific
( Diagrams.RasterificOptions
( Diagrams.mkWidth
( scale params * Diagrams.width diagram )
)
)
( Diagrams.bg Diagrams.white diagram )
traceShowM ( Diagrams.boundingBox diagram ) -- => fromCorners (P (V2 46.436661 (-0.997458))) (P (V2 182.97880600000002 123.825))
traceShowM ( fromPixelSpace space 0 ) -- => P (V2 46.43666100000002 (-123.825))
-- | Map the coordinates of a pixel into the space of a diagram.
fromPixelSpace
:: ( Floating n )
=> Diagrams.Transformation Diagrams.V2 n
-> Linear.Point Diagrams.V2 n
-> Linear.Point Diagrams.V2 n
fromPixelSpace space =
Diagrams.papply ( Diagrams.inv space )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment