| 125424 | |
| 125425 | |
| 125426 | function cloudSprite(contextAndRatio, d, data, di) { |
| 125427 | if (d.sprite) return; |
| 125428 | var c = contextAndRatio.context, |
| 125429 | ratio = contextAndRatio.ratio; |
| 125430 | c.clearRect(0, 0, (cw << 5) / ratio, ch / ratio); |
| 125431 | var x = 0, |
| 125432 | y = 0, |
| 125433 | maxh = 0, |
| 125434 | n = data.length, |
| 125435 | w, |
| 125436 | w32, |
| 125437 | h, |
| 125438 | i, |
| 125439 | j; |
| 125440 | --di; |
| 125441 | |
| 125442 | while (++di < n) { |
| 125443 | d = data[di]; |
| 125444 | c.save(); |
| 125445 | c.font = d.style + " " + d.weight + " " + ~~((d.size + 1) / ratio) + "px " + d.font; |
| 125446 | w = c.measureText(d.text + "m").width * ratio; |
| 125447 | h = d.size << 1; |
| 125448 | |
| 125449 | if (d.rotate) { |
| 125450 | var sr = Math.sin(d.rotate * cloudRadians), |
| 125451 | cr = Math.cos(d.rotate * cloudRadians), |
| 125452 | wcr = w * cr, |
| 125453 | wsr = w * sr, |
| 125454 | hcr = h * cr, |
| 125455 | hsr = h * sr; |
| 125456 | w = Math.max(Math.abs(wcr + hsr), Math.abs(wcr - hsr)) + 0x1f >> 5 << 5; |
| 125457 | h = ~~Math.max(Math.abs(wsr + hcr), Math.abs(wsr - hcr)); |
| 125458 | } else { |
| 125459 | w = w + 0x1f >> 5 << 5; |
| 125460 | } |
| 125461 | |
| 125462 | if (h > maxh) maxh = h; |
| 125463 | |
| 125464 | if (x + w >= cw << 5) { |
| 125465 | x = 0; |
| 125466 | y += maxh; |
| 125467 | maxh = 0; |
| 125468 | } |
| 125469 | |
| 125470 | if (y + h >= ch) break; |
| 125471 | c.translate((x + (w >> 1)) / ratio, (y + (h >> 1)) / ratio); |
| 125472 | if (d.rotate) c.rotate(d.rotate * cloudRadians); |
| 125473 | c.fillText(d.text, 0, 0); |
| 125474 | |
| 125475 | if (d.padding) { |
| 125476 | c.lineWidth = 2 * d.padding; |
| 125477 | c.strokeText(d.text, 0, 0); |
| 125478 | } |
| 125479 | |
| 125480 | c.restore(); |
| 125481 | d.width = w; |
| 125482 | d.height = h; |
| 125483 | d.xoff = x; |