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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:46:52+00:00 2026-06-03T13:46:52+00:00

Javascript is very far from being one of my strengths; therefore apologies if my

  • 0

Javascript is very far from being one of my strengths; therefore apologies if my question appears very remedial to many of you.

I am attempting to implement Boids through Javascript and the HTML5 Canvas. Although the flocking behaviour has been established, the application looks rather plain upon a blank background.

For this reason, I am attempting to use an image as my background, but am having difficulties.

this.draw = function() {
        /* First clear everything */
        this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);

        /* And ink them */
        this.context.strokeStyle = "#000";
        this.context.stroke();

        /* Draw each boid */
        for(var i in this.boids) {
            this.boids[i].draw(this.context, this.size);
        }
    }

If anyone has knowledge of how to paint a background image within the above function, please can you let me know 🙂

  • 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-03T13:46:53+00:00Added an answer on June 3, 2026 at 1:46 pm

    Instead of doing it in Canvas, you can more easily set a background-image in the CSS:

    http://jsfiddle.net/qwzBh/

    That way you won’t have to worry about drawing it all the time.

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

Sidebar

Related Questions

Caveat: I'm VERY new at both Django and jQuery/Javascript. So far, it's driving me
Here's a piece of code I copied from http://www.schillmania.com/content/projects/javascript-animation-1/demo/ Very simple JS animation: function
I'm trying to understand how JSONP works, and from my so far very basic
I have a very simple JavaScript/jquery code which won't just work correctly. The problem
This could be a very basic Javascript I know but I just can't get
I have a very long javascript (so long that it's too long to escape
I am fighting with a very strange javascript behavior on a jQuery UI widget
First off, i'm a front end designer/developer with very very minimal javascript and PHP
Very new to javascript and html-type stuff. I wanted to just make a quick
I'm very new to Javascript (and jQuery). My JSFiddle really shows the issue in

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.