Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6782739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:46:46+00:00 2026-05-26T16:46:46+00:00

I got a script that generates 100 elements and appends them to the site.

  • 0

I got a script that generates 100 elements and appends them to the site.
I’m using jquery to let the elements move to the left or right side but I was wondering if there would be some kind of algorithm to create a cross or a cirle out of those elements.

So you have 100 small boxes and the algorithm moves them around and formes a circle or other easy symbols.

I did some researching but I couldn’t find something usable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:46:46+00:00Added an answer on May 26, 2026 at 4:46 pm

    Note: This is a super hacky, quickly put together solution that has a couple obvious flaws, but I’m sure that you can work those out for yourself:

    Here’s what I might do (well, a little cleaner, but it would probably be along these lines):

    $(function(){
        // generate the boxes
        for(var n = 0; n < 100; ++n) {
            $("<div/>",
                {
                    id: n,
                    style: "width: 20px;\
                        height: 20px;\
                        background-color: red;\
                        position: absolute;",
                }
            ).appendTo("#container");
        }
    
        var mid = {
            x: 250,
            y: 250
        };
        var w = 300;
    
        function circle() {
            for(var n = 0; n < 100; ++n) {
                $("#"+n).css("top", (mid.y + (Math.sin(Math.PI/((n+1)/100)) * w/2)));
                $("#"+n).css("left", (mid.x + (Math.cos(Math.PI/((n+1)/100)) * w/2)));
            }
        }
    
        function square() {
            // top
            var n = 0;
            for(; n < 25; ++n) {
                $("#"+n).css("top", mid.y - 150);
                $("#"+n).css("left", w * (n/25) + mid.x / 2);
            }
            // right
            for(; n < 50; ++n) {
                $("#"+n).css("top", (w * ((n-25)/25)) + mid.y/2);
                $("#"+n).css("left", mid.x + w/2);
            }
            // bottom
            for(; n < 75; ++n) {
                $("#"+n).css("top", mid.y + 300/2);
                $("#"+n).css("left", w * ((n-50)/25) + mid.x / 2);
            }
            // left
            for(; n < 100; ++n) {
                $("#"+n).css("top", (w * ((n-75)/25)) + mid.y/2);
                $("#"+n).css("left", mid.x - w/2);
            }
        }
    
        var fns = [circle,
                   square];
    
        var idx = 0;
        setInterval(function() {
            fns[idx]();
            if(++idx >= fns.length) idx = 0;
        }.bind(this), 1000);
    });
    

    http://jsfiddle.net/bBEau/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a script that sets some session values before redirecting to / using
Ive got a VBS Script that,generates an url to download a file from a
I got this php script that generates reports that take 20 to 30 seconds
I've got a script that takes a user uploaded RTF document and merges in
I've got a script that dynamically calls and displays images from a directory, what
I've got a script that changes the background colour of text that has been
I've got a PHP script that needs to invoke a shell script but doesn't
I've got a Perl script that needs to execute another Perl script. This second
I have got a demo script that lets me authorize with my app and
I've got a script control that has a control embedded within it that exposes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.