Author Topic: Serpinski triangles  (Read 3331 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Serpinski triangles
« on: February 01, 2019, 02:35:13 am »
Code: QB64: [Select]
  1. DEFINT A-Z
  2. x1 = 126: y1 = 80: x2 = 302: y2 = 160: z = 220
  3. DIM gbuff(12000) ' large buffer
  4. SCREEN 12 ' screen mode 640 * 480 * 16
  5. 'password$ = "woof" ' delete, comment out, or make null for ordinary screensaver
  6. rununtil! = TIMER + .5
  7. DO WHILE TIMER < rununtil!
  8.         discard = _MOUSEBUTTON(1)
  9.         discard = _MOUSEBUTTON(2)
  10.         discard = _MOUSEWHEEL
  11.     LOOP
  12.     a = (a + 3) MOD 360: c = -(a > 180)
  13.     y = 120 - 40 * COS(a * ATN(1) / 45) ' vertical along right
  14.     FOR i = 0 TO 2
  15.         j = i * 120: k = i * 4 + c * 2 + 1
  16.         c1 = VAL(MID$(" 7 1 8111012", k, 2))
  17.         c2 = VAL(MID$(" 612 5 214 9", k, 2))
  18.         PSET (x2, y + j), c1
  19.         PSET (x2 + z, y + j), c2
  20.         GET (x1 + VAL(MID$("122", i + 1, 1)), y1 + j)-(x2, y2 + j), gbuff()
  21.         PUT (x1, y1 + j), gbuff()
  22.         GET (z + x1 + VAL(MID$("122", i + 1, 1)), y1 + j)-(z + x2 + 1, y2 + j), gbuff()
  23.         PUT (z + x1, y1 + j), gbuff()
  24.     NEXT i
  25.     LINE (x2, 0)-(x2 + z, 479), 0, B
  26.     i$ = INKEY$
  27.     mi = _MOUSEINPUT
  28.     IF LEN(password$) THEN
  29.         guess$ = guess$ + i$: i$ = "":mi=0
  30.         IF INSTR(guess$ + SPACE$(4), password$) > 0 THEN SYSTEM
  31.     END IF
  32. LOOP UNTIL LEN(i$) OR mi
« Last Edit: February 02, 2019, 08:21:42 pm by Richard Frost »
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Serpinski triangles
« Reply #1 on: February 01, 2019, 04:31:27 pm »
Interesting!

Here is a variation made with circles: https://www.qb64.org/forum/index.php?topic=201.0