CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2010
    Posts
    3

    Zooming and 2D Graphics

    Hello, I am writing a 2D graphics program to draw basic shapes and I was hoping someone could help me figure out how to write a function which would allow the user to zoom in on the screen. My program uses Windows BGI. If you follow this link (http://csci.biola.edu/csci105/using_winbgi.html) you'll find winbgi2.cpp and graphics2.h, both of which are in my program, and I've also attached my ShapeGeometry.cpp and ShapeGeometry.h in case they are of any use to anyone. Any help would be much appraciated!
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Zooming and 2D Graphics

    Wow! Is this the same BGI graphics used by Borland in the Eighties? I didn't think modern command prompt windows even support DOS based graphics anymore. Why not use Windows GDI or GDIPlus?

    I don't think there's any easy way to do what you want with the tools you're using.

  3. #3
    Join Date
    May 2010
    Posts
    3

    Re: Zooming and 2D Graphics

    Well, this is what I was given to use by my professor. The main point of the project is to show that we can use objects. I know it is possible to make a zoom method because some of my classmates have done it. I am just not sure where to begin. The graphics I can make fairly easily. Zooming in and out is a different story. I'm not sure how zooming works in general, otherwise I am sure I could figure it out.

  4. #4
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Zooming and 2D Graphics

    I haven't looked at your BGI code, but I think you should be able to achieve this by basically multiplying all your x,y coordinates by your zoom factor.

  5. #5
    Join Date
    May 2010
    Posts
    3

    Re: Zooming and 2D Graphics

    Hey, thanks a bunch. I think this will do for my purposes. I feel kind of lame for not thinking of that in the first place. Thanks again.

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Zooming and 2D Graphics

    Sigh... And then they wonder why students taking Object Oriented programming courses end up being so bad at doing proper OO.

    'Graphical Shapes' is such a bad example to work with. Taking real life 'objects' and trying to match them with the 'Objects' (classes) in OO is just a really really bad mindset. It's one of the first things we always have to stamp out of new job recruits.

    In real life a circle is a special form of an oval
    a square is a special form of a rectangle

    trying to enforce this type of thinking into an OO design class hierarchy (class shape has a derived class rectangle and this in turn has a derived class square) is just asking for problems.
    Most books and courses using this very 'shapes' example invariably end up weasling their way out of it either by awful implementation or by just avoiding the issue altogether.

    Your teacher deserves a slapping.
    For perpetuating bad design concepts, and for making you use antiquated user interfaces.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured