[libbluray-devel] BDGraphics: implement drawOval and fillOval

Ian Curtis git at videolan.org
Wed Mar 19 15:55:07 CET 2014


libbluray | branch: master | Ian Curtis <i.curtis at gmail.com> | Wed Mar 19 16:11:43 2014 +0200| [902e4f0670d8da6f4548772006b2827dace65e9a] | committer: hpi1

BDGraphics: implement drawOval and fillOval

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=902e4f0670d8da6f4548772006b2827dace65e9a
---

 .../bdj/java-j2me/java/awt/BDGraphics.java         |   25 ++++++++++++++++++--
 .../bdj/java-j2se/java/awt/BDGraphics.java         |   25 ++++++++++++++++++--
 2 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
index e0ad2a0..c29a6f0 100644
--- a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
@@ -554,12 +554,33 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
 
     /** Draws an oval to fit in the given rectangle */
     public void drawOval(int x, int y, int w, int h) {
-        logger.unimplemented("drawOval");
+
+        float angleIncriment = 180 / h;
+        int   rgb = foreground.getRGB();
+
+        for (int i = 0; i < h; i++) {
+            int offset = (int) (w/2 * Math.sin(angleIncriment*i));
+            int startX = x + w/2 - offset;
+            int endX   = x + w/2 + offset;
+
+            drawPoint(startX, y + i, rgb);
+            drawPoint(endX, y + i, rgb);
+        }
     }
 
     /** Fills an oval to fit in the given rectangle */
     public void fillOval(int x, int y, int w, int h) {
-        logger.unimplemented("fillOval");
+
+        float angleIncriment = angleIncriment = 180 / h;
+        int   rgb = foreground.getRGB();
+
+        for (int i = 0; i < h; i++) {
+            int offset = (int) (w/2 * Math.sin(angleIncriment*i));
+            int startX = x + w/2 - offset;
+            int endX   = x + w/2 + offset;
+
+            drawSpan(startX, y + i, endX - startX, rgb);
+        }
     }
 
     /**
diff --git a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
index 8f5d66b..6a841f2 100644
--- a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
@@ -636,12 +636,33 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
 
     /** Draws an oval to fit in the given rectangle */
     public void drawOval(int x, int y, int w, int h) {
-        logger.unimplemented("drawOval");
+
+        float angleIncriment = 180 / h;
+        int   rgb = foreground.getRGB();
+
+        for (int i = 0; i < h; i++) {
+            int offset = (int) (w/2 * Math.sin(angleIncriment*i));
+            int startX = x + w/2 - offset;
+            int endX   = x + w/2 + offset;
+
+            drawPoint(startX, y + i, rgb);
+            drawPoint(endX, y + i, rgb);
+        }
     }
 
     /** Fills an oval to fit in the given rectangle */
     public void fillOval(int x, int y, int w, int h) {
-        logger.unimplemented("fillOval");
+
+        float angleIncriment = angleIncriment = 180 / h;
+        int   rgb = foreground.getRGB();
+
+        for (int i = 0; i < h; i++) {
+            int offset = (int) (w/2 * Math.sin(angleIncriment*i));
+            int startX = x + w/2 - offset;
+            int endX   = x + w/2 + offset;
+
+            drawSpan(startX, y + i, endX - startX, rgb);
+        }
     }
 
     /**



More information about the libbluray-devel mailing list