本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.quadraticCurveTo方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.quadraticCurveTo方法的具體用法?Java Context2d.quadraticCurveTo怎麽用?Java Context2d.quadraticCurveTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.canvas.dom.client.Context2d
的用法示例。
在下文中一共展示了Context2d.quadraticCurveTo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawRoundRectHelper
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* based on http://js-bits.blogspot.co.at/2010/07/canvas-rounded-corner-rectangles.html
*/
private static void drawRoundRectHelper(Context2d ctx, boolean drawOuterLine, final double x, final double y, final double width, final double height, final double radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
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: 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");
}
}
}
示例4: 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_ARC: {
double curX = x, curY = 0;
double radius = list.get(i++);
x = list.get(i++);
y = list.get(i++);
ctx.arcTo(curX, curY, x, y, radius);
break;
}
case CMD_CLOSE: {
ctx.closePath();
break;
}
default:
throw new AssertionError("Corrupt command list");
}
}
}