QB64 Phoenix Edition
Old Paper - Put an old paper texture on the screen - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7)
+---- Thread: Old Paper - Put an old paper texture on the screen (/showthread.php?tid=4152)



Old Paper - Put an old paper texture on the screen - Dav - 11-25-2025

Here's a little SUB I made a while back and never shared.  Thought it may be useful.  It paints an old paper texture at given screen coordinates and you can specify the color of the paper.  It uses a very small grey paper image which is layered with a given color using the LINE statement.  The texture looks okay when filling both small and large screen areas.  I've found it handy for several kinds of programs.

This method is kind of outdated now that QB64PE can embed image files, and also has BASE64 built-in.  But for those who still like to stick things in code, here you go. 

- Dav

Code: (Select All)
'============
'OldPaper.bas
'============
'Coded by Dav for QB64PE.
'Small SUB loads nice old paper texture on screen.
'You can specify the size and color of the old paper.
'Use it for background, textured buttons, etc...

Screen _NewImage(_DesktopHeight, Int(_DesktopHeight * .75), 32)

Do
    x1 = Rnd * _Width + 1: x2 = x1 + Rnd * _Width + 1
    y1 = Rnd * _Height + 1: y2 = y1 + Rnd * _Height + 1
    OldPaper x1, y1, x2, y2, Rnd * 155, Rnd * 155, Rnd * 155
    _Limit 10
    _Display
Loop

Sub OldPaper (x1, y1, x2, y2, r, g, b)
    A$ = "" 'Loads old paper at given screen coordinates and r,g,b color.
    A$ = A$ + "2BgDTi)>A-YROXo*0F)G}<S=/|gF8-QlUIW8h<eoH?Z(C{Uh2<N7=9P*l4xZD1Iz+wa[9+d[WUS5"
    A$ = A$ + "S4YVM/n-Y}H.vE3J*uJ<.3{g6Fw;ON=Ia>upAodpP<*E'xO4pveHLNG7Mr1pa'jDl;hEn6'A:1d1"
    A$ = A$ + "D^Z1Gi5'o_4hd*kE<yIKI48yoF{AQ(G<B)ca6Zec}55M:=Wf{-IC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2"
    For i = 39 To 125
        If i <> 64 And i <> 96 Then c$ = c$ + Chr$(i)
    Next: Dim v As _Unsigned Long
    a = Val(Mid$(A$, 1, 1))
    For i& = 2 To Len(A$) Step 5: v = 0
        For j& = 0 To 4: p& = 85 ^ (4 - j&)
            c& = InStr(c$, Mid$(A$, i& + j&, 1)) - 1
        v = v + c& * p&: Next: o$ = o$ + MKL$(v)
    Next: btemp$ = Mid$(o$, 1, Len(o$) - a + 1)
    BASFILE$ = _Inflate$(btemp$, 2328) 'uncompress image data
    tempwall& = _LoadImage(BASFILE$, 32, "memory") 'load image data from string memory
    _PutImage (x1, y1)-(x2, y2), tempwall& 'put image on screen at given cords
    Line (x1, y1)-(x2, y2), _RGBA(r, g, b, 55), BF 'layer given color over it
    _FreeImage tempwall&: A$ = "": BASFILE$ = "" 'clean up on aisle 4
End Sub



RE: Old Paper - Put an old paper texture on the screen - Delsus - 11-25-2025

Hello! Nice program!

I have always wondered how an image can be drawn using those characters. Can you please enlighten me?


RE: Old Paper - Put an old paper texture on the screen - SpriggsySpriggs - 11-25-2025

@Delsus, the image is being stored in a deflated string that he then inflates and loads into memory. It's just the raw binary of the image but compressed.


RE: Old Paper - Put an old paper texture on the screen - bplus - 11-25-2025

Dang I was hoping to see what Rho used for the Wiki, the realistic looking rough paper. That might be done with an image also? Don't think its drawing that paper.


RE: Old Paper - Put an old paper texture on the screen - Pete - 11-26-2025

No, no, no! That's a utility, not a program!!! Big Grin Big Grin Big Grin 

My artistic talent is strictly linear in nature, so I could never come up with stuff like this in a million years. +2

Pete