GithubHelp home page GithubHelp logo

zoomoid / demo-man Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 228.14 MB

demo-man provides your listeners with fresh tunes with just a PUT of a button

License: MIT License

Dockerfile 1.73% JavaScript 51.21% HTML 0.33% Vue 21.66% Makefile 0.93% Shell 0.41% Python 6.94% SCSS 0.05% TypeScript 16.73%
microservices

demo-man's People

Contributors

dependabot[bot] avatar zoomoid avatar

Stargazers

 avatar

Watchers

 avatar

demo-man's Issues

Add SVG creation logic for new waveman

SVG rectangles are largely templatable and also require configuration files to be present.
As we mount the config files into the container using Kubernetes, we provide default configurations for usage outside of Kubernetes or without a proper ConfigMap.

The config files are JSON data which nodeJS can read directly using require / import, hence we do not need to emply JSON readers.

A example config map looks like this:

apiVersion: v1
kind: ConfigMap
metadata:
  name: demo-wave-man-config
  namespace: web
  labels:
    app: demo-man
    svc: wave-man
data:
  small.json: |
    {
      "step_width": 16,
      "height": 200,
      "color": "{{.color}}",
      "rounded": 8,
      "steps": 32,
      "gap": 7,
      "mode": "rounded_avg",
      "align": "center",
      "sr": 48000,
      "mono": true,
      "scale": 1,
      "dpi": 600,
      "preserveAspectRatio": "none" 
    }
  full.json: |
    {
      "step_width": 20,
      "height": 200,
      "color": "{{.color}}",
      "rounded": 10,
      "steps": 64,
      "gap": 4,
      "mode": "rounded_avg",
      "align": "center",
      "sr": 48000,
      "mono": true,
      "scale": 1,
      "dpi": 600,
      "preserveAspectRatio": "none"
    }

Note that the color property is used to template the color such that the API server can replace the escape string with whatever color the user requests.

Most information for the actual rectangles can be derived from the config map.

The rendering logic for the SVG rectangles should look roughly like this:

  1. Take an already transformed chunk from the queue of chunks. The chunks carry both the chunks value as well as the index, such that we can derive the X position
  2. Calculate the X position using the index:x := i * config.step_width
    3 Calculate the Y position of the rectangle: This depends on the mode we are in: For bottom mode, the Y position is
    y := (1 - chunk) * config.height, while for center mode, the Y position is y := (0.5 * config.height) - (0.5 * chunk * config.height), as we need to center the rectangle in the canvas.
  3. Calculate the width of the rectangle: width := config.step_width - config.gap
  4. Calculate the height of the rectangle: height := config.height * chunk

After this, append the rectangle to the SVG string already constructed.

Bootstrap the wave-man rewrite in NodeJS

Packages needed at least:

  • music-metadata
  • eslint
  • prettier
  • express

This time, we construct the SVG by hand, therefore, we do not need a package to create a canvas and add elements to it,
as we only create primitive rectangles with incremental x values

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.