@@ -2227,27 +2227,30 @@ int image_(Main_drawRect)(lua_State *L) {
22272227 int cg = luaL_checkint (L , 8 );
22282228 int cb = luaL_checkint (L , 9 );
22292229
2230- int offset = lineWidth / 2 ;
2231- int x1 = (int ) MAX (0 , x1long - offset - 1 );
2232- int y1 = (int ) MAX (0 , y1long - offset - 1 );
2233- int x2 = (int ) MIN (output -> size [2 ] - 1 , x2long - offset - 1 );
2234- int y2 = (int ) MIN (output -> size [1 ] - 1 , y2long - offset - 1 );
2235-
2236- int w = x2 - x1 + 1 ;
2237- int h = y2 - y1 + 1 ;
2238- for (int y = y1 ; y < y2 + lineWidth ; y ++ ) {
2239- for (int x = x1 ; x < x1 + lineWidth ; x ++ ) {
2230+ int loffset = lineWidth / 2 + 1 ;
2231+ int uoffset = lineWidth - loffset - 1 ;
2232+ int x1l = (int ) MAX (0 , x1long - loffset );
2233+ int y1l = (int ) MAX (0 , y1long - loffset );
2234+ int x1u = (int ) MIN (output -> size [2 ], x1long + uoffset + 1 );
2235+ int y1u = (int ) MIN (output -> size [1 ], y1long + uoffset + 1 );
2236+ int x2l = (int ) MAX (0 , x2long - loffset );
2237+ int y2l = (int ) MAX (0 , y2long - loffset );
2238+ int x2u = (int ) MIN (output -> size [2 ], x2long + uoffset + 1 );
2239+ int y2u = (int ) MIN (output -> size [1 ], y2long + uoffset + 1 );
2240+
2241+ for (int y = y1l ; y < y2u ; y ++ ) {
2242+ for (int x = x1l ; x < x1u ; x ++ ) {
22402243 image_ (drawPixel )(output , y , x , cr , cg , cb );
22412244 }
2242- for (int x = x2 ; x < x2 + lineWidth ; x ++ ) {
2245+ for (int x = x2l ; x < x2u ; x ++ ) {
22432246 image_ (drawPixel )(output , y , x , cr , cg , cb );
22442247 }
22452248 }
2246- for (int x = x1 ; x < x2 + lineWidth ; x ++ ) {
2247- for (int y = y1 ; y < y1 + lineWidth ; y ++ ) {
2249+ for (int x = x1l ; x < x2u ; x ++ ) {
2250+ for (int y = y1l ; y < y1u ; y ++ ) {
22482251 image_ (drawPixel )(output , y , x , cr , cg , cb );
22492252 }
2250- for (int y = y2 ; y < y2 + lineWidth ; y ++ ) {
2253+ for (int y = y2l ; y < y2u ; y ++ ) {
22512254 image_ (drawPixel )(output , y , x , cr , cg , cb );
22522255 }
22532256 }
0 commit comments