Hi,

REALbasic 2007r1 Pro for Mac OS X 10.4.9

I was fooling around earlier today (2:10 at night) and fall into a trap: the 
code below fills and draw a Triangle using the Language Reference example.


Paste the code on a fresh project,
click once,
click a second time, but press the Option Key (for Linux and Windows, replace 
"AsyncOptionKey" by "AsyncAltKey": not tested).

You will still see the yellow line (the last one).


OK, I found a solution; replace the Else part using:

Else
    // Draw the PolyGon Border (Triangle)
    g.ForeColor = RGB(255,200,100) // A kind of yellow
    
    // Modify two values of the Points array (Index #3 and #6)
    Points(1) =  10  // X of Point 1
    Points(2) =  10  // Y of Point 1
    Points(3) =  73  // X of Point 2   -2
    Points(4) =  30  // Y of Point 2
    Points(5) =  10  // X of Point 3
    Points(6) = 123  // Y of Point 3   -2
    g.DrawPolygon Points

End If

and the previous "Frame Rect" or border will disappears completely. I love 
coherency and so I checked what does FillRect / DrawRect and it clears the 
yellow border.

    // Place this line just before the Else Statement
    g.FillRect 150,150,100,100


    // Place this line just before the End If Statement
    g.DrawRect 150,150,100,100



Action ?

HTH,

Emile

Now, if you compare (the rectangle part) to what AppleWorks does, I am wrong: 
AppleWorks Border (in the Vectorial module) is around the AppleWork interior 
(fill). But, in the other hand, I always disliked that AppleWorks feature!

:(:(:(:(:(:(:(:(:(:(:(:(:(

I'de better not talk about AppleWorks and the Vector module! I've gone to the 
Group2D Class / FigureShape Class, took the example, changed it a bit and... 
demonstrate that it have the same kind of trouble... Use it and discover it by 
yourself, then check what must be done. I am tired (at 2:45:00, this is a 
normal behavior... the "wake up" tomorrow will be ... oouuch!)

FigureShape Class example:

Function MouseDown(X As Integer, Y As Integer) As Boolean
  // Draw a triangle with FigureShape
  // Uses the LR example
  
  Dim fx As New FigureShape
  Dim g  As Graphics
  
  // Get a Window Graphics shortcut
  g = Self.Graphics
  
  // LR code
  fx.AddLine 0, 100, 50, 0
  fx.AddLine 50, 0, -50, 0
  If Keyboard.AsyncOptionKey Then  | A change here
    fx.Border  = 100 // opaque border
  Else
    fx.Border  = 0 // transparent border
  End If
  fx.BorderColor = &cFF0000  // red border
  fx.FillColor   = &cFFFF00  // yellow interior
  g.DrawObject fx, 100,100
End Function





PS: the three DrawLine were just a way to "fool around" as in "What happens if 
I write this ?"
same results using three lines instead of one (DrawPolygon) :)


Function MouseDown(X As Integer, Y As Integer) As Boolean
  // Draw a triangle with g.DrawPolygon Points(6)
  // Uses the LR example
  
  Dim Points(6) As Integer
  Dim g         As Graphics
  
  // Get a Window Graphics shortcut
  g = Self.Graphics
  
  // Fills the Points array
  Points(1) =  10  // X of Point 1
  Points(2) =  10  // Y of Point 1
  Points(3) =  75  // X of Point 2
  Points(4) =  30  // Y of Point 2
  Points(5) =  10  // X of Point 3
  Points(6) = 125  // Y of Point 3
  
  // Draw (Fill the interior or Draw the border) using two methods
  If Keyboard.AsyncOptionKey Then
    // Fill the PolyGon (Triangle)
    g.ForeColor = RGB(100,200,255) // A kind of blue
    g.FillPolygon Points
    
  Else
    // Draw the PolyGon Border (Triangle)
    g.ForeColor = RGB(255,200,100) // A kind of yellow
    
    // DrawPolyGon and the series of DrawLine share the same result:
    // the last line (yellow) is still there,
    // where the lines 1 and 2 are over painted in blue!
    g.DrawPolygon Points
    
    'g.DrawLine Points(1),Points(2),Points(3),Points(4)
    'g.DrawLine Points(3),Points(4),Points(5),Points(6)
    'g.DrawLine Points(5),Points(6),Points(1),Points(2)
  End If
End Function


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to