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

  • Home
  • SEARCH
  • 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 8168327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:29:12+00:00 2026-06-06T20:29:12+00:00

My code: $(document).ready(function () { // Creates canvas 800 × 800 at 30, 50

  • 0

My code:

$(document).ready(function () {           

            // Creates canvas 800 × 800 at 30, 50
            var paper = Raphael(30, 50, 800, 800);
            $(document).click(function () {
                create(paper);
            });

            function create(paper) {

                // Creates circle at x = 250, y = 100, with radius 50
                var circle = paper.circle(250, 100, 50);
                // Sets the fill attribute of the circle to red (#f00)
                circle.attr("fill", "#f00");

                // Sets the stroke attribute of the circle to white
                circle.attr("stroke", "#EEE");
                circle.animate({ transform: "r" + 180 }, 1000);
           }
        });

i am able to create a circle when document is clicked. Please let me know the code for creating circle objects with different colours based on my click with flying animation on the page at dynamic locations using Raphael.js

  • 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-06-06T20:29:14+00:00Added an answer on June 6, 2026 at 8:29 pm

    Perhaps you can adapt something from this?

    var canvas = Raphael( 0, 0, 320, 240 );
    
    var backboard = canvas.rect( 0, 0, 320, 240 ).attr( { fill: 'white', stroke: 'none' } );
    
    backboard.click( function( event, x, y )
        {
            var bbox = backboard.getBBox();
            var x_ratio = x / bbox.width;
            var y_ratio = y / bbox.height;
    
            var color = 'rgb(' + Math.floor( x_ratio * 255 ) + ',0,' + Math.floor( y_ratio * 255 ) + ")";
    
            var transient_circle = canvas.circle( x, y, 25 ).attr( { fill: color, stroke: 'black', 'stroke-width': 1 } );
            transient_circle.animate( { cx: bbox.width / 2, cy: bbox.width / 3, 'fill-opacity': 0.25 }, 3000, ">", function()
                {
                    transient_circle.animate( { 'stroke-opacity': 0, 'fill-opacity': 0 }, 2500, function() 
                    { 
                        transient_circle.remove(); 
                    } );
                } );
        } );
    

    The fiddle is here.

    The general idea is that you capture the location of the click, using some variable of the location to determine the attributes of your circle, and then animate the circle from the click location to the center, where it then fades out and is removed. I kept the animations slow enough so that it’s possible to see lots of transparent circles of different colors overlapping, just because it’s sparkly.

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

Sidebar

Related Questions

Here is my code: $(document).ready(function(){ //These variables are for loading more posts var create_ptr
On document ready I run this code: jQuery(document).ready(function(){ jQuery('#button').click(function() { jQuery('#contact_form').load(/Users/mge/Downloads/jquery-ajax-1/readme.txt); return false; });
jQuery Code: $(document).ready(function(){ $.getJSON('dat.js', function(data) { var obj = JSON.parse(data); alert(obj[0].title); }); }); My
Consider the following code: $(document).ready(function() { $(body).append(<div class='outer'><span class='inner'>Click me</span></div>); $(html).click(function(event) { var targetClass
I have the following code: $(document).ready(function() { var id = 'cbx'; var idPrefix =
I have the following code $(document).ready(function() { $('a#slick-toggle').click(function() { $('#slickbox0').toggle(400); return false; }); });
My jQuery code: $(document).ready(function() { chrome.extension.sendRequest({get: height}, function(response) { height = response.value; }); $(#id).css(height,
Here is my code: $(document).ready(function(){ dropbox.addEventListener("dragenter", somethingHappens, false); }); function somethingHappens(evt) { // code
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
I have the following code block code when the document is ready: $(document).ready(function() {

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.