line clip test

Post your FreeBASIC tips and tricks here. Please don’t post your code without including an explanation.
dafhi
Posts: 1238
Joined: Jun 04, 2005 9:51

line clip test

Postby dafhi » Dec 24, 2018 23:27

i use this to debug my raster-based renderers

Code: Select all

var w = 640
var h = 480

screenres w,h,32


var a = 3.14159/4 ' start angle

while inkey=""
  var wm = w - 1, wh = wm/2 'dependents
  var hm = h - 1, hh = hm/2
 
  #define show(x,y)  line ( (x), (y) ) - ( (x)+r*cos(a), (y)+r*sin(a) ), -1
 
  var r = sqr(w*w+h*h)/10
 
  screenlock
    cls
    var k = 10
   
    '' top left
    #if 1
     show( -k,-k )
     show( k,k )
    #endif
   
    '' top right
    #if 0
     show( wm-k,k )
     show( wm+k,-k )
    #endif
   
    '' low left
    #if 0
     show( -k,hm+k )
     show( +k,hm-k )
    #endif
   
    '' low right
    #if 0
     show( wm+k,hm+k )
     show( wm-k,hm-k )
    #endif
   
    '' mid
    show( wh, hh )
  screenunlock
 
  sleep 1
  a += 1/80
wend

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 2 guests