Text Scroller

Blitz3D Forums/Blitz3D Beginners Area/Text Scroller

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Veering off topic, there are some RLE routines to store images in data statments.

http://www.blitzbasic.com/codearcs/codearcs.php?code=973

http://www.blitzbasic.com/codearcs/codearcs.php?code=974


Here's BlackD's image stored as RLE data statements. Example shows rotated images and curved text.
Global sw% = 800
Global sh% = 600
Global cd% = 32 ;<--------------- Color depth

Graphics sw, sh , cd, 2
SetBuffer BackBuffer()

Dim vecs(1) ;vector array (true dimension size in image data)
Dim pal%(1)	;Color palette array (true dimension size in image data)

;========== masking constants for 32 bit color =========
	Global maskRed% = 16711680
	Global maskGrn% = 65280
	Global maskBlu% = 255
	Cls

		Restore dBlitz_data
		;restore image from data to an image buffer
		gfx0 = data2buffer(0)
		DrawBlock (gfx0,0,0)
		
		Restore dBlitz_data
		;rotate the image data 90 degrees - store in image buffer
		gfx90 = data2buffer(90)
		DrawBlock(gfx90, 500,0)
		
		Restore dBlitz_data
		;rotate the image data 180 degrees - store in image buffer
		gfx180 = data2buffer(180)
		DrawBlock(gfx180, 100,500)
		
		Restore dBlitz_data
		;rotate the image data 270 degrees - store in image buffer
		gfx270 = data2buffer(270)
		DrawBlock(gfx270, 0,100)
		
		Restore dBlitz_data
		;wrap the image data around 360 degrees of arc - place on dark red background
		gfxCircle = dat2curv2buf(200, 150.0 ,360.0, 3, 96, 0 ,0)
		DrawBlock(gfxCircle,100,100)
		Flip
		WaitKey()
		End

Function data2buffer%(displayAngle%)
	If displayAngle = 0 Or displayAngle = 90 Or displayAngle = 180 Or displayAngle = 270 Then
		Read imgWidth%
	    Read imgHeight%
		Read numVecs%
		Read palSize%
	    Dim vecs(numVecs)
		Dim pal(palSize-1)
		For i% = 0 To palSize-1
			Read pal(i)
		Next
		ras% = 1
		vCount% = 0
		lineLen% = 0
		While ras <= imgHeight 
			Read vecLen%
			Read idx%
			vecs(vCount) = vecLen
			vecs(vCount+1) = pal(idx)
			lineLen = lineLen + vecLen
			If lineLen = imgWidth Then
				lineLen = 0
				ras = ras + 1
			End If
			vCount = vCount + 2
		Wend
		Select displayAngle
			Case   0
				newWidth%  = imgWidth
				newHeight% = imgHeight
				x% = 0
				y% = 0
			Case  90
				newWidth%  = imgHeight
				newHeight% = imgWidth
			 	x% = newWidth-1
				y% = 0
			Case 180
				newWidth%  = imgWidth
				newHeight% = imgHeight
				x% = imgWidth-1
				y% = imgHeight-1
			Case 270
				newWidth%  = imgHeight
				newHeight% = imgWidth
				x% = 0
				y% = newHeight-1
		End Select
		imgTemp% = CreateImage(newWidth, newHeight)
		SetBuffer ImageBuffer(imgTemp)
        angle2% = displayAngle + 90
		vCount = 0
        For i = 1 To imgHeight
            p# = Cos(angle2)*(i-1)+x
            q# = Sin(angle2)*(i-1)+y
			lineLen = 0
            While lineLen < imgWidth
			    vecLen% = vecs(vCount)
				lineLen = lineLen + vecLen
	            red = (vecs(vCount + 1) And maskRed) Shr 16
     	    	grn = (vecs(vCount + 1) And maskGrn) Shr 8
	            blu =  vecs(vCount + 1) And maskBlu
                Color red,grn,blu
			    r# = Cos(displayAngle)*vecLen+p
			    s# = Sin(displayAngle)*vecLen+q
			    Line p,q,r,s
                vCount = vCount+2
			    p=r
			    q=s
            Wend
        Next
	    SetBuffer BackBuffer()
		Return imgTemp
	Else 
		Return 0
	End If
