本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.strokeRect方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.strokeRect方法的具体用法?Java GraphicsContext.strokeRect怎么用?Java GraphicsContext.strokeRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext.strokeRect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void draw(DungeonTileRenderer renderer, GraphicsContext g)
{
RAND.setSeed((long)(renderer.posX * 17 + renderer.posY));
double ds = MAX_BORDER - MIN_BORDER;
double dx = RAND.nextDouble() * ds + MIN_BORDER;
double dy = RAND.nextDouble() * ds + MIN_BORDER;
double dw = RAND.nextDouble() * ds + MIN_BORDER;
double dh = RAND.nextDouble() * ds + MIN_BORDER;
drawBlock(renderer, g, this.chestPaint, dx, dy, 1 - dx - dw, 1 - dy - dh);
if (this.outlinePaint != null)
{
g.setStroke(this.outlinePaint);
}
g.setLineWidth(OUTLINE_WIDTH);
g.strokeRect(dx, dy, 1 - dx - dw, 1 - dy - dh);
}
示例2: initDraw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void initDraw(GraphicsContext gc) {
double canvasWidth = gc.getCanvas().getWidth();
double canvasHeight = gc.getCanvas().getHeight();
log.info("canvasWidth = {}, canvasHeight = {}", canvasWidth, canvasHeight);
gc.clearRect(0, 0, canvasWidth, canvasHeight);
gc.setStroke(borderRectangleColor);
gc.setLineWidth(5);
gc.strokeRect(0, // x of the upper left corner
0, // y of the upper left corner
canvasWidth, // width of the rectangle
canvasHeight); // height of the rectangle
gc.setFill(Color.RED);
gc.setStroke(Color.BLUE);
gc.setLineWidth(drawLineWidth);
}
示例3: drawShapes
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawShapes() {
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
gc.setStroke(Color.RED);
gc.setFill(Color.YELLOW);
gc.setLineWidth(5);
double w = 100;
double h = 100;
double width = drawingCanvas.getWidth();
double height = drawingCanvas.getHeight();
gc.fillRect(width / 2 - w / 2, height / 2 - h / 2, w, h);
gc.strokeRect(width / 2 - w / 2, height / 2 - h / 2, w, h);
double initialX = 100;
double initialY = 200;
double dr = -20;
for (double radius = 100; radius >= 20; radius += dr, initialX -= dr, initialY -= dr) {
gc.strokeOval(initialX, initialY, 2 * radius, 2 * radius);
}
// Hometasks:
// 1. draw a sun!
// 2. draw regular ngons (fix the function that I wrote)
}
示例4: draw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw() {
drawGrid();
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
gc.setStroke(Color.BLACK);
gc.setLineWidth(5);
gc.setFill(Color.YELLOW);
gc.fillRect(300 - 50, 200 - 50, 100, 100);
gc.strokeRect(300 - 50, 200 - 50, 100, 100);
gc.setFill(Color.GREEN);
gc.fillOval(100, 100, 200, 100);
gc.strokeOval(100, 100, 200, 100);
// Hometasks:
// 1. Draw a circle right at the center with radius of 150 pixels
// 2. Draw 20 concentric circles in the top left box
// 3. Draw a sun (circle + rays)
// 4. Draw a regular n-gon (like pentagon)
}
示例5: drawBorder
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawBorder(GraphicsContext g2d) {
// fill it in
g2d.setFill(Paint.valueOf("WHITE"));
g2d.fillRect(0, 0, width, height);
// draw bordere
g2d.setStroke(Paint.valueOf("BLACK"));
g2d.setLineWidth(1);
g2d.strokeRect(0, 0, width, height);
}
示例6: drawExportArea
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public static void drawExportArea(GraphicsContext g, Rectangle2D area)
{
g.setStroke(COLOR_EXPORT_AREA);
g.setLineWidth(EXPORT_LINE_WIDTH);
g.strokeRect(area.getMinX(), area.getMinY(),
area.getWidth(), area.getHeight());
}
示例7: draw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void draw(DungeonTileRenderer renderer, GraphicsContext g)
{
double dx = (1 - this.size) * 0.5;
double dy = (1 - this.size) * 0.5;
drawBlock(renderer, g, this.mainPaint, dx, dy, 1 - dx - dx, 1 - dy - dy);
if (this.outlinePaint != null)
{
g.setStroke(this.outlinePaint);
}
g.setLineWidth(OUTLINE_WIDTH);
g.strokeRect(dx, dy, 1 - dx - dx, 1 - dy - dy);
}