Giter Site home page Giter Site logo

sbn's Introduction

sbn

A compiler for small drawing language sbn(SVG by Numbers). Inspired by John Maeda's book: Design by Numbers.

Supported Keywords

This compiler is work-in-progress. Here is a list of commands currently supported (v0.4.3) & planning to implement. (sbn language specification is compatible with Design by Numbers chapter 1 - 12)

  • Paper
  • Pen
  • Line
  • // comment
  • Set (variable)
  • { } (block)
  • Nested block
  • Repeat
  • (+ - / *) (calculations)
  • [x, y] (dot)
  • Copy Dots (calculation on dot)
  • Same ? / NotSame? (question)
  • Smaller ? / NotSmaller? (question)
  • Command (function)
  • Load (import)

usage

browser

include sbn.js in your html, sbn object will be available in global scope.

<script src="./lib/sbn.js"></script>

Call compile method. The compiler creates SVG out of sbn code you passed.

var code = 'Paper 95\nPen 1\nLine 50 15 85 80\nPen 30\nLine 85 80 15 80\nPen 70\nLine 15 80 50 15'
var svg = sbn.compile(code)

document.body.innerHTML = svg

node

You can run sbn compiler on node to create SVG file.

var fs = require('fs')
var sbn = require('sbn')

var code = `
  Paper 95
  Pen 1
  Line 50 15 85 80
  Pen 30
  Line 85 80 15 80
  Pen 70
  Line 15 80 50 15
`

fs.writeFile("sbn_drawing.svg", sbn.compile(code), function(err) {
    console.log('SVG was saved!')
})

License

Copyright 2016 Mariko Kosaka

Code licensed under the Apache-2.0 License Documentation licensed under CC BY-SA 4.0

sbn's People

Contributors

kosamari avatar

Watchers

James Cloos avatar Emran 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.