Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. '##############################################################################################################################################################
    
  2. Sub EWH_Line(Byref V_Image As EWH_Image_Type Ptr, Byref V_X1 As Integer, Byref V_Y1 As Integer, Byref V_X2 As Integer, Byref V_Y2 As Integer, Byref V_Color As Uinteger = &HFFFFFFFF, Byref V_Box As Ubyte = 0, Byref V_Filled As Ubyte = 0, Byref V_LineStyle As EWH_LineStyle_Enum = EWH_LineStyle_Continues)
    
  3. If V_Image = 0 Then Exit Sub
    
  4. If V_Image->V_Data = 0 Then Exit Sub
    
  5. Dim TX1 As Integer = V_X1
    
  6. Dim TX2 As Integer = V_X2
    
  7. Dim TY1 As Integer = V_Y1
    
  8. Dim TY2 As Integer = V_Y2
    
  9. Dim TC1 As Uinteger '= (V_X1 mod 1)
    
  10. Dim TC2 As Uinteger '= (V_Y1 mod 1)
    
  11. Dim TMDLen As Uinteger = V_Image->V_Width * V_Image->V_Height
    
  12. With *V_Image
    
  13.         'line between 2 points
    
  14.         If TX1 = TX2 Then
    
  15.             If TX1 < 0 Then TX1 = 0
    
  16.             If TX1 >= .V_Width Then TX1 = .V_Width - 1
    
  17.             If TX2 < 0 Then TX2 = 0
    
  18.             If TX2 >= .V_Width Then TX2 = .V_Width - 1
    
  19.             If TY1 < 0 Then TY1 = 0
    
  20.             If TY1 >= .V_Height Then TY1 = .V_Height - 1
    
  21.             If TY2 < 0 Then TY2 = 0
    
  22.             If TY2 >= .V_Height Then TY2 = .V_Height - 1
    
  23.             If TX1 > TX2 Then Swap TX1, TX2
    
  24.             If TY1 > TY2 Then Swap TY1, TY2
    
  25.             For Y As Integer = TY1 To TY2
    
  26.                 V_Image->V_Data[Y * .V_Width + TX1] = V_Color
    
  27.             Next
    
  28.         Elseif TY1 = TY2 Then
    
  29.             If TX1 < 0 Then TX1 = 0
    
  30.             If TX1 >= .V_Width Then TX1 = .V_Width - 1
    
  31.             If TX2 < 0 Then TX2 = 0
    
  32.             If TX2 >= .V_Width Then TX2 = .V_Width - 1
    
  33.             If TY1 < 0 Then TY1 = 0
    
  34.             If TY1 >= .V_Height Then TY1 = .V_Height - 1
    
  35.             If TY2 < 0 Then TY2 = 0
    
  36.             If TY2 >= .V_Height Then TY2 = .V_Height - 1
    
  37.             If TX1 > TX2 Then Swap TX1, TX2
    
  38.             If TY1 > TY2 Then Swap TY1, TY2
    
  39.             For X As Integer = TX1 To TX2
    
  40.                 V_Image->V_Data[TY1 * .V_Width + X] = V_Color
    
  41.             Next
    
  42.         Else
    
  43.             Dim TMultiplier As Double
    
  44.             Dim TMinX As Integer = TX1
    
  45.             Dim TMinY As Integer = TY1
    
  46.             Dim TMaxX As Integer = TX2
    
  47.             Dim TMaxY As Integer = TY2
    
  48.             If TX1 > TX2 Then TMinX = TX2: TMaxX = TX1
    
  49.             If TY1 > TY2 Then TMinY = TY2: TMaxY = TY1
    
  50.             If Abs(TX2 - TX1) > Abs(TY2 - TY1) Then
    
  51.                 TMultiplier = Abs(TY2 - TY1) / Abs(TX2 - TX1)
    
  52.                 If TX1 < TX2 Then
    
  53.                     For X As Uinteger = TX1 To TX2
    
  54.                         If TMDLen > (Cint(TMinY + (X - TMinX) * TMultiplier) * .V_Width + X) Then
    
  55.                             V_Image->V_Data[CInt(TMinY + (X - TMinX) * TMultiplier) * .V_Width + X] = V_Color
    
  56.                         End If
    
  57.                     Next
    
  58.                 Else
    
  59.                     For X As Uinteger = TX2 To TX1
    
  60.                         If TMDLen > (Cint(TMinY + (X - TMinX) * TMultiplier) * .V_Width + X) Then
    
  61.                             V_Image->V_Data[CInt(TMinY + (X - TMinX) * TMultiplier) * .V_Width + X] = V_Color
    
  62.                         End If
    
  63.                     Next
    
  64.                 End If
    
  65.             Else
    
  66.                 TMultiplier = Abs(TX2 - TX1) / Abs(TY2 - TY1)
    
  67.                 If TY1 < TY2 Then
    
  68.                     For Y As Uinteger = TY1 To TY2
    
  69.                         If TMDLen > (Y * .V_Width + Cint(TMinX + (Y - TMinY) * TMultiplier)) Then
    
  70.                             V_Image->V_Data[Y * .V_Width + Cint(TMinX + (Y - TMinY) * TMultiplier)] = V_Color
    
  71.                         End If
    
  72.                     Next
    
  73.                 Else
    
  74.                     For Y As Uinteger = TY2 To TY1
    
  75.                         If TMDLen > (Y * .V_Width + Cint(TMinX + (Y - TMinY) * TMultiplier)) Then
    
  76.                             V_Image->V_Data[Y * .V_Width + Cint(TMinX + (Y - TMinY) * TMultiplier)] = V_Color
    
  77.                         End If
    
  78.                     Next
    
  79.                 End If
    
  80.             End If
    
  81.         End If
    
  82. End With
    
  83. End Sub