Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   Interface and Graphics (http://www.xtremevbtalk.com/interface-and-graphics/)
-   -   How do you fill in a shape like in paint? (http://www.xtremevbtalk.com/interface-and-graphics/240350-fill-shape-paint.html)

Cipherzero 10-05-2005 09:44 PM

How do you fill in a shape like in paint?
I want to make an outline of a mask in a dc, then fill it in. The problem is i have no idea how to do this. Could someone point me to some method or code that will help me? The shape will always be a quadrilateral so i dont know if that makes it easier. Thanks in advance

passel 10-05-2005 10:38 PM

1 Attachment(s)
You can use FloodFill or ExtFloodFill to fill outlines, or solid colors, but I thing for creating your mask I would just use the polygon function.
You can search for polygon to find a number of examples.
A fairly simple example that might be adapted to your situation can be found in post #3 of this thread.

I don't think the following code is necessaryily ready for public consumption, it is just some code I worked on some time back playing around with ideas of doing isometric type drawing, but being allowed to rotate and tilt the view.
It uses both polygon and plgblt.

Since plgblt doesn't work on Win9x machines I'm not sure what will happen if you pick that option on a Win9x machine. It may draw nothing, or maybe it will do a poly.

This has been sitting around on my disk for quite awhile now, so I might as will post it for what it's worth, but be aware that the comments and code might not match. Originally I was drawing a single cube, then I drew four cubes (2x2), and added a grid of lines. That was when I added the comments. But I later made it 4x4 and instead of cubes varied the size (width, length, and height) so that it would be more like buildings on a square.
I then added the checkbox options to switch between using plgblt or polygon to draw the faces of the boxes.
I didn't update the comments so some of them are out of sync at this point.

As I said, this was just my experimental code, and so isn't really meant to do much of anything practical, and doesn't limit the tilt so that you don't go under or upside down, and you might run far enough away to loose where the boxes are.

The command button should reset everything back.
The mouse, I guess I left it where if you click, the circle moves toward the mouse (front and back) or spins towards the mouse (left and right) until you click it again.
The arrow keys will also do the motion. The A and Z key will tilt around the X Axis, as will the top skinny picturebox.
The four skinny pictureboxes are meant to be dragged on (like scrollbars) to rotate around the X and Y axis. (and "move" the circle).

A bit of a mess, but I didn't intend on anyone seeing this particular code.
On the other hand, I'm so busy now, I won't be doing anything with it for awhile and maybe it can serve at least as another example of using the polygon function.

Cipherzero 10-05-2005 11:30 PM

Well Passel, I gotta hand it to ya, thats some crazy stuff. Ill have to look at that in depth some time. Right now ill focus on the polygon function. Thank you.

Mathijsken 10-06-2005 02:58 AM

Are you saying you wrote a 3D-environment with API's????


passel 10-06-2005 07:13 AM

I'm not saying I wrote a 3D-environment, per se.
The code is just doing simple rotation of points around two axis and connecting those points in groups of 4 to form parallelograms which are aligned to create 3d boxes.

There is some ordering of the polygons to draw things in the correct order, but it is not necessarily a good way to do it.
It works in this case because all the boxes have the same orientation relative to each other and this code doesn't rotate the Z-axis which would break the simple check of looking at the "deepest" corner to figure out what quad should be draw first.

This is not really new, it is just variations of the same code I have from QBasic days and you can find old QBasic and VB code that does this type of stuff on the web (but often with just wireframe in the old QBasic).

In any case, most of the code I "played around with" along these lines is written in VB3 so I wouldn't post that here since the 16-bit API calls, and other stuff, would have to be modified for people to be able to use it.

If the principles in the code above were to be used in a "real" program, some smarter optimizations would have to be done to limit how many things are rotated, or considered for drawing, etc. Right now it loops through everything, but in a big environment you don't have time to run calculations and draw and collision test agains all the objects. You want to work out a way to only draw the stuff that is visible on the screen (and perhaps even limit that to a certain "depth" so far off objects aren't drawn).
And you would only want to collision test against objects near you.
And since it is isometric and not perspective, you would want to limit the rotation angles so that you don't "flatten" the view to where you need that perspective to make sense of what you're seeing.

The code above was the 3rd version of some old VB3 code that I ported to VB6 just for the purpose of trying out plgblt. Since plgblt is like stretchblt, but can use a mask, and it stretches the image to fit a parallelogram, I figured using it to do a rotatable, isometric type, game might be a good use for it.
plgblt has been mentioned a few times over that last several years in this forum, and elsewhere, but since it only works with NT based machines, probably has limited its mention.
But now that XP is fairly wide spread, it might be worth bringing up as an alternative to those who can use it and don't mind the restrictions.
I've though about, but haven't done it yet, trying to write code using the DMA graphics approach to emulate what plgblt does so that it could be used on the older Win9x machines, but I don't believe time will present itself anytime soon to pursue that.

x7z 10-07-2005 10:45 AM

1 Attachment(s)

Originally Posted by passel
Since plgblt doesn't work on Win9x machines I'm not sure what will happen if you pick that option on a Win9x machine. It may draw nothing, or maybe it will do a poly.

Note for passel:
Tested it on Win98SE machine:
With plgblt checked, it draws nothing..and the API call returns a value of "0".
Polygon works fine though.

Note for Cipherzero: If multiple quadrilateral masks are being generated (say for instance if you intent to use it to do trapezoidal perspective mapping), then you might also want to take a look at the PolyPolygon API:

Note for Mathijsken:
I think what Cipherzero is trying to go toward is not true 3D, but using perspective mapped 2D to achieve a Doom / Wolfenstein type first person maze effect. I'll attach a very primitive solid color (with shading) example below..

Cipherzero 10-11-2005 02:32 PM

Im not going for a maze like that, Im going for a side-view game, like super smash (though not the same style of play). The project I am working on is posted in this thread

All times are GMT -6. The time now is 03:40 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.