|
|||||||
| Programming, Coding, (Web)Design Discuss all your programming or design needs with likeminded people. |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Banned
Join Date: Jul 2002
Posts: 613
Rep Power: 0 ![]() |
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 |
|
|
|
|
|
#2 |
|
DriverHeaven Junior Member
Join Date: Oct 2004
Posts: 84
Rep Power: 0 ![]() |
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. |
|
|
|
|
|
|
|
Banned
Join Date: Jul 2002
Posts: 613
Rep Power: 0 ![]() |
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? |
|
|
|
|
|
#4 |
|
DriverHeaven Junior Member
Join Date: Oct 2004
Posts: 84
Rep Power: 0 ![]() |
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 11:44 PM. |
|
|
|
|
|
|
|
Banned
Join Date: Jul 2002
Posts: 613
Rep Power: 0 ![]() |
im trying to make a better line then borland makes got any ideas?
also where can i download the old bc for dos? |
|
|
|
|
|
#6 |
|
DriverHeaven Junior Member
Join Date: Oct 2004
Posts: 84
Rep Power: 0 ![]() |
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 - Parasite Coder |
|
|
|
|
|
|
|
Banned
Join Date: Jul 2002
Posts: 613
Rep Power: 0 ![]() |
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? |
|
|
|
|
|
#8 |
|
DriverHeaven Junior Member
Join Date: Oct 2004
Posts: 84
Rep Power: 0 ![]() |
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 - Parasite Coder |
|
|
|
|
|
|
|
Banned
Join Date: Jul 2002
Posts: 613
Rep Power: 0 ![]() |
help!! turbo c gives lots of linker errors
and the borland i use at school doesnt... |
|
|
|
|
|
#10 |
|
DriverHeaven Junior Member
Join Date: Oct 2004
Posts: 84
Rep Power: 0 ![]() |
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 - Parasite Coder |
|
|
|
|
|
|
|
Banned
Join Date: Jul 2002
Posts: 613
Rep Power: 0 ![]() |
is there any site where i can learn asm from the beginning?
|
|
|
|
![]() |
| Thread Tools | |
|
|