'############################################################################################################################################################## 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) If V_Image = 0 Then Exit Sub If V_Image->V_Data = 0 Then Exit Sub Dim TX1 as Integer = V_X1 Dim TX2 as Integer = V_X2 Dim TY1 as Integer = V_Y1 Dim TY2 as Integer = V_Y2 Dim TC1 as UInteger '= (V_X1 mod 1) Dim TC2 as UInteger '= (V_Y1 mod 1) Dim TMDLen as UInteger = V_Image->V_Width * V_Image->V_Height With *V_Image 'line between 2 points If TX1 = TX2 Then If TX1 < 0 Then TX1 = 0 If TX1 >= .V_Width Then TX1 = .V_Width - 1 If TX2 < 0 Then TX2 = 0 If TX2 >= .V_Width Then TX2 = .V_Width - 1 If TY1 < 0 Then TY1 = 0 If TY1 >= .V_Height Then TY1 = .V_Height - 1 If TY2 < 0 Then TY2 = 0 If TY2 >= .V_Height Then TY2 = .V_Height - 1 If TX1 > TX2 Then Swap TX1, TX2 If TY1 > TY2 Then Swap TY1, TY2 For Y as Integer = TY1 to TY2 V_Image->V_Data[Y * .V_Width + TX1] = V_Color Next ElseIf TY1 = TY2 Then If TX1 < 0 Then TX1 = 0 If TX1 >= .V_Width Then TX1 = .V_Width - 1 If TX2 < 0 Then TX2 = 0 If TX2 >= .V_Width Then TX2 = .V_Width - 1 If TY1 < 0 Then TY1 = 0 If TY1 >= .V_Height Then TY1 = .V_Height - 1 If TY2 < 0 Then TY2 = 0 If TY2 >= .V_Height Then TY2 = .V_Height - 1 If TX1 > TX2 Then Swap TX1, TX2 If TY1 > TY2 Then Swap TY1, TY2 For X as Integer = TX1 to TX2 V_Image->V_Data[TY1 * .V_Width + X] = V_Color Next Else Dim TMultiplier as Double Dim TMinX as Integer = TX1 Dim TMinY as Integer = TY1 Dim TMaxX as Integer = TX2 Dim TMaxY as Integer = TY2 If TX1 > TX2 Then TMinX = TX2: TMaxX = TX1 If TY1 > TY2 Then TMinY = TY2: TMaxY = TY1 If Abs(TX2 - TX1) > Abs(TY2 - TY1) Then TMultiplier = Abs(TY2 - TY1) / Abs(TX2 - TX1) If TX1 < TX2 Then For X as UInteger = TX1 to TX2 If TMDLen > (CInt(TMinY + (X - TMinX) * TMultiplier) * .V_Width + X) Then V_Image->V_Data[CInt(TMinY + (X - TMinX) * TMultiplier) * .V_Width + X] = V_Color End If Next Else For X as UInteger = TX2 to TX1 If TMDLen > (CInt(TMinY + (X - TMinX) * TMultiplier) * .V_Width + X) Then V_Image->V_Data[CInt(TMinY + (X - TMinX) * TMultiplier) * .V_Width + X] = V_Color End If Next End If Else TMultiplier = Abs(TX2 - TX1) / Abs(TY2 - TY1) If TY1 < TY2 Then For Y as UInteger = TY1 to TY2 If TMDLen > (Y * .V_Width + CInt(TMinX + (Y - TMinY) * TMultiplier)) Then V_Image->V_Data[Y * .V_Width + CInt(TMinX + (Y - TMinY) * TMultiplier)] = V_Color End If Next Else For Y as UInteger = TY2 to TY1 If TMDLen > (Y * .V_Width + CInt(TMinX + (Y - TMinY) * TMultiplier)) Then V_Image->V_Data[Y * .V_Width + CInt(TMinX + (Y - TMinY) * TMultiplier)] = V_Color End If Next End If End If End If End With End Sub