Giter Club home page Giter Club logo

cornea's Introduction

cornea

Cornea is a library for 3D graphing and rendering in Haskell.

Here's an example:

import Cornea
import Codec.Picture (PixelRGBA8 (..), writePng)

axes :: World
axes = [ ( Edge [[0,0,0], [15, 0, 0]] , mark (PixelRGBA8 255 100 100 255) 1)
       , ( Edge [[0,0,0], [ 0,15, 0]] , mark (PixelRGBA8 100 255 100 255) 1)
       , ( Edge [[0,0,0], [ 0, 0,15]] , mark (PixelRGBA8 100 100 255 255) 1)
       ]

main :: IO ()
main = do
  writePng "/tmp/axes.png" $ render 500 500 10 $ axes `seenFrom` isometric

Axes

And here's a more contrived example. You can see the full source in app/Main.hs.

Axes

Usage

Cornea uses Graphics.Rasterific under the hood to draw and style things, so each object to be drawn is a tuple; the first bit is the point or set of points to draw, and the second is a Style of type

type Style = ([Primitive] -> Drawing PixelRGBA8 ())

typically this will be something like withTexture (uniformTexture <color>) . fill or withTexture (uniformTexture <color>) . stroke <thickness> JoinRound (CapRound, CapRound), so Cornea provides solid <color> and mark <color> <thickness>, which are shorter ways to write the same thing.

The object itself is easy to define.

data Obj = Cord [Float] | Edge [[Float]] | Face [[Float]] 

The only difference between an Edge and a Face is whether it draws a polyline or polygon (Rasterific primitives) under the hood. Both can be styled however which way.

cornea's People

Contributors

ambuc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.