在JavaFX中使用Canvas绘图(Drawing with Canvas in JavaFX)
想象一下,你有一个
canvas
实例Canvas canvas = new Canvas();
我想用
GraphicsContext
绘制一些pieces
GraphicsContext gc = canvas.getGraphicsContext2D();
这种方法具有创建
round pieces
的功能,此部分的Color
无关紧要,实际上该方法绘制一个circle
,其中需要根据目标对绘图进行一些调整public void drawRoundPiece(GraphicsContext gc) { gc.setFill(Color.BLUE);//text color gc.setStroke(Color.BLUE);//text color gc.fillOval(50, 50, 50, 50); gc.strokeOval(50, 50, 50, 50); gc.fill(); gc.stroke(); }
这种方法具有
circle in middle
创建带circle in middle
square pieces
的功能,该部分的Color
无关紧要,实际上该方法绘制了一个square
,其中需要根据目标对绘图进行一些调整。public void drawSquarePiece(GraphicsContext gc) { gc.setFill(Color.YELLOW);//text color gc.setStroke(Color.YELLOW);//text color gc.fillRoundRect(100, 10, 50, 50, 10, 10); gc.fill(); gc.stroke(); }
而目标就是将图像画成画面
任何帮助?
Imagine, you have a
canvas
instanceCanvas canvas = new Canvas();
and I wanna draw some
pieces
withGraphicsContext
GraphicsContext gc = canvas.getGraphicsContext2D();
This method has the functionality of creating
round pieces
, theColor
of this part does not matter and in fact the method draws acircle
, in which it needed some adjustment for the drawing to go according to the objectivepublic void drawRoundPiece(GraphicsContext gc) { gc.setFill(Color.BLUE);//text color gc.setStroke(Color.BLUE);//text color gc.fillOval(50, 50, 50, 50); gc.strokeOval(50, 50, 50, 50); gc.fill(); gc.stroke(); }
This method has the functionality of creating
square pieces
withcircle in middle
, theColor
of this part does not matter and in fact the method draws asquare
, in which it needed some adjustment for the drawing to go according to the objectivepublic void drawSquarePiece(GraphicsContext gc) { gc.setFill(Color.YELLOW);//text color gc.setStroke(Color.YELLOW);//text color gc.fillRoundRect(100, 10, 50, 50, 10, 10); gc.fill(); gc.stroke(); }
and the objetive is draw the pieces like image in down
any help?
原文:https://stackoverflow.com/questions/41970863
最满意答案
这是一个已知问题,实际上仍然是一个开放的问题。 有几种方法可以让您的工作如预期。 您可以在项目问题跟踪器上阅读它: select / ngOptions在键盘选择后无法更新模型 。 作为解决方法,您可以在
<select>
放置一个空的<option>
<select>
。 观察以下变化......<select ng-model="selected" ng-options="person.name for person in people track by person.id" ng-change="selectionChanged()"> <option value=""></option> </select>
JSFiddle Link - 更新的演示
This is a known issue, and in fact, is still an open one. There are a few ways to get this working how you would expect. You can read about it on the project issue tracker here: select/ngOptions fails to update model after keyboard selection. As a workaround, you can place an empty
<option>
within your<select>
. Observe the following change...<select ng-model="selected" ng-options="person.name for person in people track by person.id" ng-change="selectionChanged()"> <option value=""></option> </select>
JSFiddle Link - updated demo
相关问答
更多-
在Foundation for Apps中,选择时不会触发ng-change(ng-change isn't firing on select in Foundation for Apps)[2022-04-12]
将您的代码更改为此,忘记在HTML页面中包含控制器