1 relative positioning of objects in a windowthe program

Assignment Help Computer Graphics
Reference no: EM13347432

1. Relative positioning of Objects in a Window

The program should draw a rectangle at the middle of the screen when started. The program could maintain a "relative" positioning of the object when resized.

For illustration, when the program is first executed, the figure is drawn at the center of the window, e.g., at 200, 200 with a 400 x 400 window. If the window is resized to, e.g., 600 x 600, the figure should remain at the center ( ½ x and ½ y ), now, 300 x 300. That is, the figure's position have to be relative to the area displayed by the window. A figure positioned at the center of a window will remain at the center of the window (rather than at the same x, y coordinates), even when the window is resized, and, hence, the client area size changes. Similarly, a figure at, e.g., x center and ¼ of the y size when the window size is changed will remain at those relative positions with any size windows, e.g., at 150, 100 with a 300 x 400 window will be 75, 50 when resized to 150 x 200. Note that resizing typically will not be symmetric for x and y change, which is fine, just have the same relative positions for the fig-ure's x and y.

2. Clicking and Dragging

The user should be able to "drag" the figure (object) anywhere on the screen by "mousing down", i.e., depressing and holding down the left mouse button, in the object and then moving the mouse.

The object in essence "follows" the cursor, as long as the left button is pressed down. This is accomplished by re-peatedly drawing and erasing the object as the mouse position moves. Erase only the object, vs. the entire client area. Again, when the object is dragged, feedback about its position is to be given to the user, i.e., it is repeatedly repositioned as the mouse cursor moves. Also, when it is selected and being dragged, feedback to the user is to be given to the user that is has been selected, by changing the solid outline of the figure to a dashed outline.

When the user releases the left mouse button, dragging is over, and the object has a new position. Recall that resiz-ing of the window should result in the relative positioning of the object (at its new location) in the window.

3. Animated Repositioning by Clicking

Provide functionality to allow the user to reposition the figure at a point indicated by "clicking", i.e., pressing and releasing, the right mouse button. When the right mouse button is clicked, the movement of the object should be animated in its movement to the new location, i.e., the figure should move in a straight line from its old position to its new position.

4. Enhancement: Differing Animation Speeds

Use the timer (as described in Petzold and which we'll talk about later, or any other method) to vary the speed at which the figure is repositioned using the right button, such that the figure initially moves slowly toward its new position when the button is released, speeds up toward the middle, and slows down at the end, using, say 1/3's of distance to define start, middle, and end.

Implementation notes:

As noted in class, programming complex API's can be, well, complex. One way to handle the complexity is to pro-gram "incrementally" by making a series of fairly small (often 1 line) modifications, testing each thoroughly (e.g., MessageBox's for variable values and to slow it all down, MessageBeeps to see what's executing), and proceeding iteratively until all functionality is implemented in your program. Though I'm in general glad to help in any way, it is in practice quite a challenge to go beyond a function call or two in finding any problems, and the best help I might give would be when the question is quite narrow. The debugger with breakpoints and single stepping can be a very valuable, and perhaps necessary, tool in Windows API programming. If you've not mastered it by now, it's time.

Detecting when button presses occur in particular areas of the screen is hit testing, as discussed in class. Doing it simply and transparently is likely preferable for your first programs to using the several Windows API functions that are available to do similar things. As a general note on Windows API programming for this course, as with any pro-gramming, there are certainly many ways to do things! What happens as one begins to explore the wide range of functions not discussed in class or in Petzold is that "subtleties" of usage arise, plenty of which have no real docu-mentation, and then you're pretty much on your own to figure things out - which is fine, just heads up! The presentations in class to date have been designed to introduce you to the rudiments of event driven programming and have focused on transparency of control flow and functionality. These pedagogic examples are also pretty easy to debug. Similarly for the Petzold examples, despite some elements of advanced C programming, those ex-amples are about as straightforward as can be. They were designed to be that way. The class presentations have also focused on "unpacking" those programs and have been selected to provide code examples useful in your as-signments.

For the relative positioning with window resize, etc., recall that the event handling function is repeatedly called, so use of static variables for figure location.

The animation can be accomplished with a simple loop at this point that does not relinquish processor control. Bad form later, but ok for now. We'll eventually learn about the timer. If you've had a course in graphics, Bresenham's algorithm would be perfect to determine the successive x and y locations for drawing the animated figure. If you're not familiar with Bresenham's algorithm for line drawing, fine, just use real values from the old y=mx+b equation (what's a microsecond more or less). There are lots of ways to do the animation that are inelegant, but work, and they are fine.

Reference no: EM13347432

Questions Cloud

Question 1 a sphere is trapped inside the box whose walls : question 1 a sphere is trapped inside the box whose walls are the following six planesx 2 x 8 y 0 y 10 z 3 z
You have to develop a basic temperature classnbsp base : you have to develop a basic temperature class.nbsp base skeleton code and a simple driver have been provided for
Catfish creek canoe companyin this age of development : catfish creek canoe companyin this age of development things got advanced and placed their effect on every aspect of
Case study southwestern universitysouthwestern university : case study southwestern universitysouthwestern university swu a large state college in stephenville texas enrolls close
1 relative positioning of objects in a windowthe program : 1. relative positioning of objects in a windowthe program should draw a rectangle at the middle of the screen when
Ellen is a graduate of the college of alternative medicine : ellen is a graduate of the college of alternative medicine and is looking to start her own business. she decides to
Scenarioprepare a power point presentation and a short : scenarioprepare a power point presentation and a short report relating to the capabilities of solidworks motion
Question 1nbsp the table sets out the demand and supply : question 1nbsp the table sets out the demand and supply schedules for chewing gum.pricecents per packquantity
What are the implications of the future of fabrication for : what are the implications of the future of fabrication for international trade transportation and

Reviews

Write a Review

Computer Graphics Questions & Answers

  Create a simple warm-up program using your g3d

Create a simple warm-up program using your G3D programming and graphics environment.

  Shadow effect while rolling a sphere

Shadow effect while rolling a sphere as well as the options of shading and lighting.

  Relative positioning and interactive positioning

Relative Positioning and Interactive Positioning by Dragging and Clicking and some Simple Animation

  Draw a teapot at the global origin

Draw a teapot at the global origin

  Concepts of computer graphics

Concepts of Computer Graphics and develop a program using OpenGL

  The security policy document outline

Using the GDI Case Study below, complete the Security Policy Document Outline

  Develop the image manipulations

Develop the image manipulations

  What does resolution mean

What does resolution mean How is resolution connected to ppi and dpi units

  Differentiate between a bitmap image and a vector image

Differentiate between a bitmap image and a vector image Explain the following terms

  Essential elements of a design pattern

configuration of an Iterator pattern, patterns could be used in a Library System, Singleton, Template, Decorator, Façade,What does Alexander means by the following declaration "But it is impossible to form anything which has the temperament of natu..

  Framework of user interface design

design of user interfaces, natural mapping, GUI applications, web page design different to designing for printed media, risks exposed in this "phone as individual proxy" approach, interaction designers of ubicomp applications, Storyboards are usual..

  What are the factors affecting picture composition

Define picture composition What are the factors affecting picture composition. Elaborate on each factor Describe the basic lines present in a composition

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd