Draw the vectors so the tip of one vector is connected to the tail of the next 3. Make sure the length and direction of each arrow is correct. How to add vectors by the parallelogram method? The resultant is the diagonal starting from the joined tails. Free Vector Graphics Software Design with Vectr. Vectr is a free graphics software used to create vector graphics easily and intuitively. It's a simple yet powerful web and desktop cross-platform tool to bring your designs into reality.
- Bluetail 2 3 – Easy To Use Vector Drawing Application Online
- Bluetail 2 3 – Easy To Use Vector Drawing Application Printable
- Bluetail 2 3 – Easy To Use Vector Drawing Applications
- Bluetail 2 3 – Easy To Use Vector Drawing Application Form
This topic walks you through the process of creating the DemoApp class, which creates a window and uses Direct2D to draw a grid and two rectangles. In this tutorial, you learn how to create Direct2D resources and draw basic shapes. You also learn how to structure your application to enhance performance by minimizing resource creation.
To follow the tutorial, you can use Microsoft Visual Studio 2008 to create a Win32 project and then replace the code in the main application header and cpp file with the code described in this tutorial.
- Creating a Simple Direct2D Application.; 9 minutes to read +1; In this article. This topic walks you through the process of creating the DemoApp class, which creates a window and uses Direct2D to draw a grid and two rectangles.
- Vector Converter for macOS. Create your own Fashion Sketches. PrintLab Studio 3. Easy drag and drop design tool. 2020 Bluetail Team.
Note
If you want to create a Windows Store app that uses Direct2D, see the Direct2D Quickstart for Windows 8 topic.
For an overview of the interfaces you can use to create Direct2D content, see the Direct2D API Overview.
This tutorial contains the following parts:
Upon completion, the DemoApp class produces the output shown in the following illustration.
Part 1: Create the DemoApp Header
In this step, you set up your application to use Direct2D by adding the necessary headers and macros. You also declare the methods and data members you'll use in later parts of this tutorial.
- In your application header file, include the following frequently used headers.
- Declare additional functions for releasing interfaces and macros for error handling and retrieving the module's base address.
- Declare methods for initializing the class, creating and discarding resources, handling the message loop, rendering content, and the windows procedure.
- Declare pointers for an ID2D1Factory object, an ID2D1HwndRenderTarget object, and two ID2D1SolidColorBrush objects as class members.
Part 2: Implement the Class Infrastructure
In this part, you implement the DemoApp constructor and destructor, its initialization and message looping methods, and the WinMain function. Most of these methods look the same as those found in any other Win32 application. The only exception is the Initialize method, which calls the CreateDeviceIndependentResources method (which you define in the next part) that creates several Direct2D resources.
- In the class implementation file, implement the class constructor and destructor. The constructor should initialize its members to NULL. The destructor should release any interfaces stored as class members.
- Implement the DemoApp::RunMessageLoop method that translates and dispatches messages.
Bluetail 2 3 – Easy To Use Vector Drawing Application Online
- Implement the Initialize method that creates the window, shows it, and calls the DemoApp::CreateDeviceIndependentResources method. You implement the CreateDeviceIndependentResources method in the next section.
- Create the WinMain method that serves as the application entry point. Initialize an instance of the DemoApp class and begin its message loop.
Part 3: Create Direct2D Resources
In this part, you create the Direct2D resources that you use to draw. Direct2D provides two types of resources: device-independent resources that can last for the duration of the application, and device-dependent resources. Device-dependent resources are associated with a particular rendering device and will cease to function if that device is removed.
- Implement the DemoApp::CreateDeviceIndependentResources method. In the method, create an ID2D1Factory, a device-independent resource, for creating other Direct2D resources. Use the m_pDirect2DdFactory class member to store the factory.
- Implement the DemoApp::CreateDeviceResources method. This method creates the window's device-dependent resources, a render target, and two brushes. Retrieve the size of the client area and create an ID2D1HwndRenderTarget of the same size that renders to the window's HWND. Store the render target in the m_pRenderTarget class member.
- Use the render target to create a gray ID2D1SolidColorBrush and a cornflower blue ID2D1SolidColorBrush.
![Bluetail 2 3 – Easy To Use Vector Drawing Application Bluetail 2 3 – Easy To Use Vector Drawing Application](https://www.idevice.ro/wp-content/plugins/AppStoreZaone/images3/2014/11/16/abd63caaff158f0e13c246a09c940db3.jpg)
- Because this method will be called repeatedly, add an if statement to check whether the render target (m_pRenderTarget ) already exists. The following code shows the complete CreateDeviceResources method.
- Implement the DemoApp::DiscardDeviceResources method. In this method, release the render target and the two brushes you created in the DemoApp::CreateDeviceResources method.
Part 4: Render Direct2D Content
In this part, you implement the windows procedure, the OnRender method that paints content, and the OnResize method that adjusts the size of the render target when the window is resized.
- Implement the DemoApp::WndProc method to handle window messages. For the WM_SIZE message, call the DemoApp::OnResize method and pass it the new width and height. For the WM_PAINT and WM_DISPLAYCHANGE messages, call the DemoApp::OnRender method to paint the window. You implement the OnRender and OnResize methods in the steps that follow.
- Implement the DemoApp::OnRender method. First, create an HRESULT. Then call the CreateDeviceResource method. This method is called every time the window is painted. Recall that, in step 4 of Part 3, you added an if statement to prevent the method from doing any work if the render target already exists.
- Verify that the CreateDeviceResource method succeeded. If it didn't, don't perform any drawing.
- Inside the if statement you just created, initiate drawing by calling the render target's BeginDraw method. Set the render target's transform to the identity matrix, and clear the window.
- Retrieve the size of the drawing area.
- Draw a grid background by using a for loop and the render target's DrawLine method to draw a series of lines.
- Create two rectangle primitives that are centered on the screen.
- Use the render target's FillRectangle method to paint the interior of the first rectangle with the gray brush.
- Use the render target's DrawRectangle method to paint the outline of the second rectangle with the cornflower blue brush.
- Call the render target's EndDraw method. The EndDraw method returns an HRESULT to indicate whether the drawing operations were successful. Close the if statement you began in Step 3.
- Check the HRESULT returned by EndDraw. If it indicates that the render target needs to be recreated, call the DemoApp::DiscardDeviceResources method to release it; it will be recreated the next time the window receives a WM_PAINT or WM_DISPLAYCHANGE message.
- Return the HRESULT and close the method.
- Implement the DemoApp::OnResize method so that it resizes the render target to the new size of the window.
You've completed the tutorial.
Bluetail 2 3 – Easy To Use Vector Drawing Application Printable
Note
To use Direct2D, ensure that your application includes the d2d1.h header file and compiles against the d2d1.lib library. Class 6 social studies chapter 1. You can find d2d1.h and d2d1.lib in Windows Software Development Kit (SDK) for Windows 7.
Bluetail 2 3 – Easy To Use Vector Drawing Applications
Summary
In this tutorial, you learned how to create Direct2D resources and draw basic shapes. You also learned how to structure your application to enhance performance by minimizing resource creation.