2

I'm working on JavaFx canvas. I can have a GraphicsContext object called 'gc'.

GraphicsContext gc = canvas.getGraphicsContext2D();

I can set regular fill color for it as

gc.setFill(Color.GREEN);

But I really want is HATCHED green color as the fill. But I couldn't found appropriate java class to get Hatched Colors. Can anybody help me please?

Hera is an Example for hatched patterns(color=black in this case):- An Example for hatched patterns(color=black in this case)

Lakshitha Kanchana
  • 844
  • 2
  • 12
  • 32
  • 1
    relevant: [JavaFx equivalent of C# .Net HatchStyles](http://stackoverflow.com/questions/39297719/javafx-equivalent-of-c-sharp-net-hatchstyles) – Omid Jan 10 '17 at 18:53
  • 2
    Also related (though different): [Resizable Grid using Canvas](http://fxexperience.com/2014/05/resizable-grid-using-canvas/). – jewelsea Jan 10 '17 at 18:58
  • The duplicate is about JavaFX, not C# – jewelsea Jan 12 '17 at 06:04

1 Answers1

1

Set the fill to an ImagePattern, or a Gradient to achieve the hatch.

jewelsea
  • 150,031
  • 14
  • 366
  • 406