Code Monkey home page Code Monkey logo

doodle's Introduction

Doodle: Compositional Graphics

Copyright 2015-2017 Underscore.

A Scala library for compositional vector graphics, with a desktop back-end via Swing and Java2D, and an HTML SVG back-end via Scala.js.

Distributed under the Apache 2.0 license.

Build Status Join the chat at https://gitter.im/underscoreio/doodle

Using Doodle

You can use Doodle in your own project by importing the JARs published to our Bintray repository. The current release is 0.8.3. To use it add the following to your build.sbt:

scalaVersion := "2.12.6" // Doodle is currently published for Scala 2.12 only
resolvers += Resolver.bintrayRepo("underscoreio", "training")
libraryDependencies += "underscoreio" %% "doodle" % "0.8.3"

Alternatively you can git clone or download Doodle and use it directly from the SBT console. See the instructions below.

Documentation

Creative Scala is currently the main documentation for Doodle. Creative Scala is a free introductory Scala ebook. Follow the link to download your copy from our web site.

Below we have a few tips to get you started.

Getting Started from SBT

  1. Start SBT:

    bash$ sbt
    
    > # This is the SBT prompt. Press Ctrl+D to quit to the OS.
  2. Start the console:

    > console
    
    scala> # This is the Scala prompt. Press Ctrl+D to quit to SBT.
  3. Use Scala commands to draw a shape in a native window:

    scala> (circle(10) fillColor Color.red).draw

    A window should appear containing a red circle.

  4. You can also save your masterpieces to a file.

    scala> (circle(10) fillColor Color.red).save[Png]("masterpiece.png")

    Doodle currently supports saving to PNG and PDF formats. Just alter the type parameter of save accordingly.

Drawing in the Browser

You can also draw Doodle pictures in the browser. The process is slightly different.

  1. Write your code in js/src/main/scala/Main.scala

  2. Start SBT:

    bash$ sbt
    
    > # This is the SBT prompt. Press Ctrl+D to quit to the OS.
  3. Compile the JS version:

    > fastOptJS
  4. Open your browser and point to http://localhost:12345/index.html to see an SVG version of the code.

Viewing the Examples

Doodle ships with a set of examples for each of the exercises in Creative Scala. See the shared/src/main/scala/doodle/examples directory for a complete list.

To view an example, simply run the sbt console, and draw the examples from there. For example:

bash$ sbt console

When the console is running, type

scala> Sierpinski.image.draw

Directory Structure

Source code is in the following directories:

 - shared / src / {main,test} / scala
 - jvm    / src / {main,test} / scala
 - js     / src / {main,test} / scala

SBT Commands

We provide three quick aliases for common commands:

> console   runs the console using the JVM codebase
> fastOptJS compiles the JS codebase
> test      runs the unit tests for both codebases

Acknowledgements

Doodle was written by Noel Welsh and Dave Gurnell with contributions from the contributors listed by Github.

doodle's People

Contributors

d6y avatar domesticmouse avatar indraastra avatar jo-osborne avatar julienrf avatar matmoore avatar ml10 avatar namn avatar noelhwelsh avatar noelwelsh avatar sethtisue avatar xuwei-k avatar

Watchers

 avatar  avatar  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.