views:

92

answers:

3

Prompt how to solve a problem, please.

I have a div containing text.

It is necessary that the text was in a circle.

alt text

From what to me to start to solve the given problem? Can be methods javascript (on a site it is connected jQuery)?

P.S. The decision should be crossbrowser.

+2  A: 

Maybe you are looking for this plugin:

http://nicodmf.github.com/TextMorph/en.html

Here are some demos:

http://nicodmf.github.com/TextMorph/demos/jquery.html

harpax
Good job on deciphering what he wanted!
Kyle Sevenoaks
I got it the first time i read that too... ;) ... Nevertheless.. an interesting question.... and +1 for the links...!
SpikETidE
Yes, references interesting. But it not that is necessary. It is my fault that I could not ask a question well. I have corrected a question.
Kalinin
+1  A: 

Can I guess at a translation?

  • you have a div containing text
  • you don't know the size, perhaps because the div size is linked to the browser width / screen resolution / parent div
  • you want a circle to "spin round the block" (have animated movement?) ie you want a circle to move round the div that contains the text
  • you want this to always happen irrespective of the size of the text-container div
  • the effect will be kind of like a 10,000 metre runner running round a track except the size of the track is dynamically generated

Not a solution, but I think a translation might be a better first start... Is this anywhere close to what you are trying to describe?

odavy
@odavy, I am sorry. I has very badly explained that it is necessary for me. I have corrected a question. Thanks for your remarks.
Kalinin
+1  A: 

I can think couple of methods:

  1. Wrap the text block by bigger element, resize it so that the circle will fit (you will need some serious math skills!) and use cross-browser Raphael library to draw a circle on it.

  2. Based on the width & height of text block, adjust top/bottom padding until the box is square and choose best matching background from different size pre-drawn images.

Sample code (using jQuery) to get the second idea, totally untested:

var images = [300, 200, 100];  // image dimensions from biggest to smallest
var textbox = $('#my-textbox');
var padding = 20;  // base padding, choose your own
var w = textbox.width();
var h = textnox.height();
var filler = (w > h ? (w - h) : (h - w)) / 2;  // how much extra padding needed?
var pver = w > h ? filler : padding;  // padding vertical
var phor = w > h ? padding : filler;  // padding horizontal
textbox.css({ paddingTop: pver, paddingBottom: pver,
              paddingLeft: phor, paddingRight phor });
$.each(images, function(i, dimension) {
    if (dimension < textbox.width())
        textbox.css('backgroundImage', 'url(/img/circle_' + dimension + '.png)');
});
jholster
@Yaggo, Raphael too heavy library that it to connect for one only this thing. Whether there is a decision on pure javascript?
Kalinin
Added a second idea, no external libraries needed.
jholster
@Yaggo, Preliminary drawn pictures do not suit. The text can be any size (it is impossible to draw the picture under every size test).
Kalinin
Draw just one big enough picture and use it as downscaled <img> element instead of background? Use absolute positioning / z-index to get it behind the text box.
jholster
I will test this code. Thank you.
Kalinin