Revision: 2468
http://sourceforge.net/p/swingme/code/2468
Author: yuranet
Date: 2021-06-23 10:56:56 +0000 (Wed, 23 Jun 2021)
Log Message:
-----------
arcs work
Modified Paths:
--------------
iOSME/src/javax/microedition/lcdui/Graphics.java
Modified: iOSME/src/javax/microedition/lcdui/Graphics.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Graphics.java 2021-06-23 10:24:47 UTC (rev 2467)
+++ iOSME/src/javax/microedition/lcdui/Graphics.java 2021-06-23 10:56:56 UTC (rev 2468)
@@ -68,6 +68,20 @@
dirtyClip = true;
}
+ public void translate(int x, int y) {
+ tx += x;
+ ty += y;
+ dirtyClip = true;
+ }
+
+ public int getTranslateX() {
+ return tx;
+ }
+
+ public int getTranslateY() {
+ return ty;
+ }
+
public int getClipX() {
return (int)getClipBounds().origin().x();
}
@@ -84,6 +98,17 @@
return (int)getClipBounds().size().height();
}
+ public void clipRect(int x, int y, int w, int h) {
+ CoreGraphics.CGContextClipToRect(context, new CGRect(new CGPoint(tx+x, ty+y), new CGSize(w, h)));
+ dirtyClip = true;
+ }
+
+ public void setClip(int x, int y, int w, int h) {
+ CoreGraphics.CGContextRestoreGState(context);
+ CoreGraphics.CGContextSaveGState(context);
+ clipRect(x, y, w, h);
+ }
+
public int getColor() {
NFloatPtr alpha = PtrFactory.newNFloatReference();
NFloatPtr red = PtrFactory.newNFloatReference();
@@ -276,63 +301,38 @@
//}
}
- public void clipRect(int x, int y, int w, int h) {
- CoreGraphics.CGContextClipToRect(context, new CGRect(new CGPoint(tx+x, ty+y), new CGSize(w, h)));
- dirtyClip = true;
- }
+ public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+ CGPoint center = new CGPoint(tx + x + width / 2, ty + y + height / 2);
- public void setClip(int x, int y, int w, int h) {
- CoreGraphics.CGContextRestoreGState(context);
CoreGraphics.CGContextSaveGState(context);
- clipRect(x, y, w, h);
- }
- public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
-/*
- CGContextSaveGState(theCGContext);
- CGPoint center = CGPointMake(x + width / 2.0, y + height / 2.0);
- UIBezierPath* clip = [UIBezierPath bezierPathWithArcCenter:center
- radius:max(width, height)
- startAngle:startAngle
- endAngle:endAngle
- clockwise:YES];
- [clip addLineToPoint:center];
- [clip closePath];
- [clip addClip];
+ UIBezierPath clip = UIBezierPath.bezierPathWithArcCenterRadiusStartAngleEndAngleClockwise(center, Math.max(width / 2, height/ 2), startAngle, arcAngle, true);
+ clip.addLineToPoint(center);
+ clip.closePath();
+ clip.addClip();
- UIBezierPath *arc = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(x, y, width, height)];
- [[UIColor blackColor] setStroke];
- [arc stroke];
+ UIBezierPath bezierPath = UIBezierPath.bezierPathWithOvalInRect(getRect(x, y, width, height));
+ CoreGraphics.CGContextAddPath(context, bezierPath.CGPath());
+ CoreGraphics.CGContextStrokePath(context);
- CGContextRestoreGState(theCGContext);
- */
-
- //paint.setStyle(Paint.Style.FILL);
- //RectF rect = new RectF(tx+x, ty+y, tx+x + width, ty+y + height);
- //canvas.drawArc(rect, startAngle, arcAngle, false, paint);
- throw new UnsupportedOperationException();
+ CoreGraphics.CGContextRestoreGState(context);
}
- public void translate(int x, int y) {
- tx += x;
- ty += y;
- dirtyClip = true;
- }
+ public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+ CGPoint center = new CGPoint(tx + x + width / 2, ty + y + height / 2);
- public int getTranslateX() {
- return tx;
- }
+ CoreGraphics.CGContextSaveGState(context);
- public int getTranslateY() {
- return ty;
- }
+ UIBezierPath clip = UIBezierPath.bezierPathWithArcCenterRadiusStartAngleEndAngleClockwise(center, Math.max(width / 2, height/ 2), startAngle, arcAngle, true);
+ clip.addLineToPoint(center);
+ clip.closePath();
+ clip.addClip();
- public void drawArc(int x, int y, int width, int height, int startAngle,
- int arcAngle) {
- //paint.setStyle(Paint.Style.STROKE);
- //RectF rect = new RectF(tx+x, ty+y, tx+x + width, ty+y + height);
- //canvas.drawArc(rect, startAngle, arcAngle, false, paint);
- throw new UnsupportedOperationException();
+ UIBezierPath bezierPath = UIBezierPath.bezierPathWithOvalInRect(getRect(x, y, width, height));
+ CoreGraphics.CGContextAddPath(context, bezierPath.CGPath());
+ CoreGraphics.CGContextFillPath(context);
+
+ CoreGraphics.CGContextRestoreGState(context);
}
public void drawChar(char character, int x, int y, int anchor) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|