本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.fill方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.fill方法的具體用法?Java Context2d.fill怎麽用?Java Context2d.fill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.canvas.dom.client.Context2d
的用法示例。
在下文中一共展示了Context2d.fill方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawShape
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* Rysuje zakonczenie linii
*
* @param shapeName
* @param context
* @param centerX
* @param centerY
* @param startX
* @param startY
*/
private void drawShape(String shapeName, Context2d context, double centerX, double centerY, double startX, double startY) {
if ("dot".equals(shapeName)) {
context.beginPath();
context.arc(centerX, centerY, 3, 0, 2 * Math.PI, false);
context.closePath();
context.fill();
} else if ("arrow".equals(shapeName)) {
CanvasArrow canvas = new CanvasArrow(context, startX, startY, centerX, centerY);
canvas.draw();
}
}
示例2: createBillboard
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public static BillboardOptions createBillboard(DrawInteractionOptions options) {
Canvas canvas = Canvas.createIfSupported();
Context2d context = canvas.getContext2d();
context.setFillStyle(options.color.toCssColorString());
context.setStrokeStyle(options.outlineColor.toCssColorString());
context.setLineWidth(options.outlineWidth);
context.translate(canvas.getCoordinateSpaceWidth() / 2, canvas.getCoordinateSpaceHeight() / 2);
context.beginPath();
context.arc(0, 0, options.pixelSize, 0, Math.PI * 2, true);
context.closePath();
context.stroke();
context.fill();
BillboardOptions billboard = new BillboardOptions();
billboard.horizontalOrigin = HorizontalOrigin.CENTER();
billboard.verticalOrigin = VerticalOrigin.CENTER();
billboard.imageCanvas = canvas.getCanvasElement();
return billboard;
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: repaint
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void repaint(Tool tool, int x, int y, int tileSize){
Context2d context = canvasLayer.getContext();
context.clearRect(0, 0, canvasLayer.getWidth(), canvasLayer.getHeight());
if (tool == Tool.BRUSH) {
} else if (tool == Tool.ERASER) {
Eraser eraser = ToolBox.getInstance().getEraser();
int size = eraser.getSize()*tileSize;
context.save();
context.setLineWidth(1.0);
context.setStrokeStyle(CssColors.RED);
context.setFillStyle(CssColors.LIGHT_GREY);
context.rect(x, y, size, size);
context.stroke();
context.setGlobalAlpha(0.25);
context.fill();
context.restore();
}
}
示例6: render
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
if (!isVisible()) {
return;
}
redrawNeeded = false;
g.save();
g.translate(x, y);
if (redrawBufferNeeded) {
buffer.render();
redrawBufferNeeded = false;
}
if (null != backgroundColor) {
g.beginPath();
g.rect(0, 0, width, height);
g.setFillStyle(backgroundColor);
g.fill();
}
buffer.flip(g);
g.restore();
}
示例7: PolygonDisplayElement
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public PolygonDisplayElement(String id, int x, int y, int width,
int height, int[][] coords) {
super(id, x, y, width, height);
this.coords = coords;
// Create a canvas containing the filled polygon with no border
Canvas sub_canvas = Canvas.createIfSupported();
sub_canvas.setCoordinateSpaceWidth(baseWidth());
sub_canvas.setCoordinateSpaceHeight(baseHeight());
Context2d context = sub_canvas.getContext2d();
context.save();
context.beginPath();
context.moveTo(coords[0][0] - baseLeft(), coords[0][1] - baseTop());
for (int i = 1; i < coords.length; i++) {
context.lineTo(coords[i][0] - baseLeft(), coords[i][1] - baseTop());
}
context.setFillStyle(fill_color);
context.fill();
context.closePath();
context.restore();
this.image_data = context.getImageData(0, 0, baseWidth(), baseHeight());
}
示例8: getImage
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private CanvasElement getImage() {
if (!Cesium.defined(particleCanvas)) {
particleCanvas = RootPanel.get().getElement().getOwnerDocument().createCanvasElement();
particleCanvas.setWidth(20);
particleCanvas.setHeight(20);
Context2d context2d = particleCanvas.getContext2d();
context2d.beginPath();
context2d.arc(8, 8, 8, 0, Math.TWO_PI(), true);
context2d.closePath();
context2d.setFillStyle("rgb(255, 255, 255)");
context2d.fill();
Cesium.log(particleCanvas);
}
return particleCanvas;
}
示例9: draw
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
double zoom = area.zoom();
context.save();
context.translate(-area.viewportLeft(), -area.viewportTop());
context.scale(zoom, zoom);
// outline
int[][] coords = el.coordinates();
context.beginPath();
context.moveTo(coords[0][0], coords[0][1]);
for (int i = 1; i < coords.length; i++) {
context.lineTo(coords[i][0], coords[i][1]);
}
context.setLineWidth(6);
context.stroke();
context.setGlobalAlpha(0.3);
context.setFillStyle("white");
context.fill();
context.setGlobalAlpha(1.0);
context.closePath();
// text
context.setFillStyle("black");
context.setFont("bold 60px sans-serif");
context.setTextBaseline("top");
context.fillText(el.text(), el.baseLeft(), el.baseTop(), el.baseWidth());
context.restore();
cb.onDrawn();
}
示例10: render
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
g.save();
g.setFillStyle("#F99");
g.setStrokeStyle("#333");
g.beginPath();
GraphicsUtil.drawRoundedRect(g, 0.5, 0.5, width - 1, height - 1, 8);
g.closePath();
g.fill();
g.stroke();
renderText(g);
g.restore();
}
示例11: draw
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
double zoom = area.zoom();
context.save();
context.translate(-area.viewportLeft(), -area.viewportTop());
context.scale(zoom, zoom);
context.beginPath();
context.moveTo(coords[0][0], coords[0][1]);
for (int i = 1; i < coords.length; i++) {
context.lineTo(coords[i][0], coords[i][1]);
}
context.setLineWidth(6);
context.stroke();
context.setGlobalAlpha(0.3);
context.setFillStyle("white");
context.fill();
context.setGlobalAlpha(1.0);
context.closePath();
context.restore();
cb.onDrawn();
}
示例12: render
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
g.save();
g.setFillStyle("#333");
g.setStrokeStyle("#999");
g.beginPath();
GraphicsUtil.drawRoundedRect(g, 0.5, 0.5, width - 1, height - 1, 8);
g.closePath();
g.fill();
g.stroke();
renderText(g);
g.restore();
}
示例13: render
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
g.save();
g.setGlobalAlpha(0.4);
g.setFillStyle("#333");
g.setStrokeStyle("#999");
g.beginPath();
GraphicsUtil.drawRoundedRect(g, 0.5, 0.5, width - 1, height - 1, 8);
g.closePath();
g.fill();
g.stroke();
renderText(g);
g.restore();
}
示例14: draw
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
double zoom = area.zoom();
context.save();
context.translate(-area.viewportLeft(), -area.viewportTop());
context.scale(zoom, zoom);
// Draw outline
int[][] coords = el.coordinates();
context.beginPath();
context.moveTo(coords[0][0], coords[0][1]);
for (int i = 1; i < coords.length; i++) {
context.lineTo(coords[i][0], coords[i][1]);
}
context.setLineWidth(6);
context.stroke();
context.setGlobalAlpha(0.3);
context.setFillStyle("white");
context.fill();
context.setGlobalAlpha(1.0);
context.closePath();
// Write text
context.setFillStyle("black");
context.setFont("bold 60px sans-serif");
context.setTextBaseline("top");
if (el.text().contains("<") && el.text().contains(">")) {
context.fillText(el.label() + "...", el.baseLeft(), el.baseTop(), el.baseWidth());
el.neverShowPopup(false);
} else {
String[] words = el.text().split(" ");
String line = "";
int y = el.baseTop();
for (int i = 0; i < words.length; i++) {
String test_line = line + words[i] + " ";
if (context.measureText(test_line).getWidth() > el.baseWidth() && i > 0
|| words[i].contains("\n")) {
context.fillText(line, el.baseLeft(), y);
y += step;
line = words[i] + " ";
if (y + step > el.baseTop() + el.baseHeight()) {
context.restore();
el.neverShowPopup(false);
cb.onDrawn();
return;
}
} else {
line = test_line;
}
}
context.fillText(line, el.baseLeft(), y);
el.neverShowPopup(true);
}
context.restore();
cb.onDrawn();
}