Author Topic: MAPTRIANGLE in 3D  (Read 46 times)

MAPTRIANGLE in 3D
« on: June 25, 2018, 05:08:57 PM »
Code: [Select]
SCREEN _NEWIMAGE(1024, 768, 32)
im& = _SCREENIMAGE
img& = _COPYIMAGE(im&, 33)
_FREEIMAGE im&
SX0 = 0: SY0 = 0: SX1 = 0: SY1 = _HEIGHT: sx2 = _WIDTH: sy2 = 0: sx3 = _WIDTH: sy3 = _HEIGHT
DX0 = -2: DY0 = 2: DX1 = -2: DY1 = -2: DX2 = 2: DY2 = 2: DX3 = 2: DY3 = -2

tt = .01: t = .1
DO
    e& = ell&
    WHILE _MOUSEINPUT: WEND
    Mx = _MOUSEX: My = _MOUSEY
    StredX = Mx
    t = t + tt: IF t > _PI(2) OR t < -_PI(2) THEN tt = tt * -1
    RR = SIN(t) - 4
    SS = COS(t) - 10
    R = -SIN(t) * -2
    s = -COS(t) * 2

    _MAPTRIANGLE (SX0, SY0)-(sx3, sy3)-(SX1, SY1), e& TO(DX0 * R, DY0 * s, RR)-(DX3 * R, DY3 * s, SS)-(DX1 * R, DY1 * s, RR), 0, _SMOOTH
    _MAPTRIANGLE (SX0, SY0)-(sx3, sy3)-(sx2, sy2), e& TO(DX0 * R, DY0 * s, RR)-(DX3 * R, DY3 * s, SS)-(DX2 * R, DY2 * s, SS), 0, _SMOOTH
    _DISPLAY
    _LIMIT 30
LOOP



FUNCTION ell&

    SHARED vx, vy, Mxx, Myy
    LOCATE 1, 1: PRINT "This is Software Screen."
    V& = _NEWIMAGE(1024, 768, 32)
    _DEST V&
    W = 1024: H = 768
    IF Mxx = 0 THEN Mxx = 10: Myy = 10
    vx = vx + Mxx: IF vx > W OR vx < 0 THEN Mxx = Mxx * -1
    vy = vy + Myy: IF vy > H OR vy < 0 THEN Myy = Myy * -1
    CLS , _RGB32(1, 55, 132)
    _PRINTMODE _KEEPBACKGROUND
    LOCATE 11, 30: PRINT "This is Hardware Screen"
    FOR d = 0 TO _PI / 2 STEP .2
        LINE (vx - SIN(d) * 50, vy - COS(d) * 50)-(vx + SIN(d) * 50, vy + COS(d) * 50), , BF
    NEXT d
    _DEST 0
    ell& = _COPYIMAGE(V&, 33)
    _FREEIMAGE V&
END FUNCTION
Coding is relax (At least sometimes)

Re: MAPTRIANGLE in 3D
« Reply #1 on: June 25, 2018, 05:14:07 PM »
Please add this
_FREEIMAGE E& to line 28 after _DISPLAY or program use very much memory and crashed. Why is time limited modification for post..... ????
Coding is relax (At least sometimes)