Giter Site home page Giter Site logo

Comments (5)

davay42 avatar davay42 commented on June 20, 2024 1

HI! Glad you find Chromatone useful!

ABCjs implementation is a bit obscure for me as a Vue developer. And by default there are no specific classes on the notes in the SVG format. Like if we could have something class="G#5" for every rendered note, colorizing it can be done with just some CSS styles.

I couldn't make ABCjs embed such classes yet... And we don't have a browser plugin yet too 😅

from chromatone.center.

Utopiah avatar Utopiah commented on June 20, 2024 1

Absolutely, I'm a prototypist so it's as always very rough and I'm sure in plenty of cases it won't work... but hopefully enough to demonstrate the point as in https://twitter.com/utopiah/status/1627699500398567424

from chromatone.center.

Utopiah avatar Utopiah commented on June 20, 2024

Thanks for the clarification.

I'm tinkering with the SVG directly and using

const notes = {"C": "#7af500", "C#": "#00f500", "D": "#00f57a", "D#": "#00f5f5", "E": "#007af5", "F": "#0000f5", "F#": "#7a00f5", "G": "#f500f5", "G#": "#f5007a", "A":"#f50000", "A#": "#f57a00", "B": "#f5f500", };

[...[...document.querySelectorAll("[data-name=note]")][0].children]
.filter(e => e.getAttribute("data-name")?.match(/[_^]?[a-gA-G]{1}$/))
.map(n => n.setAttribute("fill", notes[n.getAttribute("data-name").toUpperCase()] ) )

I'm getting something.

I might do a Tridactyl autocmd looking for SVG generated by ABCjs so if I get anything useful going I'll share back here.

from chromatone.center.

Utopiah avatar Utopiah commented on June 20, 2024
const notes = {"C": "#7af500", "C#": "#00f500", "D": "#00f57a", "D#": "#00f5f5", "E": "#007af5", "F": "#0000f5", "F#": "#7a00f5", "G": "#f500f5", "G#": "#f5007a", "A":"#f50000", "A#": "#f57a00", "B": "#f5f500", };
// copied from https://chromatone.center/

[...document.querySelectorAll("[data-name=note]")].map( n => [...n.children].filter(e => e.getAttribute("data-name")?.match(/[_^]?[a-gA-G]{1}$/))
	.map(n => {n.setAttribute("fill", notes[n.getAttribute("data-name").toUpperCase().replace(/\^([A-G])/,"$1#").replace("=","")] );
		let notesarray = [...Object.getOwnPropertyNames(notes)];
    if ( n.getAttribute("data-name")[0]=="_") n.setAttribute("fill", notes[ notesarray[ [...Object.getOwnPropertyNames(notes),"C"].indexOf( n.getAttribute("data-name").toUpperCase().slice(-1) ) -1 ] ] )
	} ) 
)

doesn't cover every case but it's a start. I use the temporary object to loop back from e.g _C to B.

Can be tried in the console on https://chromatone.center/theory/notes/alternative/abc/

from chromatone.center.

davay42 avatar davay42 commented on June 20, 2024

Great job! Looks a bit hacky though. Will explore this later. Somewhat busy releasing the 2.0 version with deep refactoring under the hood.

from chromatone.center.

Related Issues (1)

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.