本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.bezierCurveTo方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.bezierCurveTo方法的具體用法?Java Context2d.bezierCurveTo怎麽用?Java Context2d.bezierCurveTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.canvas.dom.client.Context2d
的用法示例。
在下文中一共展示了Context2d.bezierCurveTo方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawEllipseHelper
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* based on http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas/2173084#2173084
*/
private static void drawEllipseHelper(Context2d ctx, boolean drawOuterLine, double x, double y, double w, double h) {
double kappa = .5522848f;
double ox = w / 2 * kappa; // control point offset horizontal
double oy = h / 2 * kappa; // control point offset vertical
double xe = x + w; // x-end
double ye = y + h; // y-end
double xm = x + w / 2; // x-middle
double ym = y + h / 2; // y-middle
ctx.beginPath();
ctx.moveTo(x, ym);
ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
ctx.fill();
if (drawOuterLine) {
ctx.stroke();
}
}
示例2: drawPath
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public static void drawPath(Path path, Context2d context) {
context.beginPath();
for (PathElement e : path.getElements()) {
switch (e.getType()) {
case ClosePath:
context.closePath();
break;
case CubicCurveTo:
CubicCurveTo c = (CubicCurveTo) e;
context.bezierCurveTo(c.cp1.x, c.cp1.y, c.cp2.x, c.cp2.y, c.p.x, c.p.y);
break;
case LineTo:
LineTo l = (LineTo) e;
context.lineTo(l.p.x, l.p.y);
break;
case MoveTo:
MoveTo m = (MoveTo) e;
context.moveTo(m.p.x, m.p.y);
break;
case QuadraticCurveTo:
QuadraticCurveTo q = (QuadraticCurveTo) e;
context.quadraticCurveTo(q.cp.x, q.cp.y, q.p.x, q.p.y);
break;
}
}
}
示例3: drawCone
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* Draw a cone. Does not call beginPath().
*/
public static void drawCone(Context2d g, double x, double y, double radius, double height) {
double kappa = .5522848;
double w = (2 * radius) * SQRT1_5;
double h = (2 * radius) * SQRT0_5;
double xm = w / 2f; // x-middle
double ym = h / 2f; // y-middle
double ox = xm * kappa; // control point offset horizontal
double oy = ym * kappa; // control point offset vertical
g.translate(x, y);
g.moveTo(w, ym);
g.bezierCurveTo(w, ym + oy, xm + ox, h, xm, h);
g.bezierCurveTo(xm - ox, h, 0, ym + oy, 0, ym);
g.lineTo(xm, ym - height);
g.closePath();
g.translate(-x, -y);
}
示例4: drawEllipse
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* Draw an ellipse. Does not call beginPath().
*/
public static void drawEllipse(Context2d g, double x, double y, double w, double h) {
double kappa = .5522848;
double xm = w / 2f; // x-middle
double ym = h / 2f; // y-middle
double ox = xm * kappa; // control point offset horizontal
double oy = ym * kappa; // control point offset vertical
g.translate(x, y);
g.moveTo(0, ym);
g.bezierCurveTo(0, ym - oy, xm - ox, 0, xm, 0);
g.bezierCurveTo(xm + ox, 0, w, ym - oy, w, ym);
g.bezierCurveTo(w, ym + oy, xm + ox, h, xm, h);
g.bezierCurveTo(xm - ox, h, 0, ym + oy, 0, ym);
g.translate(-x, -y);
}
示例5: drawRoundedRect
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* Draw a rounded rect. Does not call beginPath().
*/
public static void drawRoundedRect(Context2d g, double x, double y, double width, double height,
double topLeftRadiusX, double topLeftRadiusY, double topRightRadiusX, double topRightRadiusY,
double bottomLeftRadiusX, double bottomLeftRadiusY, double bottomRightRadiusX,
double bottomRightRadiusY) {
g.translate(x, y);
g.moveTo(topLeftRadiusX, 0);
g.lineTo(width - topRightRadiusX, 0);
x = width;
y = 0;
g.bezierCurveTo(x, y, x, y, width, topRightRadiusY);
g.lineTo(width, height - bottomRightRadiusY);
x = width;
y = height;
g.bezierCurveTo(x, y, x, y, width - bottomRightRadiusX, height);
g.lineTo(bottomLeftRadiusX, height);
x = 0;
y = height;
g.bezierCurveTo(x, y, x, y, 0, height - bottomLeftRadiusY);
g.lineTo(0, topLeftRadiusY);
x = 0;
y = 0;
g.bezierCurveTo(x, y, x, y, topLeftRadiusX, 0);
g.translate(-x, -y);
}
示例6: replay
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
void replay(Context2d ctx) {
ctx.beginPath();
int len = list.length(), i = 0;
double x = 0, y = 0;
while (i < len) {
switch ((int) list.get(i++)) {
case CMD_MOVE: {
x = list.get(i++);
y = list.get(i++);
ctx.moveTo(x, y);
break;
}
case CMD_LINE: {
x = list.get(i++);
y = list.get(i++);
ctx.lineTo(x, y);
break;
}
case CMD_QUAD: {
double cpx = list.get(i++);
double cpy = list.get(i++);
x = list.get(i++);
y = list.get(i++);
ctx.quadraticCurveTo(cpx, cpy, x, y);
break;
}
case CMD_BEZIER: {
double c1x = list.get(i++), c1y = list.get(i++);
double c2x = list.get(i++), c2y = list.get(i++);
x = list.get(i++);
y = list.get(i++);
ctx.bezierCurveTo(c1x, c1y, c2x, c2y, x, y);
break;
}
case CMD_CLOSE: {
ctx.closePath();
break;
}
default:
throw new AssertionError("Corrupt command list");
}
}
}