Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8619429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:20:12+00:00 2026-06-12T06:20:12+00:00

I have several DirectWrite text objects on a same render target and I want

  • 0

I have several DirectWrite text objects on a same render target and I want to transform one of them at one time while keep others no change, In Direct2D, there are several type of transforms

  • Render target transform
  • Geometry transform
  • Brush transform

I can not use render target transform since it affects all the objects on it

I can not use geometry transform, since text is not a geometry, and there is no transform method for IDWriteTextLayout.

So the only choice for me is brush transform, but when I try to use the solid brush to draw a transformed rectangle, it still draw it in the original place(see code below), the sdk demo show an example of bitmap brush transform, so my question is: does transform works for other type of brush? like solid brush?

here is my code, first, calculate a translate matrix based on the time elapsed, then use this matrix to translate the brush and at last draw the rectangle. please take a look and tell me whether this is the case or if I can do it in some way else?

VOID CalculateTranslationMatrix(D2D1_MATRIX_3X2_F* matrix) 
{ 
    static float totalTime = 0.0f; 

    // Get start time 
    static DWORD startTime = timeGetTime(); 

    // Get current time 
    DWORD currentTime = timeGetTime(); 

    // Calculate time elapsed 
    float timeElapsed = (currentTime - startTime) * 0.001f; 

    // Accumulate total time elapsed 
    totalTime += timeElapsed; 

    // Build up the translation matrix 
    matrix->_11 = 1.0f; 
    matrix->_12 = 0.0f; 
    matrix->_21 = 0.0f; 
    matrix->_22 = 1.0f; 
    matrix->_31 = totalTime; 
    matrix->_32 = totalTime; 
} 

VOID DrawRectangle(HWND hwnd) 
{ 
    CreateD2DResource(hwnd) ; 

    g_pRenderTarget->BeginDraw() ; 

    // Clear background color to white 
    g_pRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::White)); 

    D2D1_MATRIX_3X2_F matrix; 
    CalculateTranslationMatrix(&matrix); 
    g_pBlackBrush->SetTransform(&matrix); 

    // Draw Rectangle 
    g_pRenderTarget->DrawRectangle( 
        D2D1::RectF(10.f, 10.f, 50.f, 50.f), 
        g_pBlackBrush 
        ); 

    HRESULT hr = g_pRenderTarget->EndDraw() ; 
    if (FAILED(hr)) 
    { 
        MessageBox(NULL, "Draw failed!", "Error", 0) ; 

        return ; 
    } 
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:20:13+00:00Added an answer on June 12, 2026 at 6:20 am

    You could use render target transform, and just apply and restore states, eg:

    • Before draw, call g_pRenderTarget->GetTransform to get copy of the current transform
    • Set your desired object transform
    • Draw your object
    • use g_pRenderTarget->SetTransform using the value you saved before the draw.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several annotations on a mapview. After selecting one of them (callout enabled)
I have several dictionary files that i read in Java and while reading them
I have several .cpp and .hpp files. I want compile and lnk them over
I have several classes implements interface MyInterface and I want all of them to
I have several xml files with different node structure. I want to extract xml
I have several HTML elements (buttons) that fire the same JQuery AJAX request. When
We have several offices around the US and one in India. Our IT department
I have several separate instances of the same web application running on different servers
I have several CRUD operations to perform, each one on a collection of models
I have several 2-dimentional arrays under a hdf5 file, how can I merge them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.