End Function

Function dat2curv2buf(radius%, startAngle#, arcSegment#, penSize%, bkR%, bkG%, bkB%)
	Read imgWidth%
    Read imgHeight%
	Read numVecs%
	Read palSize%
    Dim vecs(numVecs)
	Dim pal(palSize-1)
	For i% = 0 To palSize-1
		Read pal(i)
	Next
	ras% = 1
	vCount% = 0
	lineLen% = 0
	While ras <= imgHeight 
		Read vecLen%
		Read idx%
		vecs(vCount) = vecLen
		vecs(vCount+1) = pal(idx)
		lineLen = lineLen + vecLen
		If lineLen = imgWidth Then
			lineLen = 0
			ras = ras + 1
		End If
		vCount = vCount + 2
	Wend
	;Create a Blitz image buffer
	diameter% = radius Shl 1
	imgTemp% = CreateImage(diameter%, diameter%)
	SetBuffer ImageBuffer(imgTemp)
	;Fill the background with desired color
	Color bkR, bkG, bkB
	Rect(0,0,diameter, diameter, True)
	;Start drawing the curved image on the image buffer
	If penSize > 1 Then
		penOffset# = penSize Shr 1
	End If
	stepSize# = arcSegment/imgWidth
	vCount = 0
	centerX% = radius
	centerY% = radius
	For i% = 1 To imgHeight
		lineLen = 0
		arc# = startAngle
		While lineLen < imgWidth
			arcLen = vecs(vCount)
			lineLen = lineLen + arcLen
			red = (vecs(vCount + 1) And maskRed) Shr 16
			grn = (vecs(vCount + 1) And maskGrn) Shr 8
			blu =  vecs(vCount + 1) And maskBlu
			Color red, grn, blu
			arcInc# = arcLen*stepSize
			c# = arc#
			While c <= arc+arcInc
				x = Cos(c)*radius+centerX
				y = Sin(c)*radius+centerY
				If penSize > 1 Then
					Rect x-penOffset, y-penOffset, penSize, penSize, True
				Else
					Plot x,y
				End If
				c = c+stepSize
			Wend
			arc = arc+arcInc
			vCount = vCount+2
		Wend
		radius = radius - 1
	Next
	SetBuffer BackBuffer()
	Return imgTemp	
End Function

.dBlitz_data
Data 500,100,3468,2
Data -16777216,-1
Data 500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,500,0,30,0,17,1,294,0,16,1,143,0,23,0,29,1,283,0,26,1,33,0,5,1,101,0,17,0
Data 38,1,275,0,33,1,28,0,8,1,101,0,12,0,45,1,270,0,38,1,21,0,13,1,101,0,7,0,51,1,269,0,18,1,7,0,14,1,20,0,11,1,13,0,6,1,84,0,5,0,23,1,11,0,21,1,267,0,5,1,3,0,9,1,10,0,13,1,19,0,10,1,13,0,8,1,83,0,4,0
Data 19,1,20,0,18,1,274,0,9,1,12,0,11,1,19,0,9,1,13,0,10,1,82,0,4,0,16,1,25,0,17,1,273,0,9,1,13,0,11,1,18,0,9,1,13,0,10,1,82,0,11,0,8,1,28,0,16,1,272,0,9,1,14,0,10,1,18,0,9,1,13,0,10,1,82,0,11,0,8,1,30,0
Data 15,1,271,0,8,1,16,0,10,1,17,0,9,1,13,0,10,1,82,0,11,0,8,1,31,0,14,1,271,0,8,1,17,0,9,1,17,0,9,1,13,0,10,1,82,0,11,0,8,1,32,0,14,1,270,0,8,1,17,0,9,1,17,0,8,1,15,0,8,1,83,0,11,0,8,1,33,0,13,1,270,0
Data 8,1,17,0,9,1,17,0,8,1,16,0,6,1,84,0,11,0,8,1,34,0,13,1,269,0,8,1,18,0,8,1,17,0,8,1,106,0,11,0,8,1,35,0,12,1,269,0,8,1,18,0,8,1,17,0,8,1,106,0,11,0,8,1,35,0,13,1,268,0,8,1,18,0,8,1,17,0,8,1,106,0,11,0
Data 8,1,36,0,12,1,268,0,8,1,18,0,8,1,17,0,8,1,106,0,11,0,8,1,36,0,12,1,268,0,8,1,18,0,8,1,17,0,8,1,106,0,11,0,8,1,37,0,11,1,268,0,8,1,18,0,7,1,18,0,8,1,106,0,11,0,8,1,37,0,12,1,267,0,8,1,17,0,8,1,18,0
Data 8,1,44,0,4,1,58,0,11,0,8,1,38,0,11,1,267,0,8,1,17,0,8,1,18,0,8,1,43,0,5,1,58,0,11,0,8,1,38,0,11,1,267,0,8,1,17,0,7,1,19,0,8,1,42,0,6,1,58,0,11,0,8,1,38,0,11,1,267,0,8,1,16,0,8,1,19,0,8,1,41,0,6,1
Data 59,0,11,0,8,1,38,0,11,1,267,0,8,1,15,0,8,1,20,0,8,1,40,0,7,1,59,0,11,0,8,1,39,0,10,1,17,0,5,1,14,0,6,1,14,0,4,1,12,0,9,1,25,0,11,1,33,0,10,1,26,0,11,1,22,0,4,1,12,0,9,1,23,0,8,1,14,0,8,1,21,0,8,1
Data 19,0,5,1,14,0,8,1,60,0,11,0,8,1,39,0,10,1,15,0,7,1,12,0,8,1,11,0,8,1,8,0,13,1,22,0,16,1,28,0,14,1,21,0,17,1,16,0,8,1,8,0,13,1,22,0,8,1,12,0,9,1,22,0,8,1,17,0,7,1,13,0,9,1,21,0,33,1,6,0,11,0,7,1,40,0
Data 10,1,12,0,10,1,9,0,11,1,9,0,11,1,4,0,17,1,19,0,20,1,24,0,17,1,19,0,20,1,12,0,11,1,4,0,17,1,21,0,8,1,10,0,10,1,23,0,8,1,15,0,9,1,12,0,23,1,7,0,34,1,6,0,11,0,7,1,40,0,10,1,10,0,11,1,10,0,11,1,6,0,15,1
Data 1,0,20,1,17,0,33,1,11,0,19,1,16,0,23,1,8,0,15,1,1,0,20,1,20,0,8,1,6,0,14,1,23,0,8,1,11,0,13,1,11,0,24,1,7,0,34,1,6,0,11,0,7,1,40,0,10,1,10,0,10,1,11,0,11,1,6,0,37,1,14,0,11,1,4,0,20,1,10,0,8,1,3,0
Data 10,1,14,0,25,1,7,0,37,1,19,0,31,1,20,0,8,1,10,0,14,1,10,0,25,1,7,0,34,1,6,0,11,0,7,1,40,0,10,1,10,0,9,1,13,0,9,1,7,0,21,1,3,0,13,1,14,0,9,1,7,0,19,1,9,0,7,1,6,0,9,1,13,0,9,1,5,0,13,1,6,0,21,1,3,0
Data 13,1,19,0,33,1,18,0,8,1,10,0,14,1,10,0,25,1,7,0,33,1,7,0,11,0,7,1,40,0,10,1,10,0,9,1,13,0,9,1,13,0,13,1,7,0,11,1,13,0,9,1,9,0,18,1,8,0,7,1,8,0,9,1,12,0,8,1,8,0,11,1,12,0,13,1,7,0,11,1,19,0,34,1,17,0
Data 8,1,10,0,14,1,10,0,11,1,21,0,32,1,8,0,11,0,7,1,40,0,10,1,10,0,9,1,14,0,8,1,13,0,11,1,10,0,10,1,12,0,9,1,11,0,17,1,7,0,7,1,9,0,9,1,11,0,8,1,10,0,11,1,11,0,11,1,10,0,10,1,19,0,11,1,7,0,17,1,16,0,8,1
Data 15,0,9,1,13,0,8,1,21,0,6,1,17,0,8,1,9,0,11,0,7,1,40,0,9,1,11,0,9,1,14,0,8,1,14,0,9,1,12,0,10,1,11,0,8,1,13,0,16,1,7,0,7,1,9,0,9,1,10,0,8,1,12,0,10,1,12,0,9,1,12,0,10,1,18,0,8,1,14,0,15,1,14,0,8,1
Data 16,0,8,1,13,0,8,1,43,0,8,1,10,0,11,0,7,1,40,0,9,1,11,0,8,1,15,0,8,1,14,0,9,1,12,0,10,1,11,0,8,1,13,0,8,1,14,0,7,1,10,0,9,1,10,0,7,1,14,0,10,1,11,0,9,1,12,0,10,1,18,0,8,1,16,0,13,1,14,0,8,1,16,0,8,1
Data 13,0,8,1,42,0,8,1,11,0,11,0,7,1,40,0,9,1,11,0,8,1,15,0,8,1,15,0,8,1,13,0,9,1,10,0,8,1,14,0,8,1,14,0,7,1,9,0,10,1,9,0,8,1,14,0,10,1,12,0,8,1,13,0,9,1,18,0,8,1,17,0,13,1,13,0,8,1,16,0,8,1,13,0,8,1,41,0
Data 8,1,12,0,11,0,7,1,39,0,10,1,11,0,8,1,15,0,8,1,15,0,8,1,13,0,9,1,10,0,8,1,14,0,8,1,13,0,7,1,9,0,10,1,10,0,8,1,15,0,9,1,12,0,8,1,13,0,9,1,18,0,8,1,18,0,13,1,12,0,8,1,16,0,8,1,13,0,8,1,40,0,8,1,13,0
Data 10,0,8,1,39,0,9,1,12,0,8,1,15,0,8,1,15,0,8,1,13,0,9,1,10,0,8,1,14,0,8,1,13,0,7,1,8,0,10,1,11,0,7,1,16,0,10,1,11,0,8,1,13,0,9,1,18,0,8,1,19,0,12,1,12,0,8,1,16,0,8,1,13,0,8,1,39,0,8,1,14,0,10,0,8,1
Data 39,0,9,1,12,0,8,1,15,0,8,1,15,0,8,1,14,0,8,1,10,0,8,1,14,0,8,1,13,0,7,1,7,0,10,1,11,0,8,1,17,0,9,1,11,0,8,1,14,0,8,1,18,0,8,1,20,0,11,1,12,0,8,1,16,0,8,1,13,0,8,1,37,0,9,1,15,0,10,0,8,1,39,0,9,1,12,0
Data 8,1,15,0,8,1,15,0,8,1,14,0,8,1,10,0,8,1,13,0,9,1,12,0,8,1,5,0,10,1,13,0,8,1,17,0,9,1,11,0,8,1,14,0,8,1,18,0,8,1,20,0,12,1,11,0,8,1,16,0,8,1,13,0,8,1,36,0,9,1,16,0,10,0,8,1,38,0,9,1,13,0,8,1,15,0,8,1
Data 15,0,8,1,14,0,8,1,10,0,9,1,12,0,8,1,13,0,8,1,1,0,12,1,15,0,8,1,17,0,9,1,11,0,8,1,14,0,8,1,18,0,8,1,21,0,11,1,11,0,8,1,16,0,8,1,13,0,8,1,35,0,8,1,18,0,10,0,8,1,38,0,9,1,13,0,8,1,15,0,8,1,15,0,8,1,14,0
Data 8,1,10,0,9,1,12,0,8,1,13,0,19,1,17,0,8,1,18,0,8,1,11,0,8,1,14,0,8,1,18,0,8,1,21,0,11,1,11,0,8,1,16,0,8,1,13,0,8,1,34,0,8,1,19,0,10,0,8,1,37,0,9,1,14,0,8,1,15,0,8,1,15,0,8,1,14,0,8,1,10,0,10,1,10,0
Data 8,1,14,0,17,1,19,0,8,1,18,0,8,1,11,0,8,1,14,0,8,1,18,0,8,1,22,0,10,1,11,0,8,1,16,0,8,1,13,0,8,1,33,0,8,1,20,0,10,0,8,1,37,0,9,1,14,0,8,1,15,0,8,1,15,0,8,1,14,0,8,1,10,0,10,1,10,0,8,1,14,0,14,1,22,0
Data 8,1,18,0,8,1,11,0,8,1,14,0,8,1,17,0,9,1,22,0,10,1,11,0,8,1,16,0,8,1,13,0,8,1,32,0,8,1,21,0,10,0,8,1,36,0,9,1,15,0,8,1,15,0,8,1,15,0,8,1,14,0,8,1,11,0,10,1,9,0,7,1,15,0,10,1,26,0,8,1,18,0,8,1,11,0
Data 8,1,14,0,8,1,17,0,9,1,22,0,10,1,11,0,8,1,16,0,8,1,13,0,8,1,31,0,8,1,22,0,10,0,8,1,35,0,9,1,16,0,8,1,15,0,8,1,15,0,8,1,14,0,8,1,11,0,12,1,7,0,7,1,15,0,9,1,27,0,9,1,17,0,8,1,11,0,8,1,14,0,8,1,17,0,9,1
Data 22,0,10,1,11,0,8,1,16,0,8,1,13,0,8,1,30,0,8,1,23,0,10,0,8,1,34,0,10,1,16,0,8,1,15,0,8,1,15,0,8,1,14,0,8,1,11,0,14,1,4,0,9,1,14,0,9,1,27,0,9,1,17,0,8,1,11,0,8,1,14,0,8,1,17,0,9,1,22,0,10,1,11,0,8,1
Data 16,0,8,1,13,0,8,1,29,0,8,1,24,0,10,0,8,1,34,0,9,1,17,0,9,1,14,0,8,1,15,0,8,1,14,0,8,1,12,0,26,1,14,0,9,1,20,0,4,1,3,0,9,1,17,0,8,1,11,0,8,1,14,0,8,1,17,0,9,1,22,0,10,1,11,0,8,1,16,0,8,1,13,0,8,1,28,0
Data 8,1,25,0,10,0,8,1,32,0,10,1,18,0,9,1,14,0,8,1,15,0,8,1,14,0,8,1,13,0,26,1,13,0,10,1,18,0,5,1,3,0,9,1,17,0,7,1,12,0,8,1,14,0,8,1,17,0,9,1,22,0,9,1,12,0,8,1,16,0,8,1,13,0,8,1,26,0,9,1,26,0,10,0,8,1
Data 31,0,10,1,19,0,9,1,14,0,8,1,15,0,8,1,14,0,8,1,14,0,25,1,13,0,10,1,18,0,5,1,3,0,10,1,15,0,8,1,12,0,8,1,14,0,8,1,17,0,9,1,21,0,10,1,12,0,8,1,16,0,8,1,13,0,9,1,24,0,9,1,27,0,10,0,9,1,29,0,10,1,20,0,9,1
Data 14,0,8,1,15,0,8,1,14,0,8,1,15,0,25,1,13,0,10,1,16,0,6,1,4,0,10,1,14,0,8,1,12,0,8,1,14,0,8,1,17,0,9,1,21,0,10,1,12,0,8,1,16,0,8,1,13,0,9,1,23,0,9,1,28,0,10,0,9,1,27,0,11,1,21,0,10,1,12,0,9,1,15,0,8,1
Data 14,0,8,1,16,0,13,1,2,0,10,1,12,0,11,1,13,0,7,1,5,0,10,1,14,0,7,1,13,0,8,1,14,0,8,1,17,0,9,1,20,0,10,1,13,0,8,1,16,0,8,1,13,0,9,1,22,0,9,1,29,0,10,0,9,1,25,0,12,1,23,0,10,1,9,0,11,1,15,0,8,1,13,0,9,1
Data 18,0,9,1,4,0,11,1,11,0,12,1,11,0,7,1,6,0,11,1,12,0,8,1,13,0,8,1,13,0,9,1,17,0,9,1,20,0,10,1,13,0,8,1,16,0,8,1,13,0,10,1,20,0,8,1,31,0,10,0,11,1,20,0,14,1,24,0,12,1,4,0,14,1,15,0,8,1,13,0,9,1,32,0
Data 10,1,12,0,13,1,6,0,10,1,7,0,11,1,10,0,8,1,14,0,8,1,13,0,9,1,17,0,10,1,18,0,10,1,14,0,8,1,16,0,8,1,13,0,10,1,19,0,14,1,26,0,10,0,15,1,12,0,16,1,26,0,30,1,15,0,8,1,13,0,14,1,27,0,11,1,11,0,28,1,8,0
Data 12,1,8,0,8,1,15,0,8,1,13,0,14,1,11,0,12,1,16,0,10,1,15,0,9,1,1,0,4,1,10,0,8,1,13,0,11,1,9,0,4,1,4,0,34,1,7,0,10,0,41,1,28,0,30,1,15,0,8,1,13,0,14,1,28,0,11,1,11,0,26,1,10,0,13,1,4,0,9,1,16,0,8,1,13,0
Data 14,1,11,0,13,1,13,0,11,1,16,0,14,1,10,0,8,1,13,0,13,1,5,0,6,1,3,0,35,1,7,0,10,0,39,1,31,0,19,1,2,0,8,1,15,0,8,1,13,0,14,1,28,0,11,1,12,0,25,1,11,0,24,1,17,0,8,1,13,0,14,1,11,0,16,1,7,0,13,1,17,0,14,1
Data 10,0,8,1,13,0,24,1,3,0,35,1,7,0,5,0,41,1,35,0,16,1,4,0,8,1,15,0,8,1,12,0,13,1,31,0,11,1,12,0,23,1,13,0,22,1,18,0,8,1,12,0,13,1,13,0,35,1,17,0,14,1,11,0,8,1,13,0,23,1,4,0,34,1,8,0,3,0,38,1,40,0,15,1
Data 5,0,8,1,15,0,8,1,12,0,9,1,35,0,11,1,13,0,21,1,15,0,20,1,19,0,8,1,12,0,9,1,17,0,33,1,19,0,11,1,14,0,8,1,14,0,21,1,6,0,33,1,8,0,3,0,15,1,65,0,11,1,7,0,7,1,16,0,7,1,13,0,7,1,38,0,11,1,14,0,18,1,18,0
Data 16,1,21,0,7,1,13,0,7,1,18,0,5,1,1,0,26,1,21,0,9,1,16,0,7,1,17,0,16,1,12,0,25,1,13,0,3,0,6,1,76,0,7,1,9,0,6,1,17,0,4,1,16,0,4,1,41,0,11,1,17,0,13,1,22,0,11,1,24,0,4,1,16,0,4,1,21,0,3,1,10,0,15,1,25,0
Data 7,1,18,0,4,1,23,0,10,1,53,0,101,0,4,1,85,0,10,1,185,0,6,1,109,0,167,0,5,1,18,0,10,1,185,0,4,1,111,0,166,0,6,1,18,0,10,1,300,0,164,0,8,1,18,0,9,1,301,0,164,0,8,1,17,0,10,1,301,0,163,0,8,1,17,0,10,1
Data 302,0,162,0,9,1,16,0,10,1,303,0,162,0,9,1,15,0,10,1,304,0,162,0,9,1,14,0,10,1,305,0,162,0,10,1,11,0,11,1,306,0,162,0,12,1,6,0,12,1,308,0,162,0,28,1,310,0,163,0,25,1,312,0,164,0,21,1,315,0,166,0,14,1
Data 320,0,500,0,500,0,500,0