×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Nov 2006
    Posts
    63

    DrawPie draws a square...

    I've got the code for drawing a pie
    I followed the guide How to draw arcs and ellipses
    And it all works well in emulator, but on different phones (I've got S60 3rd ed. basic and FP1) it just always draws a full square. Maybe there's something missing in the documentation, b/c I have no idea what else can I add there...

    There's a code

    Code:
    //preparing pie
    
      TInt radiusX = iPieRect.Width()/2;
      TInt radiusY = iPieRect.Height()/2;
      iPieEnd.SetXY(iPieRect.iTl.iX + radiusX,iPieRect.iTl.iY);
      TPoint centre(iPieRect.iTl.iX + radiusX,
          iPieRect.iTl.iY+radiusY);
      
      TReal x = 360*aPercent*KDegToRad/100;
      TReal y = (360*aPercent/100+90)*KDegToRad;
      TReal dx, dy;
      TInt err = Math::Sin(dx, x);
      err = Math::Sin(dy, y);
      dx = centre.iX+(radiusX*dx*2);
      dy = centre.iY-(radiusY*dy*2);
    
    //this *2 is a factor to place the point outside of the square
    //I tried them outside, inside, one out one in, none worked...
    
      iPieStart.SetXY(dx, dy);
    
    
    //drawing pie
    ::Draw()
    {
      if (iPieStart != iPieEnd)
      {
      TRect pieRect(iPieRect);
      pieRect.Move(rect.iTl);
      TPoint pieStart(iPieStart+rect.iTl), pieEnd(iPieEnd+rect.iTl);
      gc.DrawPie(pieRect, pieStart, pieEnd);
      }
    }
    Krzysztof Kucharewicz

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: DrawPie draws a square...

    It may be some problem related to the emulated floating-point support of the devices.
    To check if DrawPie works at all, try some fixed values, like "gc.DrawPie(TRect(10,10,100,50),TPoint(50,0),TPoint(100,100));"

  3. #3
    Regular Contributor
    Join Date
    Nov 2006
    Posts
    63

    Re: DrawPie draws a square...

    Actually there was something else yet that caused the problem
    I was drawing the masked bitmap on the top of this ellipse and didn't reset the brush
    Code:
    SetBrushStyle(CGraphicsContext::ENullBrush);
    This wasn't a problem on emulator or S60 5th edition phone, so beware...

    Thanks for the advice with the TReal. I've also noticed that automatic conversion to TReal doesn't work well sometimes. Now using CFixed from NokiaCV
    Krzysztof Kucharewicz

Similar Threads

  1. Square Wave Wav Output using Audio
    By alistair9 in forum Symbian
    Replies: 1
    Last Post: 2011-01-03, 18:38
  2. Help with Math, Square Root
    By howl in forum Symbian
    Replies: 3
    Last Post: 2008-02-13, 11:41
  3. empty square on xhtml
    By thanray in forum Browsing and Mark-ups
    Replies: 4
    Last Post: 2006-05-31, 15:00
  4. Askew Bitmap scaling to a Square
    By DavidHSR in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2006-05-17, 14:48
  5. Extra square characters on chinese translation.
    By fmhunter in forum Mobile Java General
    Replies: 5
    Last Post: 2004-02-04, 00:14

Posting Permissions

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