bresenham

Bresenham concentric circles leaving empty pixels

半城伤御伤魂 提交于 2020-01-02 06:01:51
问题 I am using the midpoint circle algorithm, also known as Bresenham's, to draw concentric circles. The difference between each circle's radius and that of the next is always 1, so the final result should be a full circular area. However, some pixels are left empty, as shown in the attached image. I'm using Javascript to paint on an HTML5 canvas, manipulating the canvas.getContext("2d").getImageData(...).data array. The circles are alternatively white and red, and the empty pixels are black. You

Algorithm for drawing a 4-connected line

老子叫甜甜 提交于 2019-12-28 05:54:12
问题 I'm looking for an algorithm (coded in Java would be nice, but anything clear enough to translate to Java is fine) to draw a 4-connected line. It seems that Bresenham's algorithm is the most widely used, but all the understandable implementations I've found are 8-connected. OpenCV's cvline function apparently has a 4-connected version, but the source code is, to me, as a mediocre and nearly C-illiterate programmer, impenetrable. Various other searches have turned up nothing. Thanks for any

Algorithm for drawing a 4-connected line

≡放荡痞女 提交于 2019-12-28 05:54:08
问题 I'm looking for an algorithm (coded in Java would be nice, but anything clear enough to translate to Java is fine) to draw a 4-connected line. It seems that Bresenham's algorithm is the most widely used, but all the understandable implementations I've found are 8-connected. OpenCV's cvline function apparently has a 4-connected version, but the source code is, to me, as a mediocre and nearly C-illiterate programmer, impenetrable. Various other searches have turned up nothing. Thanks for any

please explain this Bresenham Line drawing code for me

一世执手 提交于 2019-12-22 09:49:45
问题 I have searched throughout the Internet and found hundreds of implementation of Bresenham's line drawing algorithm. But, one thing I found strange is, only two or three of them can cover all of the eight octets. still, they are being used in many applications. For example, this lady implemented this version (line 415) of Bresenham's algorithm. But, it doesn't cover the whole 360 degrees. This guy here seems to be developing a library. But still it doesn't work properly. Can you tell me why?

Drawing lines with Bresenham's Line Algorithm

你说的曾经没有我的故事 提交于 2019-12-21 09:21:51
问题 My computer graphics homework is to implement OpenGL algorithms using only the ability to draw points. So obviously I need to get drawLine() to work before I can draw anything else. drawLine() has to be done using integers only. No floating point. This is what I was taught. Basically, lines can be broken up into 4 different categories, positive steep, positive shallow, negative steep and negative shallow. This is the picture I am supposed to draw: and this is the picture my program is drawing

Bresenham lines w/o diagonal movement

和自甴很熟 提交于 2019-12-18 09:36:21
问题 Is there a modified Bresenham algorithm, where the step from one pixel to the next one isn't allowed to be diagonally, just horizontally or vertically? Or any other algorithm which does that? (PHP preferred) Right: 0 0 0 1 0 0 1 1 0 1 1 0 1 1 0 0 Wrong: 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 回答1: Should be a trivial modification - let's say you're in the quadrant I - i.e. going up and to the right. Instead of doing a diagonal, do an up... and then a right. Instead of: for x from x0 to x1 plot(x,y)

Simplified Bresenham's line algorithm: What does it *exactly* do?

泪湿孤枕 提交于 2019-12-18 02:43:10
问题 Based on Wikipedia's article on Bresenham's line algorithm I've implemented the simplified version described there, my Java implementation looks like this: int dx = Math.abs(x2 - x1); int dy = Math.abs(y2 - y1); int sx = (x1 < x2) ? 1 : -1; int sy = (y1 < y2) ? 1 : -1; int err = dx - dy; while (true) { framebuffer.setPixel(x1, y1, Vec3.one); if (x1 == x2 && y1 == y2) { break; } int e2 = 2 * err; if (e2 > -dy) { err = err - dy; x1 = x1 + sx; } if (e2 < dx) { err = err + dx; y1 = y1 + sy; } }

Simplified Bresenham's line algorithm: What does it *exactly* do?

爷,独闯天下 提交于 2019-12-18 02:43:06
问题 Based on Wikipedia's article on Bresenham's line algorithm I've implemented the simplified version described there, my Java implementation looks like this: int dx = Math.abs(x2 - x1); int dy = Math.abs(y2 - y1); int sx = (x1 < x2) ? 1 : -1; int sy = (y1 < y2) ? 1 : -1; int err = dx - dy; while (true) { framebuffer.setPixel(x1, y1, Vec3.one); if (x1 == x2 && y1 == y2) { break; } int e2 = 2 * err; if (e2 > -dy) { err = err - dy; x1 = x1 + sx; } if (e2 < dx) { err = err + dx; y1 = y1 + sy; } }

Can this line drawing algorithm be optimized? - SDL

試著忘記壹切 提交于 2019-12-12 22:19:08
问题 For a project I have been working on, the ability to draw lines with a gradient (I.E. they change color over the interval they are drawn) would be very useful. I have an algorithm for this, as I will paste below, but it turns out to be DREADFULLY slow. I'm using the Bresenham algorithm to find each point, but I fear that I have reached the limits of software rendering. I've been using SDL2 thus far, and my line drawing algorithm appears 200x slower than SDL_RenderDrawLine . This is an