• Stars
    star
    203
  • Rank 192,890 (Top 4 %)
  • Language
    JavaScript
  • Created about 8 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SVG by Numbers

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

More Repositories

1

sweaterify

make your own ugly sweater
JavaScript
215
star
2

color-mixer

Manipulate colors like you write Sass. Mix some colors like you paint.
JavaScript
83
star
3

who-pays-tech-speakers

code for who pays speakers
HTML
45
star
4

IoT-Boilerplate

Boilerplate to create Node.js IoT system with Arduino and Socket.io
JavaScript
45
star
5

observer

JS REPL which keeps track of global names
JavaScript
34
star
6

api-stub

Simple, no dependency, temporary API for your prototype
JavaScript
27
star
7

electroknit

Knitting for Javascripters
25
star
8

translucent

HTML
25
star
9

fokus

JavaScript
19
star
10

64sts

pattern generator in 64 stitches
HTML
16
star
11

scrolly-slides

HTML
13
star
12

TagBookmark

JavaScript
12
star
13

doodles

12
star
14

minimal-http-server

minimal http server written in Node's native http module
JavaScript
8
star
15

Geometry

JS implementation of examples from "A Programmer's Geometry"
6
star
16

Ghost-Image

Image turned into CSS box-shadow, literally Ghost.
HTML
6
star
17

ToastShow

HTML
5
star
18

kosamari.com

JavaScript
5
star
19

babel-plugin-transform-brazil-emoji

JavaScript
4
star
20

remind

Send /command to slack in batches
JavaScript
4
star
21

DecimalHexBinary

4
star
22

kumabot

slack bot I'm using
JavaScript
3
star
23

dotinstall-C

C
3
star
24

web.advent.today

HTML
3
star
25

WebRTCwithSocketIO

JavaScript
3
star
26

shift

JavaScript
3
star
27

OneAppEveryday

JavaScript
2
star
28

kniton

Knit Object Notation
2
star
29

transparent

HTML
2
star
30

knit2js

JavaScript
2
star
31

AubergineBot

Twitter Bot to turn eggplant emoji response to aubergine recipe
JavaScript
2
star
32

TalksAndDemos

CSS
2
star
33

data-exercise

1
star
34

big-text

1
star
35

codeadvent2015

canvas.adevent.today
HTML
1
star
36

electro.mechanical.computer

punchcard reader demo
HTML
1
star
37

bitmapart.com

JavaScript
1
star
38

nwjs-demo

HTML
1
star
39

gifffff

handy gif tool
HTML
1
star
40

theworldofpixels

HTML
1
star
41

d3-prototype

1
star