Author Topic: gd::Tiled  (Read 20917 times)

RONB

  • Guest
gd::Tiled
« on: September 19, 2013, 08:48:48 AM »
I came across how to use the tile feature using the gd extension.
This works with
Image = gd::Create(x,y)
or
Image = gd::CreateFromPng("filename")

so there are a lot of uses. Tested under windows-xp and Linux-Debian
 
------from sb help example
gd::SetTile image,brush
' caused stack overflow on a fine NT? Should be some poor implementation
'gd::FillToBorder image,325,191,black,gd::Tiled

------this works windows and Linux
gd::FilledRectangle IMAGE,sx,sy,ex,ey,gd::Tiled

------this also works
gd::FilledPoly IMAGE,x,y,gd::Tiled

--------sample code
iimport gd.bas

ta = gd::Create(10,10)
'ta=gd::CreateFromPng("ta.png")
white = gd::Color(ta,255,255,255)
gd::SetTransparentColor ta,white
black = gd::Color(ta,0,0,0)
gd::Line ta,5,5,40,40,black
gd::Line ta,5,8,0,8,black
gd::SavePng ta,"ta.png"

tb = gd::Create(10,10)
'tb=gd::CreateFromPng("tb.png")
white = gd::Color(tb,255,255,255)
black = gd::Color(tb,0,0,0)
gd::Line tb,0,0,10,10,black
gd::Line tb,0,10,10,0,black
gd::SavePng tb,"tb.png"

tc=gd::Create(20,20)
'tc=gd::CreateFromPng("tc.png")
white = gd::Color(tc,255,255,255)
black = gd::Color(tc,0,0,0)
gd::Line tc,0,0,20,20,black
gd::Line tc,0,20,20,0,black
gd::Rectangle tc,5,5,15,15,black
gd::SavePng tc,"tc.png"

IMAGE = gd::Create(400,400)
white = gd::Color(IMAGE,255,255,255)
gd::SetTransparentColor IMAGE,white
black = gd::Color(IMAGE,0,0,0)
red =  gd::Color(IMAGE,255,0,0)
blue =  gd::Color(IMAGE,0,0,255)
green = gd::Color(IMAGE,0,255,0)

gd::SetTile IMAGE,ta
gd::FilledRectangle IMAGE,10,10,100,100,gd::Tiled

gd::SetBrush image,tc
for vb=10 to 300 step 20
gd::Line Image,vb,350,vb,350,gd::Brushed
next vb

x[0]=100
x[1]=200
x[2]=300
x[3]=100
y[0]=100
y[1]=300
y[2]=100
y[3]=100

gd::SetTile IMAGE,tb
gd::FilledPoly IMAGE,x,y,gd::Tiled

gd::SavePng IMAGE,"tiled.png"
gd::Destroy IMAGE
end
« Last Edit: September 20, 2013, 06:34:46 AM by RONB »

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: gd::Tiled
« Reply #1 on: September 19, 2013, 10:42:04 AM »
Great stuff Ron!

I haven't played with the GD extension module much and I'm glad to see someone take advantage of it.