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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:47:22+00:00 2026-06-04T23:47:22+00:00

I have some lines drawn using lineTo() and some arcs using arc(). I would

  • 0

I have some lines drawn using lineTo() and some arcs using arc(). I would like to draw these shapes I’ve created with their black-outlines clearly visible on top of a blue/white coloured background that I have. It’s pretty light so I know that the black will show. But it doesn’t.

I used the canvas itself to place the background image, is this wrong? Here’s the relevant code:

blueprint_background.onload = function(){
var pattern = context.createPattern(this, "repeat");
context.fillStyle = pattern;
context.rect(margin_x,margin_y,eff_width,eff_height);
context.fill();
};

And my beautiful shape:

//the three sides of the triangle
context.beginPath();
context.moveTo(loc_x, loc_y);
context.lineTo(loc_x, loc_y + 30); //vertical downwards
context.moveTo(loc_x, loc_y);
context.lineTo(loc_x + 20, loc_y + 15);
context.moveTo(loc_x, loc_y + 30);
context.lineTo(loc_x + 20, loc_y + 15); //go the other way to complete the triangle
context.stroke(); 

By the way if anybody wants to call be out on bad practices for drawing shapes using canvas, go for it before it becomes habit. For example I’m wondering after I call stroke() if I should call a closePath() method or something.

But yeah my main issue is that I can’t see the black lines on top of my image background.

Thanks for any help.

  • 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-04T23:47:24+00:00Added an answer on June 4, 2026 at 11:47 pm

    If the codes for your triangle is outside of the background’s onload part, then this might fix it:

    blueprint_background.onload = function(){
        //background
        var pattern = context.createPattern(this, "repeat");
        context.fillStyle = pattern;
        context.rect(margin_x, margin_y, eff_width, eff_height);
        context.fill();
        draw_triangle();
    };
    
    function draw_triangle(){                       //seperate function
        //triangle
        context.beginPath():
        context.moveTo(loc_x, loc_y);
        context.lineTo(loc_x, loc_y + 30);
        context.moveTo(loc_x, loc_y);
        context.lineTo(loc_x + 20, loc_y + 15);
        context.moveTo(loc_x, loc_y + 30);
        context.lineTo(loc_x + 20, loc_y + 15);
        context.stroke(); 
    };
    

    It is because your background will have to wait until it loaded, which will result in the background drawing on top of your triangle.

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

Sidebar

Related Questions

I'm using OpenGL ES on Android to draw some shapes, so I have some
I have some (fairly large) UIButtons. Instead of text, I would like to draw
I have some functions that use opengl to draw lines on the screen (health
I have a Format32bppArgb backbuffer, where I draw some lines: var g = Graphics.FromImage(bitmap);
I have external html5 canvas that you can paint on some lines using your
I have trouble using sed. I need to replace some lines in very deprecated
I'm trying to draw a line using ctx.lineTo in loop. I have small function
I have an applet which displays some data using circles and lines. As the
I have some code in a python string that contains extraneous empty lines. I
I have been reading over some code lately and came across some lines such

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.