Guidance
指路人
g.yi.org
software / rapidq / Examples / Graphics & Animation / Color / rgb websafe.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'AlanEJones(7/16/02 4:49:19 am):
'an updated version which gives cut and pasteable colour
'value output in &Hnnnnnn and RGB(n,n,n) format. It is also switchable
'between all colours and websafe only.
'rapidq uses bbggrr order

' Color Palette for Rapid-Q by William Yu
' Modified by Alan Jones

     DECLARE SUB ColorChange
     DECLARE SUB Paint
     DECLARE SUB Checked
     CONST False = 0
     CONST True = 1
     CREATE Font1 AS QFONT
      Name = "Courier New"
      Size = 8
     END CREATE
     CREATE Form AS QFORM
      Height = 260
      CAPTION = "Color Palette +"
      CREATE Check AS QCHECKBOX
       Top = 6
       Left = 90
       Width = 150
       Checked = True
       CAPTION = "Websafe colours only"
       OnClick = Checked
      END CREATE
      CREATE LabelRed AS QLABEL
       Left = 10
       Top = 32
       CAPTION = "Red:"
      END CREATE
      CREATE LabelGreen AS QLABEL
       Left = 5
       Top = 62
       CAPTION = "Green:"
      END CREATE
      CREATE LabelBlue AS QLABEL
       Left = 10
       Top = 92
       CAPTION = "Blue:"
      END CREATE
      CREATE Label AS QLABEL
       Left = 255
       Top = 12
       Font = Font1
       CAPTION = "Dec  Hex"
      END CREATE
      CREATE LabelNum1 AS QLABEL
       Left = 255
       Top = 32
       Font = Font1
       CAPTION = "  0  00"
      END CREATE
      CREATE LabelNum2 AS QLABEL
       Left = 255
       Top = 62
       Font = Font1
       CAPTION = "  0  00"
      END CREATE
      CREATE LabelNum3 AS QLABEL
       Left = 255
       Top = 92
       Font= Font1
       CAPTION = "  0  00"
      END CREATE
      CREATE ScrollRed AS QSCROLLBAR
       Left = 50
       Top = 30
       Width = 200
       Height = 20
       Min = 0: Max = 255
       ShowHint =  True
       Hint = "Red Attribute"
       SmallChange = 51
       OnChange = ColorChange
      END CREATE
      CREATE ScrollGreen AS QSCROLLBAR
       Left = 50
       Top = 60
       Width = 200
       Height = 20
       Min = 0: Max = 255
       ShowHint =  True
       Hint = "Green Attribute"
       SmallChange = 51
       OnChange = ColorChange
      END CREATE
      CREATE ScrollBlue AS QSCROLLBAR
       Left = 50
       Top = 90
       Width = 200
       Height = 20
       Min = 0: Max = 255
       ShowHint =  True
       Hint = "Blue Attribute"
       SmallChange = 51
       OnChange = ColorChange
      END CREATE
      CREATE PaintBox AS QCANVAS
       Left = 50
       Top = 120
       Height = 80
       Width = 200
       OnPaint = Paint
      END CREATE
      CREATE EdRGB AS QRICHEDIT
       Top = 210
       Left = 33
       Width = 135
       Height = 20
       Alignment = 2
       Font = Font1
      END CREATE
      CREATE EdBGR AS QRICHEDIT
       Top = 210
       Left = 180
       Width = 95
       Height = 20
       Alignment = 2
       Font = Font1
      END CREATE
      Center
      SHOWMODAL
     END CREATE

     SUB ColorChange
      IF Check.Checked = True THEN
       ScrollRed.Position = (ScrollRed.Position \ 51) * 51
       ScrollGreen.Position = (ScrollGreen.Position \ 51) * 51
       ScrollBlue.Position = (ScrollBlue.Position \ 51) * 51
      END IF
      LabelNum1.CAPTION = RIGHT$("  " + STR$(ScrollRed.Position), 3) + _
       "  " + RIGHT$(HEX$(ScrollRed.Position), 2)
      LabelNum2.CAPTION = RIGHT$("  " + STR$(ScrollGreen.Position), 3) + _
       "  " + RIGHT$(HEX$(ScrollGreen.Position), 2)
      LabelNum3.CAPTION = RIGHT$("  " + STR$(ScrollBlue.Position), 3) + _
       "  " + RIGHT$(HEX$(ScrollBlue.Position), 2)
      Paint
     END SUB

     SUB Paint
      PaintBox.Paint(0,0,RGB(ScrollRed.Position, ScrollGreen.Position, _
       ScrollBlue.Position), RGB(ScrollRed.Position, _
       ScrollGreen.Position, ScrollBlue.Position))
      EdRGB.Text = "RGB(" + (STR$(ScrollRed.Position)) + ", " + _
       (STR$(ScrollGreen.Position)) + ", " + _
       (STR$(ScrollBlue.Position)) + ")"
      EdBGR.Text = "&H" + RIGHT$(HEX$(ScrollBlue.Position), 2) + _
       RIGHT$(HEX$(ScrollGreen.Position), 2) + _
       RIGHT$(HEX$(ScrollRed.Position), 2)
     END SUB

     SUB Checked
      SELECT CASE Check.Checked
      CASE True
       ScrollRed.SmallChange = 51
       ScrollGreen.SmallChange = 51
       ScrollBlue.SmallChange = 51
      CASE False
       ScrollRed.SmallChange = 1
       ScrollGreen.SmallChange = 1
       ScrollBlue.SmallChange = 1
      END SELECT
     END SUB
掌柜推荐
 
 
¥477.00 ·
 
 
¥918.00 ·
 
 
¥370.00 ·
 
 
¥271.00 ·
 
 
¥995.00 ·
 
 
¥1,580.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-07-19 06:06:40