Color Picker
Posted: Sun Jul 22, 2018 12:15 pm
I wrote a little color picker
By the way, is it possible to vary the BitmapCells RandomSeed over time?
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" MouseVisible="255" RenderOrder="1" FileVersion="2">
<OnLoaded>
<ZExternalLibrary ModuleName="opengl32">
<BeforeInitExp>
<![CDATA[//
if(ANDROID) this.ModuleName = "libGLESv1_CM.so";
else this.ModuleName = "opengl32";]]>
</BeforeInitExp>
<Source>
<![CDATA[//
void glReadPixels(int x, int y, int width, int height, int format, int type, xptr data){}
//]]>
</Source>
</ZExternalLibrary>
<SpawnModel Model="BackgroundModel"/>
<SpawnModel Model="CubeModel"/>
</OnLoaded>
<Content>
<Group Comment="Cube">
<Children>
<Material Name="CubeMaterial" Shading="1" Color="0 0 0 1"/>
<Model Name="CubeModel">
<OnSpawn>
<ZExpression>
<Expression>
<![CDATA[//
CurrentModel.RotationVelocity = .1;]]>
</Expression>
</ZExpression>
</OnSpawn>
<OnUpdate>
<ZExpression>
<Expression>
<![CDATA[//
int x = (1+App.MousePosition.X)*App.ScreenWidth*0.5;
int y = (1+App.MousePosition.Y)*App.ScreenHeight*0.5;
glReadPixels(x, y, 1, 1, 0x80E0, 0x1401, ColorPickerArray);
CubeMaterial.Color.R = ColorPickerArray[2]/256.0;
CubeMaterial.Color.G = ColorPickerArray[1]/256.0;
CubeMaterial.Color.B = ColorPickerArray[0]/256.0;]]>
</Expression>
</ZExpression>
</OnUpdate>
<OnRender>
<UseMaterial Material="CubeMaterial"/>
<RenderMesh Mesh="CubeMesh"/>
</OnRender>
</Model>
<Mesh Name="CubeMesh">
<Producers>
<MeshBox/>
</Producers>
</Mesh>
</Children>
</Group>
<Group Comment="Background">
<Children>
<Model Name="BackgroundModel">
<OnRender>
<UseMaterial Material="ColorsMaterial"/>
<RenderMesh Mesh="BackgroundMesh"/>
</OnRender>
</Model>
<Mesh Name="BackgroundMesh">
<Producers>
<MeshBox Scale="8 4.5 1" Grid2DOnly="255"/>
</Producers>
</Mesh>
<Bitmap Name="ColorsBitmap" Width="128" Height="128">
<Producers>
<BitmapCells PointsPlacement="1" UsedMetrics="2" RandomSeed="3" BorderPixels="0"/>
</Producers>
</Bitmap>
<Material Name="ColorsMaterial" Shading="1" Light="0" ZBuffer="0">
<Textures>
<MaterialTexture Texture="ColorsBitmap" TextureScale="2 2 1" TextureWrapMode="1" TexCoords="1"/>
</Textures>
</Material>
</Children>
</Group>
<Array Name="ColorPickerArray" Type="4" SizeDim1="3"/>
</Content>
</ZApplication>