Results 1 to 7 of 7

Thread: Fill area with color depending on third value array

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2019
    Posts
    31
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Fill area with color depending on third value array

    Uwe, Thank for the answer,

    Yes, first of all I don't understand how to make gradient steps related to the QWT axes coordinate system.
    Actually I don't fully understand what input parameters of void QGradient::setColorAt(qreal position, const QColor &color) means beacause qreal position is a single number and I have two numbers (one for x- and other for y-axis).

    So in my case I'm trying to implement the second plot of https://www.mathworks.com/matlabcent...screenshot.png
    So for any (x0, y0) point I need to set color as bright as z0 value is.

    I tried:
    Qt Code:
    1. QLinearGradient linearGrad(QPointF(0, 1), QPointF(3, 1));
    2. linearGrad.setCoordinateMode(QGradient::StretchToDeviceMode);
    3. linearGrad.setColorAt(0, Qt::black);
    4. linearGrad.setColorAt(0.2, Qt::white);
    5. curve->setBrush(linearGrad);
    6. curve->setBaseline(1);
    7.  
    8. // ???????? ????? ?? ????? ????????? ??????
    9. QPolygonF points;
    10.  
    11. points << QPointF( 0.0, 0.0 ) // ?????????? x, y
    12. << QPointF( 0.5, 1.5 ) << QPointF( 1.0, 1.5 )
    13. << QPointF( 1.5, 1.0 ) << QPointF( 2.0, 0.5 )
    14. << QPointF(2.5, 0.5) << QPointF(3.0, 1.0);
    To copy to clipboard, switch view to plain text mode 
    And I get the image:
    qtasdf.jpg
    But I can't understand how points are related to the axes coordinate system?
    And the next step would be how to code color with z-value array for each point? I suspect it would be done with void QGradient::setColorAt(qreal position, const QColor &color) and the algorithm how to transform z-value to the color is well known in Internet and I think will find the answer for this.
    Attached Images Attached Images

Similar Threads

  1. Replies: 5
    Last Post: 17th December 2014, 12:07
  2. Replies: 10
    Last Post: 7th March 2012, 18:22
  3. Replies: 3
    Last Post: 7th September 2011, 12:26
  4. Fill area of QPainterPath
    By vides2012 in forum Qt Programming
    Replies: 6
    Last Post: 17th June 2011, 13:00
  5. Replies: 1
    Last Post: 9th May 2011, 15:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.