RoundedBox
Posted: Fri Feb 10, 2012 6:11 pm
Just made a simple procedure to create rounded boxes:
Does not look very useful? I just needed it to create icons for a calendar icon and the actual moon phase -> you can see both of them (but only today
) in my wallpaper tool (hold shift to get back your previous wallpaper)
Here's a short snippet demonstrationg how I've created the smooth (transparent) box for the calendar icon...
Code: Select all
Procedure RoundedBox(x,y,w,h,r,color)
Box(x+r,y,w-r-r,h,color)
Box(x,y+r,w,h-r-r,color)
Circle(x+r+1,y+r+1,r,color)
Circle(x+w-r-1,y+r+1,r,color)
Circle(x+r+1,y+h-r-1,r,color)
Circle(x+w-r-1,y+h-r-1,r,color)
EndProcedure

Here's a short snippet demonstrationg how I've created the smooth (transparent) box for the calendar icon...
Code: Select all
#ImageCalendar=1
#Image=200
Procedure RoundedBox(x,y,w,h,r,color)
Box(x+r,y,w-r-r,h,color)
Box(x,y+r,w,h-r-r,color)
Circle(x+r+1,y+r+1,r,color)
Circle(x+w-r-1,y+r+1,r,color)
Circle(x+r+1,y+h-r-1,r,color)
Circle(x+w-r-1,y+h-r-1,r,color)
EndProcedure
Procedure DemoBox(size,border,rand,type=0)
Protected Zeile.s
Protected nx,ny,nc
Protected x,y,w,h
Protected radius
rand=30
radius=100
#NoTransparency=$FF000000
#NormalWhite=$FFFFFFFF
#DarkWhite=$FFE0E0E0
#NormalBlack=$FF000000
#LightBlack=$FF444444
CreateImage(#ImageCalendar,size,size,32|#PB_Image_Transparent)
StartDrawing(ImageOutput(#ImageCalendar))
x=border
y=0
w=size-border<<1
h=size
DrawingMode(#PB_2DDrawing_Gradient|#PB_2DDrawing_AlphaBlend)
GradientColor(0,#LightBlack)
GradientColor(0.75,#NormalBlack)
GradientColor(1,#LightBlack)
LinearGradient(x,y,x+w,y+h)
RoundedBox(border,0,size-border<<1,size,radius,#NoTransparency|#Black)
x=border+rand
y=rand
w=size-(border+rand)<<1
h=size-rand<<1
DrawingMode(#PB_2DDrawing_Gradient|#PB_2DDrawing_AlphaBlend)
ResetGradientColors()
GradientColor(0,#NormalWhite)
GradientColor((2+m)*0.25,#NormalWhite)
GradientColor(1,#DarkWhite)
LinearGradient(x,y,x+w,y+h)
RoundedBox(x,y,w,h,radius-rand,#NoTransparency|#White)
StopDrawing()
EndProcedure
OpenWindow(1,160,200,#Image,#Image,"",#PB_Window_SystemMenu)
SetWindowColor(1,#Blue)
DemoBox(#image*2,20,10)
ResizeImage(1,#image,#image)
ImageGadget(1,0,0,#Image,#Image,ImageID(1))
z=0
Repeat
Select WaitWindowEvent()
Case #WM_CHAR
Select EventwParam()
Case #ESC
End
EndSelect
EndSelect
ForEver