Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wallpaper creator from repeated polygon patterns
#1
Photo 
I was inspired by a program for Linux called Kali that allows creating wallpapers from simple polygons. Basically it repeated a pattern over the whole screen, by flipping or replication. The program is quite good and I installed it into one of my Debian "Bookworm" installations.

I don't give the link to the program because the GUI appears to be FLTK and some of you aren't familiar or aren't comfortable with that style. The FLTK is an older GUI programming toolkit than GTK and Qt. Also it might be installable via a "dot-DEB" file only, which some people have become as suspicious as Windows installers. :/

Also the Kali program doesn't straight out save to JPEG or PNG or other popular format, but in EPS Postscript format. This might not be sufficient importing the EPS into GIMP converting to another format with Imagemagick.

Just look it up in search service, but write "kali drawing" because just putting down "kali" might give entries about Kali Linux. Which is not what I was talking about here.

Anyway, here's a program that creates 20 pictures that could be used as wallpapers for a 15-inch laptop (1366x768 resolution). Feel free to adjust it to your tastes. For each pass, it creates polygons from triangle to octagon inclusive and draws them repeatedly according to fixed horizontal and vertical offsets. Each polygon is given an initial 32-bit color value, then one of the registers is "bounced" back and forth like in a gradient to increase interest in the picture. The actual screen to save is hidden but written to, because it's too big to fit into my screen including the window titlebar and frame. Instead a 67%-scale screen is shown of what it was like.

Note the line with ```_SAVEIMAGE``` is commented out. In my version it saves in QOI format because I wanted to check out the plug-in for GIMP which could save and load those files. Smile This plug-in cannot be used in Debian "Bullseye" or earlier, unfortunately. In the open file requester in GIMP, must check enabled "Show all files" to be able to see and select a QOI file.

Happy New Year to all members of this forum and to everybody.

Code: (Select All)

'by mnrvovrfc 30-Dec-2023
$IF VERSION < 3.10 THEN
$ERROR Must compile in QB64 Phoenix Edition v3.10 or later!
$END IF
OPTION _EXPLICIT
DIM polyg(1 TO 8) AS LONG, x(1 TO 8) AS INTEGER, y(1 TO 8) AS INTEGER
DIM AS LONG thisp, displayp, cu
DIM AS INTEGER j, u, w, wd, ht, wi, hi, xx, yy, rr, gg, bb, x1, y1
DIM AS INTEGER ri, gi, bi, v
DIM afile$, goahead AS _BYTE, nn AS DOUBLE

RANDOMIZE TIMER

wd = 200
ht = 150

thisp = _newimage(1366, 768, 32)
displayp = _NEWIMAGE(915, 515, 32)

SCREEN displayp

