Results 1 to 4 of 4

Thread: [Runtime Error]:Canvas does not allow drawing

  1. #1
    Join Date
    Mar 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [Runtime Error]:Canvas does not allow drawing

    help?

    Code:
    Gx := fx;
     Gy := fy;
     FindTimes := 3;
     for i := 1 to 2 do
     begin
      if Gx - 30 < 0 then Gx := MSCX - 30;
      if Gy - 30 < 0 then Gy := MSCY - 30;
      if (FindColorSpiralTolerance(Gx, Gy, Color[i], fx - 30, fy - 30,
      fx + 30, fy + 30, 20)) then
      begin
        SetArrayLength(CountData, FindTimes);
          while (n < FindTimes) do
          begin
            if Gx - 20 < 0 then Gx := MSCX - 20;
            if Gy - 20 < 0 then Gy := MSCY - 20;
            CountData[n] := CountColorTolerance(Color[i], Gx - 20, Gy - 20, Gx + 20, Gy + 20, 20);
            n := n + 1;
            if (n = FindTimes) then Break; // No need to Wait(100) again...
            Wait(100);
          end;
          BubbleSort(CountData);
          Count := iAbs(CountData[Length(CountData)-1] - CountData[0]);
          if (Count > 40) then
          begin
             Result := FindGas(gx, gy);
             if (Result) then
             Writeln('** Found Gas ** Pixel Count Change is [' + inttostr(Count) + ']' );
          end;
          Gx := fx;
          Gy := fy;
      end;
     end;
    end;

  2. #2
    Join Date
    Dec 2007
    Posts
    2,766
    Mentioned
    2 Post(s)
    Quoted
    37 Post(s)

    Default

    If it sais that canvas doesn't allow drawing that means, instead you took : (x,y,x1,y1) you took (x1,y1,x,y)

  3. #3
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Or it means you're trying to perform something in a negative position (e.g. FindColor(-5,-1,5,1) though it won't be that obvious) - I think you have probably got a variable somewhere that may be negative and that's why. Most likely, fx or fy will be causing the error when it does 'fx - 30, fy - 30' but it may not be.
    Also, if this isn't your (I'm pretty sure it's the SRL gas finder) then just update your SRL rev and it should be fixed.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  4. #4
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    This is from the SRL Gas Finder, it is not his code, I presume...

    I don't think the start coordinates are wrong, but the end coordinates are. (gx + 30, gy + 30)

    There should be failsafe like if gx + 30 > ColorFindingTarget.Width...

    For now I'll add a Try...Except.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 05-28-2008, 07:01 PM
  2. Replies: 9
    Last Post: 02-05-2008, 01:36 PM
  3. Replies: 4
    Last Post: 02-02-2008, 10:04 AM

Posting Permissions

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