Platforms to show: All Mac Windows Linux Cross-Platform

/Picture/Picture with Color Palettes/Color palettes
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /Picture/Picture with Color Palettes/Color palettes
This example is the version from Sat, 13th May 2005.
Notes: Last modified: Sat, 13th May 2005
Class Window1
Inherits Window
// Controls
ControlInstance
Sub Action() Handles Event
run new PaletteMBS
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
run NewGrayPaletteMBS
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
run NewWebPaletteMBS
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
run NewSystemPaletteMBS
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub MouseMove(X As Integer, Y As Integer) Handles Event
dim n as integer

if pal<>nil then
n=x\16+(y\16)*16

thiscolor.text=hexc(pal.col(n))
end if
End Sub
Sub Paint(g As Graphics) Handles Event

End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
run NewRedPaletteMBS
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
run NewGreenPaletteMBS
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
run NewBluePaletteMBS
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
run NewWindowsPaletteMBS
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
run NewPalmPaletteMBS
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub Action() Handles Event
dim p as picture
dim pal as PaletteMBS

p=newpicture(100,100,8)
pal=p.PaletteMBS

run pal
End Sub
End ControlInstance

// Properties
Protected Dim pal as paletteMBS

// Event implementations
Sub Open()

End Sub

// Methods
Sub run(p as paletteMBS)
dim pic as picture
dim g as graphics
dim i,l,x,y as integer
dim c as color

list.deleteAllRows
if p=nil then
pic=nil
Colorcount.text=""
else
pic=newpicture(256,256,32)
if pic<>nil then
g=pic.graphics
if g=nil then
pic=nil
else
i=0
for x=0 to 15
for y=0 to 15
c=p.col(i)
g.foreColor=c
g.fillrect y*16,x*16,16,16

list.addrow str(i)
l=list.lastIndex
list.cell(l,1)=strc(c)
list.cell(l,2)=hex(c.red)+" "+hex(c.green)+" "+hex(c.blue)
i=i+1
next
next
end if
end if
Colorcount.text=str(p.countColors)+" colors in palette."
end if
can.backdrop=pic
pal=p
End Sub
Function strc(c as color) As string
return str(c.red)+" "+str(c.green)+" "+str(c.blue)
End Function
Function hexc(c as color) As string
return right("00"+hex(c.red),2)+" "+right("00"+hex(c.green),2)+" "+right("00"+hex(c.blue),2)
End Function
End Class

Class App
Inherits Application
End Class


See also:




Links
MBS Realbasic Plugins - Nachhilfe in Wassenach