Giter VIP home page Giter VIP logo

wfdl's Introduction

WFDL โ€“ Watch Face Description Language

Language for defining dials of the watches

Watches

How to run

$ git clone https://github.com/gto76/wfdl.git
$ cd wfdl
$ python3 parse.py
  • Open 'index.html'.

Input

[
  {"a_len": 2, "a_width": 0.5, "b_off": 2, "b_len": 23, 
   "c_diameter": 3},
  [
    [1, 
      [12, "line", ["a_len", "a_width * 1.5"]], 
      [60, "line", [11, "a_width"]], 
      [240, "line", ["a_len", "a_width"]]],
    ["a_len + b_off", 
      [12, "line", ["b_len", 5]]],
    ["b_len - c_diameter", 
      [{"1/60", "-1/60"}, "circle", ["c_diameter"]]]
  ]
]

Output

Speedmaster

Explanation

Watch is defined by nesting following Python data structures: List, Dictionary and Set.

Top Level

On top level is a list that contains two elements. First one is a dictionary of variables, that defines name-value pairs.

  {"a_len": 2, "a_width": 0.5, "b_off": 2, "b_len": 23, 
   "c_diameter": 3},

Second element of the top level list is a list that contains descriptions of face elements.

  [
    [1, 
      [12, "line", ["a_len", "a_width * 1.5"]], 
      [60, "line", [11, "a_width"]], 
      [240, "line", ["a_len", "a_width"]]],
    ["a_len + b_off", 
      [12, "line", ["b_len", 5]]],
    ["b_len - c_diameter", 
      [{"1/60", "-1/60"}, "circle", ["c_diameter"]]]
  ]

Groups

Face elements are grouped by the distance from the watches edge. 0 means "on the edge" and 100 "in the center" of the watch. Our first group contains three elements, all of which are positioned one hundredth of the watches diameter from the edge.

    [1, 
      [12, "line", ["a_len", "a_width * 1.5"]], 
      [60, "line", [11, "a_width"]], 
      [240, "line", ["a_len", "a_width"]]],

Elements

Each element consists of three fields:

  • First one defines the number of times that it is repeated around the face.
  • Second one defines the shape of the element.
  • Third one is a list of parameters that are required by the specific shape.

For instance our first element contains 12 lines of length 'a_len' and width 'a_width * 1.5'.

      [12, "line", ["a_len", "a_width * 1.5"]], 

Complex Example

complex example

[
  {
    "a_len": 3, "a_width": 2, "b_off": 2, "b_len": 7,
    "c_len": 4, "c_width": 0.75, "d_len": 14, "d_width": 3,
    "sub_1_len": 70, "num_len": 13,
    "sub_1": [
        {"_b": 3,
        "subsub_face": [
            [
              [0,
                [1, "border", [1]]
              ],
              [10,
                [4, "number", [27, {"kind": -4, "offset": 0.5}, "lange", "horizontal"]]
              ]
            ]
          ]
        },
        [
          [0,
            [1, "border", [1]],
            [1, "border", [1], "num_len+19"]
          ],
          [0,
            [{0.5}, "face fixed centered", [90, "subsub_face"], 30]
          ],
          [4,
            [6, "line", [7, 3]],
            [30, "line", [10, 1.5]]
          ],
          [11,
            [[6, "-2/6", "2/6"], "number", ["num_len", 30, "lange", "half_rotating"]]
          ],
          ["2*num_len+4",
            [6, "bent_number centered", ["num_len", {"kind": "month", "offset": "1/12"}, "times"]],
            [12, "circle centered", [4]]
          ]
        ]
      ],
    "sub_2": [
        {"_b": 3,
        "subsub_face_1": [
            [
              [0,
                [1, "border", [1.5, 0.7]]
              ],
              [15,
                [1, "border centered", [10, 0.5]]
              ]
            ]
          ],
        "subsub_face_2": [
            [
              [0,
                [1, "border", [2.5]]
              ]
            ]
          ]
        },
        [
          [0,
            [1, "border", [1]]
          ],
          [4,
            [6, "line", [7, 3]],
            [12, "line", [14, 1.5]],
            [60, "line", [7, 1.5]]
          ],
          [11,
            [6, "number", ["num_len", "minute", "lange"]]
          ],
          [0,
            [1, "face fixed centered", [90, "subsub_face_1"]]
          ],
          ["num_len+4",
            [1, "border", [1]]
          ],
          ["num_len",
            [{"pos": 7, "offset": "1/14"}, "bent_number centered",
              ["num_len",  {"kind": "day", "offset": "1/14"}, "times"]]
          ],
          [0,
            [1, "face fixed centered", [60, "subsub_face_2"], "-(2*num_len+4)"]
          ],
          [0,
            [1, "upside_triangle", [33, 14], "-(2*num_len+4+14)"]
          ]
        ]
      ]
  },
  [
    [2,
      [{0.504}, "border", ["a_width/2", 0.709]],
      [{"tachy": [70, 100, 5, 120, 10]}, "line", ["a_len", "a_width"]],
      [{"tachy": [130, 240, 10]}, "line", ["a_len*0.8", "a_width*0.8"]],
      [{"tachy": {280, 330, 400}}, "line", ["a_len*0.6", "a_width*0.6"]],
      [{"tachy": [250, 400, 10]}, "line", ["a_len*0.6", "a_width*0.3"]]
    ],
    ["a_len+b_off",
      [1, "bent_number", [7, ["A. LANGE & SOHNE"], "lange_thin"], 3],
      [{"tachy": [70, 120, 10]}, "number", ["b_len", "tachy", "lange_thin"]],
      [{"tachy": {130, 140, 150, 160, 170, 180, 190, 210, 240}},
          "number", ["b_len*0.7", "tachy", "lange_thin", "perpendicular"]],
      [{"tachy": {280, 330, 400}}, "number", ["b_len*0.5", "tachy", "lange_thin"], 1]
    ],
    [10,
      [1, "border", [0.45]]
    ]
  ],
  [
    [0,
      [1, "border", [0.2]],
      [60, "line", ["c_len", "c_width"]],
      [300, "line", ["c_len*0.66", "c_width*0.66"]]
    ],
    ["c_len+b_off",
      [2, "two_lines", ["d_len", "d_width", 0.1]],
      [12, "line", ["d_len", "d_width"]]
    ],
    [4,
      [1, "lange_date", [29], 14],
      [{0.3135}, "face", ["sub_1_len", "sub_1"]],
      [{0.6865}, "face", ["sub_1_len", "sub_2"]]
    ],
    [18,
      [{0.5}, "moonphase", [20]]
    ]
  ]
]

wfdl's People

Contributors

gto76 avatar

Stargazers

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