[futurebasic] Some C to FB

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2013 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Sun, 9 Jun 2013 13:41:42 -0400
Can someone help me with a translation for the below…particularly the  lines 57 and 58? Are those a logical comparison? adding 1 if true?

Original link is at http://caca.zoy.org/browser/libpipi/trunk/pipi/dither/halftone.c?rev=2761

rc


45  for(y = 0; y < h; y++)
46	    {
47	        for(x = 0; x < w; x++)
48	        {
49	            double x2, y2, i, j, dist;
50	            float p, threshold = .5;
51	            int invert = 0;
52	
53	            x2 = x + .5;
54	            y2 = y + .5;
55	            i = (cost * x2 - sint * y2) / r;
56	            j = (cost * y2 + sint * x2) / r;
57	            i = i - (int)i + (i < 0.);
58	            j = j - (int)j + (j < 0.);
59	
60	            if(j > 0.5)
61	            {
62	                i = 1. - i;
63	                j = 1. - j;
64	            }
65	            if(i > 0.5)
66	            {
67	                invert = 1;
68	                i = 1. - i;
69	            }
70	
71	            dist = (i - .25) * (i - .25) + (j - .25) * (j - .25);
72	            threshold = dist * 4;
73	            if(invert)
74	                threshold = 1. - threshold;
75	
76	            p = dstdata[y * w + x];
77	            dstdata[y * w + x] = p > threshold ? 1. : 0.;
78	        }
79	    }