Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function scrMidpointCircle(xCentre, yCentre, radius){
- var arr = [];
- var _x = radius, _y = 0;
- array_push(arr, [_x + xCentre, _y + yCentre]);
- if (radius> 0) {
- array_push(arr, [_x + xCentre, -_y + yCentre]);
- array_push(arr, [_y + xCentre, _x + yCentre]);
- array_push(arr, [_y + xCentre, -_x + yCentre]);
- array_push(arr, [-_y + xCentre, _x + yCentre]);
- array_push(arr, [-_x + xCentre, _y + yCentre]);
- }
- var P = 1 - radius;
- while (_x > _y) {
- _y++;
- if (P <= 0)
- P = P + 2 * _y + 1;
- else {
- _x--;
- P = P + 2 * _y - 2 * _x + 1;
- }
- if (_x < _y) {
- break;
- }
- array_push(arr, [_x + xCentre, _y + yCentre]);
- array_push(arr, [-_x + xCentre, _y + yCentre]);
- array_push(arr, [_x + xCentre, -_y + yCentre]);
- array_push(arr, [-_x + xCentre, -_y + yCentre]);
- if (_x != _y) {
- array_push(arr, [_y + xCentre, _x + yCentre]);
- array_push(arr, [-_y + xCentre, _x + yCentre]);
- array_push(arr, [_y + xCentre, -_x + yCentre]);
- array_push(arr, [-_y + xCentre, -_x + yCentre]);
- }
- }
- return arr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement