PureBasic Forum
http://forums.purebasic.com/english/

some gfx code
http://forums.purebasic.com/english/viewtopic.php?f=10&t=34143
Page 1 of 1

Author:  xperience2003 [ Sun Sep 14, 2008 11:26 am ]
Post subject:  some gfx code

hi,

some gfx things with pb 2.9 (pb v4 will crash everytime)

smal intro test: logo, scrolltext, static text
Image

Code:
;a simple textscreen by using a
;8x10 pixel bitmap font YESS!
;init the stuff
WbStartup()
opengraphicslibrary_(0)
InitBitMap(2)
InitScreen(0)
InitPalette(0)
InitPicture(0)
InitRainbow(0)
*TagList = InitTagList(100)
;give more cpu power
ProgramPriority(20)

;we load the bitmapfont as picture
LoadPicture(0,"sys:agagame/gfx/font8x10x1.iff")
AllocateBitMap (0,319, 11, 1)
PictureToBitMap(0, BitMapID())

;we load the logo
LoadPicture(0,"sys:agagame/gfx/dawn1.iff")
AllocateBitMap(1,340,256,8)
PictureToBitMap(0,BitMapID())

;we open a costumscreen
UseBitMap(1)
ResetTagList(#SA_Type, #CUSTOMSCREEN | #CUSTOMBITMAP)
      AddTag(#SA_Quiet,1)
      AddTag(#SA_BitMap, BitMapID())
      AddTag(#SA_Top,-10)
      AddTag(#SA_Draggable, 0)
OpenScreen(0,320,256,8, *TagList)

;check up palette
GetPicturePalette (0, PictureID())
;
DisplayPalette(0, ScreenID())
;PalRgb(20,200,200,200)
Rgb(ScreenID(),1,250,250,250)
;some colors more ^^
CreateRainbow(0,255)
 RainbowColor(0,19,255,255,255)
 for i=20 To 198
   RainbowColor(0,i,10+i/2,0,5+i/4)
 next
 RainbowColor(0,199,255,255,255)
 for i=0 To 20
   RainbowColor(0,i+200,i,60,i/2)
 next
 RainbowColor(0,221,255,255,255)
 RainbowColor(0,222,0,0,0) ;dont forget To clear the last line
RainbowEnd(0)
ShowRainbow(0,ScreenID())

Procedure textline(txt.s,x.w,y.w)
  UseBitMap(1)                        ;displaybitmap
  DrawingOutput(bitmapRastPort())     ;draw To this
  UseBitMap(0)                        ;fontbitmap
  For i=1 To Len(txt.s)
  let=asc(Mid(txt.s,i,1));-64
  tx=i*8
  If let>64 And let<92 ;a-z = 1 To 26 no space
   let-64
   CopyBitMap(BitMapID(),let*8,0,tx+x,y,8,10) ;catch the letterz
  EndIf
  If let>47 And let<59 ;1-9 = 27 To 36
   let-21
   CopyBitMap(BitMapID(),let*8,0,tx+x,y,8,10) ;catch the letterz
  EndIf
  Next
EndProcedure

textline("SMALL AMIGA INTRO",90,140)
textline("WITH PUREBASIC",100,160)
textline("ABCDEFGH XYZ 1234",90,180)

scrolltext.s=" SIMPLE SCROLLTEXT DONE WITH SCROLLRASTER"
scrolltextlen=Len(scrolltext)
scrolltextpos=1   
 Repeat
    VWait() ;makes it smooooth
    ShowBitMap(1,ScreenID(),0,0)
    ;update a simple scroller
    scrolltimer+1       ;timer+1 (means 1 pixel more)
    If scrolltimer>8   ;If over 10 pixels (lettersize)
       scrolltimer=0
       scrolltextpos+1
       If scrolltextpos>scrolltextlen
       scrolltextpos=1
       EndIf
        UseBitMap(1)
        DrawingOutput(bitmapRastPort())     ;draw To this
        UseBitMap(0)                        ;fontbitmap
        let=asc(Mid(scrolltext.s,scrolltextpos,1))-64
        If let>0
        CopyBitMap(BitMapID(),let*8,0,330,205,8,10)
        EndIf
    EndIf
    ;scroll continously
    UseBitMap(1)
    scrollraster_(BitMapRastPort(),1,0,1,200,339,220)
    mb.w=mousebuttons()
Until mb.w=2
End



logo and files

Author:  Peace [ Tue Oct 14, 2008 2:59 pm ]
Post subject:  Missing EXE

Hi Xperience (sorry didn't saw your post before)

yes, can't run your examples in PB 4.0 (real Amiga & WinUAE)!
so it would be nice if you include a compiled one in the download
file to see how it works...

Greets Peace

Author:  endo [ Mon Nov 03, 2008 12:37 am ]
Post subject: 

it looks nice. did you upload the compiled exe somewhere?

Author:  xperience2003 [ Sun Aug 23, 2009 9:35 pm ]
Post subject:  some gfxcode more ^^

How to include Bitmaps?! :

Code:
; ***********************************************
;      include a 5bpl image in a bitmap
;         by xp^trs  ...amiga rulezZ
; ***********************************************

InitMemoryBank(0)  ;we need only To use the memorycommands^^
InitBitMap(0)      ; We will need 1 bitmap
InitScreen(0)      ; ... and 1 screen
InitPalette(0)

AllocateBitMap(0,320,256,5)  ; Create our bitmaps
OpenScreen(0, 320, 256, 5, 0) ;

LoadPalette(0,"data/dawn1.pal")
DisplayPalette(0,ScreenID())

;bitmappaint
 UseBitMap(0)
 *bmappointer=BitMapID()
 *plane1ptr.l=PeekL(*bmappointer+8)
 *plane2ptr.l=PeekL(*bmappointer+12)
 *plane3ptr.l=PeekL(*bmappointer+16)
 *plane4ptr.l=PeekL(*bmappointer+20)
 *plane5ptr.l=PeekL(*bmappointer+24)
 *imageptr.l=?lettera

; raw ilbm - mode: line1 bpl1 bpl2..line2 bpl1 bpl2...
pointer=0
For lines=1 To 1280 ;256 lines* 5 bpl
 CopyMemory(*imageptr +pointer         ,*plane1ptr+pointer ,40)
 CopyMemory(*imageptr +pointer+10240   ,*plane2ptr+pointer ,40)
 CopyMemory(*imageptr +pointer+20480   ,*plane3ptr+pointer ,40)
 CopyMemory(*imageptr +pointer+30720   ,*plane4ptr+pointer ,40)
 CopyMemory(*imageptr +pointer+40960   ,*plane5ptr+pointer ,40)
 pointer+40
Next


  Repeat
    VWait()
    ShowBitMap(0,ScreenID(),0,0)
   
    mb.w = mousebuttons()
  Until mb.w = 1

End      ; Finish the program and free all stuffs.

lettera:
IncludeBinary "data/dawn1.ilbm"




more examples, executables and codes here:
download 50kb

have fun =)

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/