Hello ,
Can anyone give me an efficient way to do Rect/Polygon filling as below/Attachment .

 ![Patterns.png](/attachments/small/3/13ab1a68a958648cc9313476241adfb2.png "align-left")  ![Patterns.png](/attachments/large/3/13ab1a68a958648cc9313476241adfb2.png "align-center") 

as of now I'm drawing lines & single pixel rectangles to do this and my application has slowed down
so I'm looking for an alternative .

This is an extension to my earlier discussion , now I cant use texture paint due to offset issues !
https://www.daniweb.com/software-development/java/threads/497457/fillpolygon-code-from-graphics

  • Nataraja G

What offset issues? You are unlikely to find anything faster than the standard API method, so the best approach is to work with it. Have you tried creating a transparent BufferedImage for the fill as I explained in your other post?

Hi James ,

"Have you tried creating a transparent BufferedImage "
not yet due to below reason , I've kept this on hold .

"What offset issues?"

Actually I've multiple objects ( different color ) overlapping on each other and I've a requirement that whereever this happens visually they have to be similar

If I use texturePaint , lets say 45degree line on 8x8 pixel
this will always start from 8th pixel
case1 - if the overlapped object is offseted by 1-2 pixels there will two different lines
case2 - if the overlapped object's offset is 8 pixels , lines of these two objects will merge and resulting effect is different

I can dynamically create TexturePaints so that everytime overlayed area will be like case2 but I don't think it is efficient as I've more than 10million rectangles & polygons to be drawn on JPanel .

I need these 45degree lines to be consistant no matter what the offset of object is , for this to happen I've assumed top left corner as orgin and calculated initial offset for these objects ( like first intersection point of family of lines )

I'm develiping a EDA tool for ChipDesigning all these objects are interconnects and Gates on Silicon .

  • Nataraja G