Closed buglessir closed 5 years ago
I'm trying to use trackingJS with a simple and flat image.
This is my source image : http://s9.picofile.com/file/8333543400/circles.jpg
And this my code to add green color :
`window.onload = function() { var img = document.getElementById('img'); var demoContainer = document.querySelector('.demo-container');
var tracker = new tracking.ColorTracker(['magenta', 'cyan', 'yellow', 'green']); tracking.ColorTracker.registerColor('green', function(r, g, b) { if (r < 50 && g > 200 && b < 50) { return true; } return false; }); tracker.on('track', function(event) { event.data.forEach(function(rect) { window.plot(rect.x, rect.y, rect.width, rect.height, rect.color); }); }); tracking.track('#img', tracker); window.plot = function(x, y, w, h, color) { var rect = document.createElement('div'); document.querySelector('.demo-container').appendChild(rect); rect.classList.add('rect'); rect.style.border = '2px solid ' + color; rect.style.width = w + 'px'; rect.style.height = h + 'px'; rect.style.left = (img.offsetLeft + x) + 'px'; rect.style.top = (img.offsetTop + y) + 'px'; }; };`
After this config I get this error :
Error: Color not valid, trynew tracking.ColorTracker("magenta").
Error: Color not valid, try
.
I followed the main doc to add custom color, but what's the right way to adding new colors ?!
Thank you
@eduardolundgren Hi, do you have any idea ? thanks
This problem solved, because my color code was not equal by image color codes.
I'm trying to use trackingJS with a simple and flat image.
This is my source image : http://s9.picofile.com/file/8333543400/circles.jpg
And this my code to add green color :
`window.onload = function() { var img = document.getElementById('img'); var demoContainer = document.querySelector('.demo-container');
After this config I get this error :
Error: Color not valid, try
new tracking.ColorTracker("magenta").
I followed the main doc to add custom color, but what's the right way to adding new colors ?!
Thank you