• Home
  • Reviews
  • Articles
  • News
  • Tools
  • GamingHeaven
  • Forums
  • Network
 

Go Back   DriverHeaven.net > Forums > Software / Tools > Programming, Coding, (Web)Design

Notices

Reply
 
LinkBack Thread Tools
Old Dec 2, 2004, 07:49 AM   #1
Banned
 
Join Date: Jul 2002
Posts: 613
shai is on a distinguished road

learning graphics with borland help anyone?

we need to make a painter so i need some good suggestions for a good engine to use (the loop and everything)
we have mouse.h
and i can use some good code suggestions to amaze my teacher
shai is offline   Reply With Quote
Old Dec 2, 2004, 03:21 PM   #2
DriverHeaven Junior Member
 
Join Date: Oct 2004
Posts: 84
Scar_T is on a distinguished road

i don't know how much knowledge you teacher has about coding (i tell this because my teachers were really bad :/ ) , you should know it, but anyway you could have some basic option like draw lines, circles, rectangles and a free hand tool would be nice .

Another good option would be to save/load the drawing that you make with your painting tool, something simple like saving what color index are been used, width and height of the picture.

For the drawing tools you can do this:

if(lbutton==down) //i don't know what is the name for this function on your mouse.h
{
drawing = true; //We said that we starting to draw
dtool = ATOOL; //Here we put what tool is been using by the user
lx = mouse.x; //It's a good idea to save the last pointer position
ly = mouse.y; //This will be used for the drawing tools
}

if(lbutton==up)
{
drawing = false; //We finish the drawing.
}

if(drawing==true) //User is drawing something
{
//We check what is it
switch(dtool)
{
case TLINE:
line(lx, ly, mouse.x, mouse.y);
break;
case TRECTANGLE: break;
rectangle(lx, ly, mouse.x, mouse.y);
case TCIRCLE: break;
radius = max(abs(lx-mouse.x), abs(ly-mouse.y));
circle(lx, ly, radius);
case TFREEHAND:
line(lx, ly, mouse.x, mouse.y);
lx = mouse.x; //we move to end of the current line
ly = mouse.y; //I made it with lines for avoid empty segments, make a test
// with putpixel
break;
}
}

This is only an example and it can be improved a lot, i hope it would be useful for you. Try to add some code for "erase" the last element (line, circle or rectangle) when the user is still moving the mouse with lbutton pressed.

See ya.
Scar_T is offline   Reply With Quote
Old Dec 2, 2004, 05:49 PM   #3
Banned
 
Join Date: Jul 2002
Posts: 613
shai is on a distinguished road

also i need to rotate something i made with the painter
and this painter is more complex then you might think and my teacher is very good he made the mouse.h by his own with asm very impressive
i need to make a box with the mouse like you choose a couple of items in windows if you know what i mean?
shai is offline   Reply With Quote
Old Dec 2, 2004, 06:11 PM   #4
DriverHeaven Junior Member
 
Join Date: Oct 2004
Posts: 84
Scar_T is on a distinguished road

Well, i also made my own mouse.h, it's not quite hard ^_^.

To rotate something you must use a rotation matrix:

|x| | cosA senA| |x|
| | = | | | |
|y| |-senA cosA| |y|

And for make a box, it's possible with the code that i wrote before, just add a few lines of code.

Last edited by Scar_T; Dec 2, 2004 at 06:44 PM.
Scar_T is offline   Reply With Quote
Old Dec 29, 2004, 02:26 PM   #5
Banned
 
Join Date: Jul 2002
Posts: 613
shai is on a distinguished road

im trying to make a better line then borland makes got any ideas?
also where can i download the old bc for dos?
shai is offline   Reply With Quote
Old Dec 29, 2004, 02:43 PM   #6
DriverHeaven Junior Member
 
Join Date: Oct 2004
Posts: 84
Scar_T is on a distinguished road

What do you mean with "a better line"? a smooth one?

You can donwload Turbo C++ 3.0 (which is made by Borland too) here:

http://download.pchome.net/php/dl.php?sid=9113
Scar_T is offline   Reply With Quote
Old Dec 30, 2004, 11:28 AM   #7
Banned
 
Join Date: Jul 2002
Posts: 613
shai is on a distinguished road

i mean a faster line function and more smooth of course
also i could use some help with making a polygon
and turbo c doesnt have mouse.h
not the one made with asm that is
also is there any place i can learn graphics asm?
i want to be able to use it with the turbo c
btw i found a fast line function in asm how can i add it to my code?
shai is offline   Reply With Quote
Old Dec 30, 2004, 02:57 PM   #8
DriverHeaven Junior Member
 
Join Date: Oct 2004
Posts: 84
Scar_T is on a distinguished road

A good algorithm for make lines is Bresenham's. http://www.cs.helsinki.fi/group/goa/...s/bresenh.html

If you want to use asm code inside a C program is with:

Code:
 __asm{
 	 //your asm code here
 }

I haven't coded graphics with asm for a long time ago, but I found this page: http://www.nuvisionmiami.com/books/a.../graphics1.htm, it's basic but it's a good start, i hope it'll be useful for you.
Scar_T is offline   Reply With Quote
Old Dec 31, 2004, 01:24 PM   #9
Banned
 
Join Date: Jul 2002
Posts: 613
shai is on a distinguished road

help!! turbo c gives lots of linker errors
and the borland i use at school doesnt...
shai is offline   Reply With Quote
Old Dec 31, 2004, 01:32 PM   #10
DriverHeaven Junior Member
 
Join Date: Oct 2004
Posts: 84
Scar_T is on a distinguished road

could you write the errors?

Anyway, a common linker error (when graphichs are used) is doesn't have the "Graphics Library" option checked in Options>Linker>Libraries. Could you see if this option is checked?
Scar_T is offline   Reply With Quote
Old Jan 2, 2005, 06:19 AM   #11
Banned
 
Join Date: Jul 2002
Posts: 613
shai is on a distinguished road

is there any site where i can learn asm from the beginning?
shai is offline   Reply With Quote
 

 
Powered by: vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Artwork by Allan 'Zardon' Campbell, vBulletin implementation by Craig '5320' Humphreys based on original artwork by Ratchet.

All times are GMT -5. The time now is 02:35 AM. Copyright ©2008 HeavenMedia.net