GFColor/Testfrm.frm

VERSION 5.00
Begin VB.Form Testfrm
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4635
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4635
   StartUpPosition =   3 'Windows‑Standard
   Begin VB.CommandButton Command6
      Caption         =   "System C. Test"
      Height          =   375
      Left            =   1620
      TabIndex        =   11
      Top             =   2280
      Width           =   1395
   End
   Begin VB.CommandButton Command5
      Caption         =   "Lighten "
      Height          =   375
      Left            =   60
      TabIndex        =   10
      Top             =   2760
      Width           =   1515
   End
   Begin VB.CommandButton Command4
      Caption         =   "Darken"
      Height          =   375
      Left            =   60
      TabIndex        =   9
      Top             =   2280
      Width           =   1515
   End
   Begin VB.PictureBox Picture5
      Height          =   495
      Left            =   660
      ScaleHeight     =   435
      ScaleWidth      =   495
      TabIndex        =   8
      Top             =   1380
      Width           =   555
   End
   Begin VB.PictureBox Picture4
      Height          =   495
      Left            =   60
      ScaleHeight     =   435
      ScaleWidth      =   495
      TabIndex        =   7
      Top             =   1380
      Width           =   555
   End
   Begin VB.CommandButton Command3
      Caption         =   "IsColorEqual Again"
      Height          =   375
      Left            =   3060
      TabIndex        =   5
      Top             =   1800
      Width           =   1508
   End
   Begin VB.CommandButton Command2
      Caption         =   "IsColorEqual"
      Height          =   375
      Left            =   3060
      TabIndex        =   4
      Top             =   2280
      Width           =   1508
   End
   Begin VB.PictureBox Picture3
      Height          =   598
      Left            =   65
      ScaleHeight     =   540
      ScaleWidth      =   1065
      TabIndex        =   3
      Top             =   715
      Width           =   1118
   End
   Begin VB.CommandButton Command1
      Caption         =   "Invert"
      Height          =   375
      Left            =   3060
      TabIndex        =   2
      Top             =   2760
      Width           =   1515
   End
   Begin VB.PictureBox Picture2
      AutoRedraw      =   ‑1 'True
      Height          =   540
      Left            =   660
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   1
      Top             =   60
      Width           =   540
   End
   Begin VB.PictureBox Picture1
      Height          =   540
      Left            =   60
      Picture         =   "Testfrm.frx":0000
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   0
      Top             =   60
      Width           =   540
   End
   Begin VB.Shape Shape1
      BackStyle       =   1 'Undurchsichtig
      Height          =   375
      Left            =   1620
      Top             =   2760
      Width           =   1395
   End
   Begin VB.Label Label1
      Caption         =   "READABLE!"
      BeginProperty Font
         Name            =   "Arial"
         Size            =   22.5
         Charset         =   0
         Weight          =   700
         Underline       =   0 'False
         Italic          =   0 'False
         Strikethrough   =   0 'False
      EndProperty
      Height          =   598
      Left            =   1235
      TabIndex        =   6
      Top             =   715
      Width           =   3328
   End
End
Attribute VB_Name = "Testfrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'(c)2001 by Louis.

Private Sub Command1_Click()
    'on error resume next
    Dim Temp1 As Long
    Dim Temp2 As Long
    'preset
    Picture1.ScaleMode = vbPixels
    Picture2.ScaleMode = vbPixels
    'begin
    For Temp1 = 1 To Picture1.ScaleWidth
        For Temp2 = 1 To Picture2.ScaleWidth
            Picture2.PSet (Temp1, Temp2), GFColor_InvertColor(Picture1.Point(Temp1, Temp2))
        Next Temp2
    Next Temp1
End Sub

Private Sub Command2_Click()
    'on error resume next
    Dim GreyValue1 As Byte
    Dim GreyValue2 As Byte
    'preset
    GreyValue1 = Int((255 ‑ 0 + 1) * Rnd(1) + 0)
    GreyValue2 = Int((255 ‑ 0 + 1) * Rnd(1) + 0)
    'begin
    Picture3.BackColor = RGB(GreyValue1, GreyValue1, GreyValue1)
    Picture3.ForeColor = RGB(GreyValue2, GreyValue2, GreyValue2)
    Picture3.Cls
    Picture3.Print "This is a test"
    If (GFColor_IsColorEqual(Picture3.ForeColor, Picture3.BackColor)) Then
        Label1.Visible = False
    Else
        Label1.Visible = True
    End If
End Sub

Private Sub Command3_Click()
    'on error resume next
    Picture3.Cls
    Picture3.Print "This is a test"
    If (GFColor_IsColorEqual(Picture3.ForeColor, Picture3.BackColor)) Then
        Label1.Visible = False
    Else
        Label1.Visible = True
    End If
End Sub

Private Sub Command4_Click()
    'on error resume next 'darken
    Dim R As Long
    Dim G As Long
    Dim B As Long
    'preset
    R = Int((255 ‑ 1 + 1) * Rnd(1) + 1)
    G = Int((255 ‑ 1 + 1) * Rnd(1) + 1)
    B = Int((255 ‑ 1 + 1) * Rnd(1) + 1)
    'begin
    Picture4.BackColor = RGB(R, G, B)
    Picture5.BackColor = GFColor_ChangeBrightness(Picture4.BackColor, ‑32)
    Debug.Print GFColor_IsBrightnessChangable(Picture4.BackColor, ‑32)
End Sub

Private Sub Command5_Click()
    'on error resume next 'lighten
    Picture5.BackColor = GFColor_ChangeBrightness(Picture4.BackColor, 32)
    Debug.Print GFColor_IsBrightnessChangable(Picture4.BackColor, 32)
End Sub

Private Sub Command6_Click()
    'on error resume next
    '
    'NOTE: GFColor_ChangeBrightness() and all other color functions
    'on the same level return the input color unchanged if the input color
    'is a Windows system color.
    'That's why the shape back color stays unchanged.
    '
    Shape1.BackColor = GFColor_ChangeBrightness(Shape1.BackColor, 32)
End Sub


[END OF FILE]