Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Canvas and text cut off

Status
Not open for further replies.

AdamLink

Programmer
Jan 16, 2003
4
0
0
US
I'm new to Javascript (but not programming). So I'm using w3schools.com to learn.
Adapting one of the examples, I created the code in the attached file for experimenting and testing.

However, it cuts off the rectangle and text. The code draws three rectangles each 1 pixel longer to test where the cut off occurs. It's at 146 pixels.

I tried varying:
html, body {
<canvas id='timecol' style = 'position: absolute; left: 0px; top: 0px;' ></canvas>
strokeRect(x, y, boxWidth,boxHeight)
etc.

When tested on w3schools.com, Firefox, IE11 and Access web browser control, all give the same results.

Obviously, I'm missing something, but several hours of searching and head scratching have yielded no answers.

Can anyone tell me what's wrong?

Thanks.


 
 https://files.engineering.com/getfile.aspx?folder=23d839b5-0e0f-4868-aeb1-db1944983804&file=Grid.html
I would that this
HTML:
timeBox.strokeRect(5, 5, 40, 146);
is the most probable culprit




Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
After a bit more searching, the problem is here:

<canvas id='timecol' style = 'position: absolute; left: 0px; top: 0px;' ></canvas>

When I changed it to:

<canvas id='timecol' width='200px' height='1200px' ></canvas>

It worked.

It appears the canvas syntax is critical.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top