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 8499751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:45:11+00:00 2026-06-11T00:45:11+00:00

I need a chess board for my application and I wondering the options to

  • 0

I need a chess board for my application and I wondering the options to achieve it in Raphael.js.
Should I create 64 squares and connect them together or a single big block and shade it black and white.

  • 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-11T00:45:12+00:00Added an answer on June 11, 2026 at 12:45 am

    I think you can do it this way:

    You can describe a cell or box of the board like this:

    var cellSize = 25;//the size of our cell (whatever you want)
    //Where x, y are the position in the board and cellSate 
    //a value indicating if it is black or white.
    Raphael.fn.cell = function(x, y, cellState) {
       var size = cellSize;
       var crect = paper.rect(x, y, size, size);
       if(cellState == 1)
              crect.attr({fill: "#000"});
       else
              crect.attr({fill: "#fff"});
    }
    

    And to draw the board (modify it to your purpose):

    var chessBoard = function() {
       var cSize = 0;//auxiliary variable
       var last = 0;//allows to change the colour of the boxes
       for(var i = 0; i < rows; i += 1) {
          for(var j = 0; j < cols; j+= 1) {
              if(last == 1) {
                 paper.cell(i * cSize, j * cSize, 0);
                 last = 0;
              } else {
                 paper.cell(i * cSize, j * cSize, 1);
                 last = 1;
              }
    
              if(i == 0)
                 cSize = cellSize;
          }
          if(last == 1) last = 0;
          else last = 1;//my trick hehe
      }
    

    }

    Finally, in your HTML code:

        <!DOCTYPE HTML>
        <html>
        <head> 
        <script src="./js/raphael-min.js"></script>
        <script src="./js/gof.js"></script>
        <script>
           var paper;   
           function loadBoard() {
              paper = Raphael("panel", 512, 512);
              chessBoard(cells1);
           }
        </script>
        </head>
    
        <body onload="loadBoard();">
           <div id="panel" style="width:100%; height:100%; position:absolute; top:0; left:0;">
           </div>
        </body>
        </html>
    

    The ouput should be this (the gray part is from the browser):

    enter image description here

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

Sidebar

Related Questions

implementing code for customized mini(less squares, less pieces ) chess board in java or
I'm trying to create a chess game board with 8x8 buttons. I'm using nested
I'm looking at a scenario where I need to create a single master Silverlight
within a java chess application, I need at different points in time to invert
I am creating a multiplayer chess game in Visual Basic.Net and I need to
I have a 2D array that acts as a board for a chess game.
I have java swing chess application. Cursor has custom view - rectangle, sized to
Many times I found out that I need a software to create simple educational
I'm developing a 3D chess game in which I need to be able to
I need help in designing a Chess game. I've already started but haven't got

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.