home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 85 / af085a.adf / archives / af85a1.lzx / Dialog_Procedures / Source / PaletteRequester.AMOS / PaletteRequester.amosSourceCode
Encoding:
AMOS Source Code  |  1978-07-26  |  7.4 KB  |  335 lines

  1. '
  2. Procedure _PALETTEREQUESTER[S]
  3.    '
  4.    Shared _DIALOGBUTTON$,_BACK,_SHADOW,_LIGHT,_COLOUR,_TEXT,_FONTNAME$,_FONTSIZE
  5.    '
  6.    _TEMP1$=_DIALOGBUTTON$
  7.    _TEMP2$=_FONTNAME$
  8.    _TEMP3=_FONTSIZE
  9.    _DIALOGBUTTON$=""
  10.    '
  11.    SY=70
  12.    _OPENDIALOGSCREEN[7,80,SY]
  13.    '
  14.    _SETFONT["Topaz",8]
  15.    '
  16.    Screen S
  17.    SC=Screen Colour
  18.    If SC>64
  19.       SC=16
  20.       FF=16
  21.    Else 
  22.       FF=SC
  23.    End If 
  24.    C=1
  25.    '
  26.    Screen Open 6,320,20,SC,Lowres
  27.    Screen Display 6,,SY+81,,
  28.    Curs Off 
  29.    Flash Off 
  30.    Cls 0
  31.    Get Palette S
  32.    '
  33.    STP=320/SC
  34.    LOP=0
  35.    While LOP<SC+1
  36.       Ink LOP
  37.       Bar LOP*STP,2 To LOP*STP+STP,20
  38.       Inc LOP
  39.    Wend 
  40.    Gosub _LINE
  41.    Screen 7
  42.    '
  43.    _DRAW3DBOX[0,0,639,79,"",,0,3]
  44.    _DRAWTITLEBAR["Palette Requester V1.1"]
  45.    _ADDBUTTON[0,0,44,10,"OK",11]
  46.    '
  47.    _DRAW3DBOX[10,16,38,34,"R",1,_TEXT,_BACK]
  48.    _DRAW3DBOX[10,36,38,54,"G",1,_TEXT,_BACK]
  49.    _DRAW3DBOX[10,56,38,74,"B",1,_TEXT,_BACK]
  50.    '
  51.    _HORIZONTALSLIDER[42,16,418,18,16,1,""]
  52.    _HORIZONTALSLIDER[42,36,418,18,16,1,""]
  53.    _HORIZONTALSLIDER[42,56,418,18,16,1,""]
  54.    '
  55.    _ADDBUTTON[462,19,476,31,"(S)LAR",1]
  56.    _ADDBUTTON[462,39,476,51,"(S)LAR",2]
  57.    _ADDBUTTON[462,59,476,71,"(S)LAR",3]
  58.    _ADDBUTTON[478,19,492,31,"(S)RAR",4]
  59.    _ADDBUTTON[478,39,492,51,"(S)RAR",5]
  60.    _ADDBUTTON[478,59,492,71,"(S)RAR",6]
  61.    '
  62.    _DRAW3DBOX[495,16,521,34,"",0,,_COLOUR]
  63.    _DRAW3DBOX[495,36,521,54,"",0,,_COLOUR]
  64.    _DRAW3DBOX[495,56,521,74,"",0,,_COLOUR]
  65.    _DRAW3DBOX[497,17,519,33,"",1,,_BACK]
  66.    _DRAW3DBOX[497,37,519,53,"",1,,_BACK]
  67.    _DRAW3DBOX[497,57,519,73,"",1,,_BACK]
  68.    '
  69.    _ADDBUTTON[525,16,629,30,"Spread",7]
  70.    _ADDBUTTON[525,31,629,45,"Swap",8]
  71.    _ADDBUTTON[525,46,629,60,"Copy",9]
  72.    _ADDBUTTON[525,61,629,75,"Reset",10]
  73.    '
  74.    Gosub _GET
  75.    Gosub _LINE
  76.    Gosub _R_SLIDER
  77.    Gosub _G_SLIDER
  78.    Gosub _B_SLIDER
  79.    '
  80.    Do 
  81.       '
  82.       _CHECKBUTTONS
  83.       ZN=Param
  84.       '
  85.       _CHECKZONE[46,0,639,10,0]
  86.       If Param
  87.          YY=Y Screen(Y Mouse)
  88.          While Mouse Key
  89.             If Y Mouse>42 and Y Mouse<200
  90.                SY=Y Mouse
  91.                Screen Display 7,,SY-YY,,
  92.                Screen Display 6,,SY-YY+81,,
  93.             End If 
  94.          Wend 
  95.       End If 
  96.       '
  97.       If ZN=11
  98.          Goto FIN
  99.       End If 
  100.       '
  101.       If ZN=1 and R>0
  102.          Dec R
  103.          Gosub _R_SLIDER
  104.          Gosub _CHANGE
  105.       End If 
  106.       '
  107.       If ZN=4 and R<15
  108.          Inc R
  109.          Gosub _R_SLIDER
  110.          Gosub _CHANGE
  111.       End If 
  112.       '
  113.       If ZN=2 and G>0
  114.          Dec G
  115.          Gosub _G_SLIDER
  116.          Gosub _CHANGE
  117.       End If 
  118.       '
  119.       If ZN=5 and G<15
  120.          Inc G
  121.          Gosub _G_SLIDER
  122.          Gosub _CHANGE
  123.       End If 
  124.       '
  125.       If ZN=3 and B>0
  126.          Dec B
  127.          Gosub _B_SLIDER
  128.          Gosub _CHANGE
  129.       End If 
  130.       '
  131.       If ZN=6 and B<15
  132.          Inc B
  133.          Gosub _B_SLIDER
  134.          Gosub _CHANGE
  135.       End If 
  136.       '
  137.       If ZN=7
  138.          '
  139.          _DRAWTITLEBAR["Select Colour To Spread To (ESC Exits)"]
  140.          CC=C
  141.          Screen 6
  142.          Repeat 
  143.             If Mouse Key
  144.                CC=Point(X Screen(6,X Mouse),Y Screen(6,Y Mouse))
  145.             End If 
  146.          Until Inkey$=Chr$(27) or(CC<>C and CC<FF)
  147.          '
  148.          If CC<>C
  149.             FIRST=C
  150.             LAST=CC
  151.             Screen 6
  152.             If FIRST>LAST
  153.                Swap FIRST,LAST
  154.             End If 
  155.             CF=Colour(FIRST)
  156.             CL=Colour(LAST)
  157.             NCOLS#=LAST-FIRST
  158.             '
  159.             DR#=(((CL/256) mod 16)-((CF/256) mod 16))/NCOLS#
  160.             DG#=(((CL/16) mod 16)-((CF/16) mod 16))/NCOLS#
  161.             DB#=((CL mod 16)-(CF mod 16))/NCOLS#
  162.             '
  163.             N=0
  164.             While N<(LAST-FIRST)+1
  165.                R=((CF/256) mod 16)+DR#*N
  166.                G=((CF/16) mod 16)+DG#*N
  167.                B=(CF mod 16)+DB#*N
  168.                Colour FIRST+N,R*256+G*16+B
  169.                Inc N
  170.             Wend 
  171.          End If 
  172.          '
  173.          Screen 7
  174.          _DRAWTITLEBAR["Palette Requester V1.1"]
  175.          _ADDBUTTON[0,0,44,10,"OK",0]
  176.          Gosub _GET
  177.          Gosub _R_SLIDER
  178.          Gosub _G_SLIDER
  179.          Gosub _B_SLIDER
  180.          '
  181.       End If 
  182.       '
  183.       If ZN=8
  184.          '
  185.          _DRAWTITLEBAR["Select Colour To Swap With (ESC Exits)"]
  186.          CC=C
  187.          Screen 6
  188.          Repeat 
  189.             If Mouse Key
  190.                CC=Point(X Screen(6,X Mouse),Y Screen(6,Y Mouse))
  191.             End If 
  192.          Until Inkey$=Chr$(27) or(CC<>C and CC<FF)
  193.          '
  194.          TMP=Colour(C)
  195.          Colour C,Colour(CC)
  196.          Colour CC,TMP
  197.          Screen 7
  198.          _DRAWTITLEBAR["Palette Requester V1.1"]
  199.          _ADDBUTTON[0,0,44,10,"OK",0]
  200.          Gosub _GET
  201.          Gosub _R_SLIDER
  202.          Gosub _G_SLIDER
  203.          Gosub _B_SLIDER
  204.          '
  205.       End If 
  206.       '
  207.       If ZN=9
  208.          '
  209.          _DRAWTITLEBAR["Select Colour To Copy To (ESC Exits)"]
  210.          CC=C
  211.          Screen 6
  212.          Repeat 
  213.             If Mouse Key
  214.                CC=Point(X Screen(6,X Mouse),Y Screen(6,Y Mouse))
  215.             End If 
  216.          Until Inkey$=Chr$(27) or(CC<>C and CC<FF)
  217.          '
  218.          Colour CC,Colour(C)
  219.          Screen 7
  220.          _DRAWTITLEBAR["Palette Requester V1.1"]
  221.          _ADDBUTTON[0,0,44,10,"OK",0]
  222.          Gosub _GET
  223.          Gosub _R_SLIDER
  224.          Gosub _G_SLIDER
  225.          Gosub _B_SLIDER
  226.          '
  227.       End If 
  228.       '
  229.       If ZN=10
  230.          Screen 6
  231.          Get Palette S
  232.          Screen 7
  233.          Gosub _GET
  234.          Gosub _R_SLIDER
  235.          Gosub _G_SLIDER
  236.          Gosub _B_SLIDER
  237.       End If 
  238.       '
  239.       If Scin(X Mouse,Y Mouse)=6
  240.          Gosub _PICK
  241.       End If 
  242.       '
  243.       _CHECKZONE[42+(R*26),16,42+(R*26)+24,34,0]
  244.       If Param
  245.          While Mouse Key and X Screen(X Mouse)>46 and X Screen(X Mouse)<454
  246.             R=(X Screen(X Mouse)-42)/26
  247.             Gosub _R_SLIDER
  248.             Gosub _CHANGE
  249.          Wend 
  250.       End If 
  251.       '
  252.       _CHECKZONE[42+(G*26),36,42+(G*26)+24,54,0]
  253.       If Param
  254.          While Mouse Key and X Screen(X Mouse)>46 and X Screen(X Mouse)<454
  255.             G=(X Screen(X Mouse)-42)/26
  256.             Gosub _G_SLIDER
  257.             Gosub _CHANGE
  258.          Wend 
  259.       End If 
  260.       '
  261.       _CHECKZONE[42+(B*26),56,42+(B*26)+24,74,0]
  262.       If Param
  263.          While Mouse Key and X Screen(X Mouse)>46 and X Screen(X Mouse)<454
  264.             B=(X Screen(X Mouse)-42)/26
  265.             Gosub _B_SLIDER
  266.             Gosub _CHANGE
  267.          Wend 
  268.       End If 
  269.       '
  270.    Loop 
  271.    '
  272.    FIN:
  273.    Screen S
  274.    Get Palette 6
  275.    Screen Close 7
  276.    Screen Close 6
  277.    _SETFONT[_TEMP2$,_TEMP3]
  278.    _DIALOGBUTTON$=_TEMP1$
  279.    Pop Proc
  280.    '
  281.    _PICK:
  282.    While Scin(X Mouse,Y Mouse)=6
  283.       Screen 6
  284.       If Mouse Key
  285.          C=Point(X Screen(6,X Mouse),Y Screen(6,Y Mouse))
  286.          Gosub _GET
  287.          Gosub _LINE
  288.          Gosub _R_SLIDER
  289.          Gosub _G_SLIDER
  290.          Gosub _B_SLIDER
  291.       End If 
  292.    Wend 
  293.    Screen 7
  294.    Return 
  295.    '
  296.    _LINE:
  297.    Screen 6
  298.    Ink 0
  299.    Draw 0,0 To 319,0
  300.    Ink 1
  301.    Draw C*STP,0 To C*STP+STP,0
  302.    Screen 7
  303.    Return 
  304.    '
  305.    _GET:
  306.    R=Colour(C)/256
  307.    G=Colour(C)/16 mod 16
  308.    B=Colour(C) mod 16
  309.    Return 
  310.    '
  311.    _R_SLIDER:
  312.    _HORIZONTALSLIDER[42,16,418,18,16,R+1,""]
  313.    _DRAW3DBOX[497,17,519,33,Str$(R)-" ",2,_TEXT,_BACK]
  314.    Return 
  315.    '
  316.    _G_SLIDER:
  317.    _HORIZONTALSLIDER[42,36,418,18,16,G+1,""]
  318.    _DRAW3DBOX[496,37,519,53,Str$(G)-" ",2,_TEXT,_BACK]
  319.    Return 
  320.    '
  321.    _B_SLIDER:
  322.    _HORIZONTALSLIDER[42,56,418,18,16,B+1,""]
  323.    _DRAW3DBOX[497,57,519,73,Str$(B)-" ",2,_TEXT,_BACK]
  324.    Return 
  325.    '
  326.    _CHANGE:
  327.    R$=Hex$(R)
  328.    G$=Mid$(Hex$(G),2,1)
  329.    B$=Mid$(Hex$(B),2,1)
  330.    Screen 6
  331.    Colour C,Val(R$+G$+B$)
  332.    Screen 7
  333.    Return 
  334.    '
  335. End Proc