DrawAddBorder

Share your advanced PureBasic knowledge/code with the community.
User avatar
gurj
Enthusiast
Enthusiast
Posts: 693
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

DrawAddBorder

Post by gurj »

this:

Code: Select all

;DrawAddBorder http://ataorj.ys168.com
If OpenWindow(0, 0, 0, 900, 200, "DrawAddBorder", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 CanvasGadget(0, 0, 0, 900, 200)
 ;LoadFont(0, "Tahoma", 6,#PB_Font_Bold);经典细圆简Webdings,Wingdings,Symbol
 LoadFont(0, "Webdings", 0,#PB_Font_Bold)
 ;CreateImage(0, 400, 200,32,$ffffffff)
 If StartVectorDrawing(CanvasVectorOutput(0));Image
  
  VectorFont(FontID(0), 55)
  VectorSourceColor(RGBA(220, 50, 50, 250))
  Text$ = "The quick 框是左键按下 jumped over the lazy doc"
  
  For x = 55 To 59:For y= 55 To 59
    MovePathCursor(x,y)
    DrawVectorText(Text$)
   Next:Next
  VectorSourceColor(RGBA(0, 0, 0, 255))
  MovePathCursor(57,57)
  DrawVectorText(Text$)
  StopVectorDrawing()
  ;ImageGadget(2, 0, 0, 900, 200,ImageID(0))
 EndIf
 
 Repeat
  Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
EndIf
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 693
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: DrawAddBorder

Post by gurj »

code2:

Code: Select all

;DrawAddBorder http://ataorj.ys168.com
;http://www.purebasic.fr/english/viewtopic.php?f=12&t=69308
If OpenWindow(0, 0, 0, 900, 200, "DrawAddBorder", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
 ;LoadFont(0, "Webdings", 55,#PB_Font_Bold)
 LoadFont(0, "Tahoma", 55,#PB_Font_Bold)
 CreateImage(0, 900, 200,32,$ffffffff)
 If StartVectorDrawing(ImageVectorOutput(0))
  
  VectorFont(FontID(0), 55)
  VectorSourceColor(RGBA(255, 0, 0, 255))
  Text$ = "The quick 框是左键按下 jumped over the lazy doc"
  
   MovePathCursor(55,55)
   DrawVectorText(Text$)
  For x= 1 To 2
   MovePathCursor(x,0)
   DrawVectorImage(ImageID(0), 255)
  Next
     MovePathCursor(59,55)
   DrawVectorText(Text$)

  For y= 1 To 2
   MovePathCursor(0,y)
   DrawVectorImage(ImageID(0), 255)
  Next
       MovePathCursor(0,1)
   DrawVectorImage(ImageID(0), 255)

  VectorSourceColor(RGBA(0, 0, 0, 255))
  MovePathCursor(57,57)
  DrawVectorText(Text$)
  StopVectorDrawing()
  ImageGadget(2, 0, 0, 900, 200,ImageID(0))
 EndIf
 
 Repeat
  Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
EndIf
and
code3:

Code: Select all

;DrawAddBorder http://ataorj.ys168.com
;http://www.purebasic.fr/english/viewtopic.php?f=12&t=69308
If OpenWindow(0, 0, 0, 900, 200, "DrawAddBorder", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
 ;LoadFont(0, "Webdings", 55,#PB_Font_Bold)
 LoadFont(0, "Tahoma", 55,#PB_Font_Bold)
 CreateImage(0, 900, 200,32,$ffffffff)
 If StartVectorDrawing(ImageVectorOutput(0))
  
  VectorFont(FontID(0), 55)
  VectorSourceColor(RGBA(0, 0, 0, 255))
  Text$ = "The quick 框是左键按下 jumped over the lazy doc"
  
   MovePathCursor(55,55)
   DrawVectorText(Text$)
  For x= 1 To 2
   MovePathCursor(x,0)
   DrawVectorImage(ImageID(0), 255)
  Next
     MovePathCursor(59,55)
   DrawVectorText(Text$)

  For y= 1 To 2
   MovePathCursor(0,y)
   DrawVectorImage(ImageID(0), 255)
  Next
       MovePathCursor(0,1)
   DrawVectorImage(ImageID(0), 255)

  VectorSourceColor(RGBA(255, 0, 0, 255))
  MovePathCursor(57,57)
  DrawVectorText(Text$)
  StopVectorDrawing()
  ImageGadget(2, 0, 0, 900, 200,ImageID(0))
 EndIf
 
 Repeat
  Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
EndIf
my pb for chinese:
http://ataorj.ys168.com
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: DrawAddBorder

Post by walbus »

Looking nice, good idea
User avatar
gurj
Enthusiast
Enthusiast
Posts: 693
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: DrawAddBorder

Post by gurj »

hi,@Albus:
code1,2,3 all need more clock time,
and code2 color will is not mere, on my x86 winxp

now, i use code4, although border likely has void, but need lesser clock time.
code4 from code1
code4:

Code: Select all

;DrawAddBorder http://ataorj.ys168.com
;http://www.purebasic.fr/english/viewtopic.php?f=12&t=69308
If OpenWindow(0, 0, 0, 900, 200, "DrawAddBorder", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 CanvasGadget(0, 0, 0, 900, 200)
 LoadFont(0, "Tahoma", 6,#PB_Font_Bold)
 ;LoadFont(0, "Webdings", 0,#PB_Font_Bold)
 ;CreateImage(0, 400, 200,32,$ffffffff)
 If StartVectorDrawing(CanvasVectorOutput(0));Image
  ResetPath()
  VectorSourceColor($ff000000)
  AddPathBox(0, 0, 900, 200)
  FillPath()
  
  VectorFont(FontID(0), 55)
  VectorSourceColor(RGBA(220, 220, 220, 255))
  Text$ = "The quick 框是左键按下 jumped over the lazy doc"
  
  For x = 55 To 59 Step 2:For y= 55 To 59 Step 2
    If x<>57 Or y<>57
     MovePathCursor(x,y)
    DrawVectorText(Text$):EndIf
  Next:Next
  VectorSourceColor(RGBA(0, 0, 0, 255))
  MovePathCursor(57,57)
  DrawVectorText(Text$)
  StopVectorDrawing()
  ;ImageGadget(2, 0, 0, 900, 200,ImageID(0))
 EndIf
 
 Repeat
  Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
EndIf
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 693
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: DrawAddBorder

Post by gurj »

use CustomDashPath() for border

Code: Select all

;use CustomDashPath() for border
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 CanvasGadget(0, 0, 0, 400, 200)
 LoadFont(0, "Times New Roman", 20, #PB_Font_Bold)
 
 If StartVectorDrawing(CanvasVectorOutput(0))
  VectorFont(FontID(0), 150)
  
  MovePathCursor(50, 25)
  AddPathText("Text")
  
  VectorSourceColor(RGBA(255, 0, 0, 255))
  DashPath(9999, 1)
  MovePathCursor(50, 25)
  AddPathText("Text")
  
  VectorSourceColor(RGBA(255,250, 0, 255))
  Dim dashes.d(1)
  dashes(0) = 99999
  dashes(1) = 0
  CustomDashPath(5, dashes())
  
  VectorSourceColor(RGBA(0, 0, 0, 255))
  MovePathCursor(50, 25)
  AddPathText("Text")
  FillPath()
  
  StopVectorDrawing()
 EndIf
 
 Repeat
  Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
EndIf

my pb for chinese:
http://ataorj.ys168.com
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: DrawAddBorder

Post by VB6_to_PBx »

gurj ,

Thank you very much for this Code !
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: DrawAddBorder

Post by walbus »

Try this, it looks very cool !

Code: Select all

XIncludeFile("./BucketFill_advanced.pbi") ; Download : "http://www.nachtoptik.de/ablage/BucketFill_advanced.zip"

;use CustomDashPath() for border
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 CanvasGadget(0, 0, 0, 400, 200)
 LoadFont(0, "Times New Roman", 20, #PB_Font_Bold)
 
 If StartVectorDrawing(CanvasVectorOutput(0))
  VectorFont(FontID(0), 150)
  
  MovePathCursor(50, 25)
  AddPathText("Text")
  
  VectorSourceColor($FF|$FF000000)
  DashPath(1e3, 1)
  MovePathCursor(50, 25)
  AddPathText("Text")
  
  VectorSourceColor($FFFF|$FF000000)
  Dim dashes.d(1)
  dashes(0) = 1e3
  CustomDashPath(5, dashes())
  
  VectorSourceColor($FF000000)
  MovePathCursor(50, 25)
  AddPathText("Text")
  FillPath()
  
  StopVectorDrawing()
EndIf

UseJPEGImageDecoder() : UsePNGImageDecoder()
texture_1_ID=LoadImage(#PB_Any, #PB_Compiler_Home+"Examples\3D\Data\Textures\RustySteel.jpg")
texture_2_ID=LoadImage(#PB_Any, #PB_Compiler_Home+"Examples\3D\Data\Textures\terrain.png")
texture_3_ID=LoadImage(#PB_Any, #PB_Compiler_Home+"Examples\3D\Data\Textures\terrain_detail.jpg")
SetColor_BF(#Black) : ErrorCheck_BF(BF(-2, 0, texture_1_ID, -1, -1))
SetColor_BF(#Red) : ErrorCheck_BF(BF(-2, 0, texture_2_ID, -1, -1))
SetColorDistanceFill_BF(30) : SetColor_BF(#Yellow) : ErrorCheck_BF(BF(-2, 0, texture_3_ID, -1, -1))

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
User avatar
gurj
Enthusiast
Enthusiast
Posts: 693
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: DrawAddBorder

Post by gurj »

thanks!
my pb for chinese:
http://ataorj.ys168.com
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: DrawAddBorder

Post by RSBasic »

@gurj
Very nice, thanks for sharing. Image
Image
Image
User avatar
gurj
Enthusiast
Enthusiast
Posts: 693
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: DrawAddBorder

Post by gurj »

here, best way is use StrokePath(5) To replace CustomDashPath(5, dashes())
my pb for chinese:
http://ataorj.ys168.com
Post Reply