Возможен ли прямой код вставки изображения в .js?
Всем привет!
Вопрос знатокам: Есть код: var o = { init: function(){ this.diagram(); }, random: function(l, u){ return Math.floor((Math.random()*(u-l+1))+l); }, diagram: function(){ var r = Raphael('diagram', 600, 600), rad = 73, defaultText = 'тут хотелось бы приатачить вывод картинки', speed = 250; r.circle(300, 300, 85).attr({ stroke: 'none', fill: '#E84854' }); var title = r.text(300, 300, defaultText).attr({ font: '20px Arial', fill: '#fff' }).toFront(); r.customAttributes.arc = function(value, color, rad){ var v = 3.6*value, alpha = v == 360 ? 359.99 : v, random = o.random(91, 240), a = (random-alpha) * Math.PI/180, b = random * Math.PI/180, sx = 300 + rad * Math.cos(b), sy = 300 - rad * Math.sin(b), x = 300 + rad * Math.cos(a), y = 300 - rad * Math.sin(a), path = [['M', sx, sy], ['A', rad, rad, 0, +(alpha > 180), 1, x, y]]; return { path: path, stroke: color } } $('.get').find('.arc').each(function(i){ var t = $(this), color = t.find('.color').val(), value = t.find('.percent').val(), text = t.find('.text').text(); rad += 30; var z = r.path().attr({ arc: [value, color, rad], 'stroke-width': 26 }); z.mouseover(function(){ this.animate({ 'stroke-width': 50, opacity: .75 }, 1000, 'elastic'); if(Raphael.type != 'VML') //solves IE problem this.toFront(); title.stop().animate({ opacity: 0 }, speed, '>', function(){ this.attr({ text: text + '\n' + value + '%' }).animate({ opacity: 1 }, speed, '<'); }); }).mouseout(function(){ this.stop().animate({ 'stroke-width': 26, opacity: 1 }, speed*4, 'elastic'); title.stop().animate({ opacity: 0 }, speed, '>', function(){ title.attr({ text: defaultText }).animate({ opacity: 1 }, speed, '<'); }); }); }); } } $(function(){ o.init(); }); Как тут можно реализовать вывод картинки вместо текста? var r = Raphael('diagram', 600, 600), rad = 73, defaultText = 'тут хотелось бы приатачить вывод картинки вместо текста', speed = 250; Время пошло :) |
<img src="http://javascript.ru/forum/images/ca_serenity/misc/logo.gif"> <button onclick="a()">поменять</button> <script> function a(){ document.images[0].src = "data:image/gif;base64,R0lGODlhEgASANUAAP///+Dg2NjY0P/gINjQyNjQwP/YGPDQGOjQGPDIGOjIGOjAEODAEOC4ENi4GOCwENiwENCwENioEDD/AMioENigCMCoENCgCKiYgNCYCKCYeMiYCMCQCLiQCLCQCJiIaKiQELiICJCIYKiIEKiACKCACKh4AJh4EJh4CJhwCJBwCJhoAJBoCHhoOHhgOIhgAHBgMHBYCGhQGGhQCGBQGGhICGBIEGhIAFAwEAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUUABMALAAAAAASABIAAAbSwIlQSMC0bLYWhjBsCjWzUUShoJRmGudEADshDGDDIdFQwQTDgMxiGLjf4kVHFhCKQO23HodroD4TBTEHAzh6bjgAADgSNQQaIwaJhm+JiospGi4Okop8houWOBxHCm2eiQOhig0bNDambpdvlwoPrjARhId6BwsQIS0aJAl5fHoGZBUrGgUzDAeSiIg4CxIZNwUTIiULCdFgfAkLOBcrIkJqHg0LCgkJCgsNEhcmdENcLBIPDQ0PEBU2vDijRUONFB0uZAixokYWLUSMIFHCpEkQADs=" } </script> |
Часовой пояс GMT +3, время: 20:48. |