FOR w = 1 TO 20
_DEST thisp
CLS
FOR j = 3 TO 8
DO
FOR u = 1 TO 7
polyg(u) = Random1(359)
NEXT
DO
goahead = 1
FOR u = 1 TO 6
IF polyg(u) < polyg(u + 1) THEN
SWAP polyg(u), polyg(u + 1)
goahead = 0
EXIT FOR
END IF
NEXT
LOOP UNTIL goahead
goahead = 1
FOR u = 1 TO 6
IF ABS(polyg(u) - polyg(u + 1)) <= 30 THEN goahead = 0: EXIT FOR
NEXT
LOOP UNTIL goahead
FOR u = 1 TO 7
nn = polyg(u) * 1E+6
polyg(u) = INT(_D2R(nn))
NEXT
polyg(j) = polyg(1)
DO
rr = Rand(8, 85) * 3
gg = Rand(8, 85) * 3
bb = Rand(8, 85) * 3
LOOP UNTIL rr >= 96 OR gg >= 96 OR bb >= 96
IF rr > 127 THEN ri = -2 ELSE ri = 2
IF gg > 127 THEN gi = -2 ELSE gi = 2
IF bb > 127 THEN bi = -2 ELSE bi = 2
v = INT(RND * 3 + 1)
SELECT CASE v
CASE 1
gg = 0: bb = 0
CASE 2
rr = 0: bb = 0
CASE 3
rr = 0: gg = 0
END SELECT
wi = (wd \ 2) + Random1(wd \ 2) - (wd \ 4)
hi = (ht \ 2) + Random1(ht \ 2) - (ht \ 4)
FOR u = 1 TO j
x(u) = _CEIL(COS(polyg(u) / 1E+6) * wi)
y(u) = _CEIL(SIN(polyg(u) / 1E+6) * hi)
NEXT
xx = -1366
DO UNTIL xx > 1366
yy = -768
DO UNTIL yy > 768
goahead = 0
FOR u = 1 TO j
x1 = x(u) + xx
y1 = y(u) + yy
IF ((x1 < 0) OR (x1 > 1366)) AND ((y1 < 0) OR (y1 > 768)) THEN goahead = goahead + 1
NEXT
IF goahead < j THEN
cu = _RGB(rr, gg, bb)
IF ri THEN
rr = rr + ri
IF rr < 48 OR rr > 255 THEN
ri = ri * -1
rr = rr + ri
END IF
END IF
IF gi THEN
IF gg < 48 OR gg > 255 THEN
gi = gi * -1
gg = gg + gi
END IF
END IF
IF bi THEN
IF bb < 48 OR bb > 255 THEN
bi = bi * -1
bb = bb + bi
END IF
END IF
x1 = x(1) + xx
y1 = y(1) + yy
PSET (x1, y1)
FOR u = 2 TO j
x1 = x(u) + xx
y1 = y(u) + yy
LINE -(x1, y1), cu
NEXT
END IF
yy = yy + hi
LOOP
xx = xx + wi
LOOP
NEXT
_DEST displayp
_PUTIMAGE (0, 0)-(914, 514), thisp, displayp, (0, 0)-(1365, 767)
'afile$ = ENVIRON$("HOME") + "/Pictures/mirrorbagli" + Zeroes$(w, 2) + ".qoi"
'_SAVEIMAGE afile$, thisp
_DELAY 3
NEXT
SYSTEM

FUNCTION Rand& (fromval&, toval&)
DIM sg%, f&, t&
IF fromval& = toval& THEN
Rand& = fromval&
EXIT FUNCTION
END IF
f& = fromval&
t& = toval&
IF (f& < 0) AND (t& < 0) THEN
sg% = -1
f& = f& * -1
t& = t& * -1
ELSE
sg% = 1
END IF
IF f& > t& THEN SWAP f&, t&
Rand& = INT(RND * (t& - f& + 1) + f&) * sg%
END FUNCTION

FUNCTION Random1& (maxvaluu&)
DIM sg%
sg% = SGN(maxvaluu&)
IF sg% = 0 THEN
Random1& = 0
ELSE
IF sg% = -1 THEN maxvaluu& = maxvaluu& * -1
Random1& = INT(RND * maxvaluu& + 1) * sg%
END IF
END FUNCTION

FUNCTION Zeroes$ (num AS LONG, numdig AS INTEGER)
DIM b$, v AS LONG
DIM AS INTEGER sg, hx
IF num < 0 THEN sg = -1: num = num * -1
IF numdig < 0 THEN hx = 1: numdig = numdig * -1 ELSE hx = 0
IF hx THEN
b$ = HEX$(num)
ELSE
b$ = LTRIM$(STR$(num))
END IF
v = numdig - LEN(b$)
IF v > 0 THEN b$ = STRING$(v, 48) + b$
IF sg = -1 THEN b$ = "-" + b$
Zeroes$ = b$
END FUNCTION

   
   
Reply
#2
looks like screen saver
Big Grin
Reply
#3
hey ..where is my member @roquedrivel Huh
Reply
#4
Where is mnr?
b = b + ...
Reply
#5
hmmm @mnr gone too ????
Reply
#6
Mn was last in here on Jan 1.  Looks like he's taking his winter sabbatical as well.  Wink
Reply




Users browsing this thread: 2 Guest(s)