Hello
Thought Id add this to new thread instead - it was attached to a colour picker thread... So would be misleading.
// Project: TextureMaker
// Created: 2017-02-22
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "TextureMaker" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
// Road
textureimage = createtexture(1024,100, makecolor(255,255,255) , 0)
texture = createsprite(textureimage)
// Grass
textureimage = createtexture(1024,100, makecolor(0,255,0) , 0)
texture2 = createsprite(textureimage)
// Water
textureimage = createtexture(1024,100, makecolor(0,0,255) , 0)
texture3 = createsprite(textureimage)
// Sky
textureimage = createtexture(1024,100, makecolor(0,100,255) , 1)
texture4 = createsprite(textureimage)
// Fire
textureimage = createtexture(1024,100, makecolor(255,255,0) , 0)
texture5 = createsprite(textureimage)
do
// Sky.
SetSpritePosition( texture4, 0,0 )
// Road
SetSpritePosition( texture, 0, 100)
// Grass
SetSpritePosition( texture2, 0, 200 )
// Water
SetSpritePosition( texture3, 0, 400 )
// Fire
SetSpritePosition( texture5, 0, 500 )
Print( ScreenFPS() )
Sync()
loop
// Function to create a texture
//
// Inputs - Sizex - size of the texture to create - width
// Sizey - size of the texture to create - height
// color - main colour to start with
// upordown - you like a Darker effect =0.... Lighter =1
//
// Returns the image for the resulting texture
//
function createtexture(sizex# as float, sizey# as float, color, upordown as integer)
swap()
drawbox(0,0,sizex#, sizey#, color, color,color,color, 1)
render()
img = getimage(0,0,sizex#, sizey#)
memblockid = CreateMemblockFromImage (img)
imgwidth = GetMemblockInt(memblockid, 0)
imgheight = GetMemblockInt(memblockid, 4)
size=GetMemblockSize(memblockid)
for offset=12 to size-4 step 4
r=GetMemblockByte(memblockid, offset)
g=GetMemblockByte(memblockid, offset+1)
b=GetMemblockByte(memblockid, offset+2)
a=GetMemblockByte(memblockid, offset+3)
strength=random(1,255)
if upordown=0
if strength<150 then strength=150
if strength>255 then strength=255
SetMemblockByte (memblockid, offset, r-strength)
SetMemblockByte (memblockid, offset+1, g-strength)
SetMemblockByte (memblockid, offset+2, b-strength )
SetMemblockByte (memblockid, offset+3, 255)
else
if strength<0 then strength=0
if strength>150 then strength=150
SetMemblockByte (memblockid, offset, r+strength)
SetMemblockByte (memblockid, offset+1, g+strength)
SetMemblockByte (memblockid, offset+2, b+strength )
SetMemblockByte (memblockid, offset+3, 255)
endif
next
deleteimage (img)
img = CreateImageFromMemblock(memblockid)
DeleteMemblock(memblockid)
endfunction img
Enjoy!!!
Damo