Giter VIP home page Giter VIP logo

Comments (4)

ShaneSutro avatar ShaneSutro commented on July 20, 2024

In a previous version we had the opposite of this problem where the line could not end with a bracketed-character code, so this is likely something similar. I’ll take a look into this.

from vestaboard.

coreyzev avatar coreyzev commented on July 20, 2024

I noticed that the code for .convertLine is very different than .convert(), they might need more in common.

from vestaboard.

ShaneSutro avatar ShaneSutro commented on July 20, 2024

@coreyzev I dug into this a bit more! Upon looking, this is not actually a bug, the .convert() method was always intended as a sort of "helper" to convert words and phrases more easily into the corresponding character codes. The thinking is that if you need a color character, you likely already know the number that the color maps to, so it doesn't need to be supported when converting.

Example: if I wanted to prefix a line with 3 blue bits, I would (most likely) already know that blue == 67, so I wouldn't really need to convert that part, I would only need to convert the letters that follow it, so I would do something like

finalText = [67, 67, 67] + Formatter().convert(" 5 mins")
# output = [67, 67, 67, 0, 31, 0, 13, 9, 14, 19]

This is one of those cases where at the very least there should be better documentation, but there are a few use cases where this would be useful to actually implement what you're suggesting:

  1. When converting multiple things on a single line - you likely won't want to use convertLine there, though it may be an option depending on the use case, or
  2. When the color code has the potential to change as well as the letters based on a variable or condition. There's still a way to do it using the list join method above, but it would be nicer to just be able to pass in the already-supported bracketed numbers and have it parsed correctly, or
  3. As demonstrated in your use case, when colors surround a potentially changing text
    In your example, you'd need to do something like the below, which just feels unnecessarily verbose to me:
finalText = text = [65] + Formatter.convert('n') + [65] + Formatter.convert(' 5 mins')
# output = [65, 14, 65, 0, 31, 0, 13, 9, 14, 19]

I think we could re-write the convert() helper to accept character codes pretty easily since the logic already exists. I'll plan on implementing this in v1.1.0.

from vestaboard.

ShaneSutro avatar ShaneSutro commented on July 20, 2024

Released in v1.1.0!

from vestaboard.

Related Issues (15)

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.