forums

TNT Basic Forums > Programming Q&A
Canvas conundrum
< Last Thread     Next Thread >
Author
Thread        Post A Reply

03-21-2004 23:52

Posted by:
Peace

Location:
Lund, Sweden

Find more posts by Peace

Hi all,

I have a stupid newbie question, and I'd like some help.

Here's the code I use in my program (well, not the actual code -- this is a simplified version):

Graphics Mode 800, 600

Open Canvas 1, 400, 600
Canvas 1
Set Pen Colour Red
Paint Canvas
Copy Canvas 1,0,400,0,600 To 0,200,0

Draw Frame


Now, I expected this to make canvas 1 appear in the middle of the screen, but I don't see anything but black. The thing is, if i change the line Copy Canvas 1,0,400,0,600 To 0,200,0 into Copy Canvas 1 To 0, canvas 1 appears like one would expect it to, covering the left half of my screen. So I guess I'm doing something wrong with that particular line.

I want canvas 1 to appear in the middle of the screen, but I don't understand what I'm doing wrong. Could anyone help?

I'm running Hieroglyph version 2.2M1 and TNT Basic version 1.2 on MacOS X version 10.3.3.

Thanks,
-Peace

03-22-2004 09:31

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Hello. Are you new? If so, welcome to the community.

The problem is indeed in the copy canvas line. You have the coordinates mixed up.

quote:
Copy Canvas 1,0,400,0,600 To 0,200,0

The syntax for the copy canvas command is:
copy canvas id,x1,y1,x2,y2 to id2,x,y
This means the first number is the canvas id, and the next two are the x and y coordinates of the top left point of the rectangle to be copied. The two after that are the x and y coordinates of the bottom right point.
Your code is copying from point (0,400) to (0,600), which is a line with no width.

Try this code instead:
Copy Canvas 1,0,0,400,600 to 0,200,0

03-22-2004 12:00

Posted by:
Peace

Location:
Lund, Sweden

Find more posts by Peace

Yes, I am new, thanks!

And thank you for the help. I shall have to read the TNT Basic Help more carefully in the future.

(Note to self: RTFM.)

10-14-2004 00:19

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

Cloase Canvas Causes Crash

Argh....

When I close canvas #4, TNT crashes.
Canvas 4 has been opened and is used to store a picture.
Has anyone ever experienced a crash when closing a canvas?

Thanks,
MapMaker

10-18-2004 22:32

Posted by:
Mark Tully

Location:
TNT HQ, England

Click Here to Email Mark Tully   Find more posts by Mark Tully

I think this one is caused if you close a canvas but leave it as the current canvas for drawing. Trying doing a 'canvas 0' before closing the canvas.

See also: http://www.tntbasic.com/community/forums/showthread.php?threadid=677

Hope this helps,

Mark

10-18-2004 22:38

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

hey mark! you're there! it's been a long time!

10-20-2004 02:22

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

;)

Well at least you managed to spare me some time.
But unfortunately this doesn't fix the problem, and I tried everything in the other thread. Does anyone have any other ideas?

Thanks,
MapMaker

10-25-2004 23:56

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

Arrrggghhh....

Well I fixed the last probablem, but now a new one popped up. Its pretty much the oposite effect.

I open and use a canvas, and then close it, using the code


canvas 0
close canvas 6
canvas 0
draw frame


The canvas closes OK without crashes, but then TNT comes up and tells me:


*** Runtime exception caught ***
Line# : 1380
Code : draw frame
Error : Canvas 6 not open.


Well, canvas 6 did get closed... but I told it to switch to canvas 0! :(

Help?
MapMaker

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.