TGC Codebase Backup



Colour selection tool by Anonymous Coder

30th Mar 2007 14:50
Summary

This is a handy tool to help you select a colour from the many thousands!



Description

This tool helps you select a colour from the many thousands by allowing you to use your mouse to find the colour and the scroll wheel to add more of either red, blue or green. It also allows you to clikc the mouse and select the colour so you dont lose it colour. It outputs the true colour value as well as the rgb colour value. Enjoy!!

version 2 of this tool will include code to input the rgb value of a colour and then view colours near it plus many other features!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    sync on
sync rate 0
disable escapekey

set window on
set window layout 1,1,1
set window title "Colour selector by Ashley Hyde"
set window size 800,600
set window position 100,100

set display mode 800,600,16

movez = 0

mainmenu:
cls
sync
ink rgb (255,255,255),0
print "press 'r' to control the amount of red in the green - blue spectrum."
print
print "press 'g' to control the amount of red in the blue - red spectrum."
print
print "press 'b' to control the amount of red in the red - green spectrum."
sync
do
	if keystate(19) = 1
		cls
		sync
		goto red
	endif
	if keystate(34) = 1
		cls
		sync
		goto green
	endif
	if keystate(48) = 1
		cls
		sync
		goto blue
	endif
loop

red:
movez = 0
do
	box 0,0,255,255,rgb(movez,0,0),rgb(movez,255,0),rgb(movez,0,255),rgb(movez,255,255)
	mousemove = mousemovez()
	if mousemove > 0 and movez < 255
		inc movez
	endif
	if mousemove < 0 and movez > 0
		dec movez
	endif
	if mousex() > 0 and mousex() < 255 and mousey() > 0 and mousey() < 255
		ink point(mousex(),mousey()),0
		box 0,300,100,400
		ink rgb (255,255,255),0
		set cursor 300,300
		print "The colour is: ",point(mousex(),mousey())
		set cursor 300,320
		Print "The red value is: ",rgbr(point(mousex(),mousey()))
		set cursor 300,340
		print "The green value is: ",rgbg(point(mousex(),mousey()))
		set cursor 300,360
		print "The blue value is: ",rgbb(point(mousex(),mousey()))
	endif
	if keystate(1) = 1
		goto mainmenu
	endif
	if mouseclick() = 1
		x = 0
		while x = 0
			if mouseclick() = 2
				x = 1
			endif
		endwhile
	endif
	ink rgb (255,255,255),0
	set cursor 300,20
	print "To return to the main menu, press the escape key"
	set cursor 300,60
	print "To select a colour, click the left mouse button"
	set cursor 300,100
	print "To deselect the colour, click the right mouse button"
	set cursor 300,140
	print "To add more red to the square, scroll the mouse scroll wheel"
	sync
	cls
loop

green:
movez = 0
do
	box 0,0,255,255,rgb(0,movez,0),rgb(255,movez,0),rgb(0,movez,255),rgb(255,movez,255)
	mousemove = mousemovez()
	if mousemove > 0 and movez < 255
		inc movez
	endif
	if mousemove < 0 and movez > 0
		dec movez
	endif
	if mousex() > 0 and mousex() < 255 and mousey() > 0 and mousey() < 255
		ink point(mousex(),mousey()),0
		box 0,300,100,400
		ink rgb (255,255,255),0
		set cursor 300,300
		print "The colour is: ",point(mousex(),mousey())
		set cursor 300,320
		Print "The red value is: ",rgbr(point(mousex(),mousey()))
		set cursor 300,340
		print "The green value is: ",rgbg(point(mousex(),mousey()))
		set cursor 300,360
		print "The blue value is: ",rgbb(point(mousex(),mousey()))
	endif
	if keystate(1) = 1
		goto mainmenu
	endif
	if mouseclick() = 1
		x = 0
		while x = 0
			if mouseclick() = 2
				x = 1
			endif
		endwhile
	endif
	ink rgb (255,255,255),0
	set cursor 300,20
	print "To return to the main menu, press the escape key"
	set cursor 300,60
	print "To select a colour, click the left mouse button"
	set cursor 300,100
	print "To deselect the colour, click the right mouse button"
	set cursor 300,140
	print "To add more green to the square, scroll the mouse scroll wheel"
	sync
	cls
loop

blue:
movez = 0
do
	box 0,0,255,255,rgb(0,0,movez),rgb(0,255,movez),rgb(255,0,movez),rgb(255,255,movez)
	mousemove = mousemovez()
	if mousemove > 0 and movez < 255
		inc movez
	endif
	if mousemove < 0 and movez > 0
		dec movez
	endif
	if mousex() > 0 and mousex() < 255 and mousey() > 0 and mousey() < 255
		ink point(mousex(),mousey()),0
		box 0,300,100,400
		ink rgb (255,255,255),0
		set cursor 300,300
		print "The colour is: ",point(mousex(),mousey())
		set cursor 300,320
		Print "The red value is: ",rgbr(point(mousex(),mousey()))
		set cursor 300,340
		print "The green value is: ",rgbg(point(mousex(),mousey()))
		set cursor 300,360
		print "The blue value is: ",rgbb(point(mousex(),mousey()))
	endif
	if keystate(1) = 1
		goto mainmenu
	endif
	if mouseclick() = 1
		x = 0
		while x = 0
			if mouseclick() = 2
				x = 1
			endif
		endwhile
	endif
	ink rgb (255,255,255),0
	set cursor 300,20
	print "To return to the main menu, press the escape key"
	set cursor 300,60
	print "To select a colour, click the left mouse button"
	set cursor 300,100
	print "To deselect the colour, click the right mouse button"
	set cursor 300,140
	print "To add more blue to the square, scroll the mouse scroll wheel"
	sync
	cls
loop