java - Creating 3x3 checkerboard over a picture using Graphics2D -



java - Creating 3x3 checkerboard over a picture using Graphics2D -

i want create overlay of 3x3 checkerboard, non-solid squares should transparent.

i don't want iterate pixels, rather draw squares using graphics2d create checkerboard. (do need loop, if statement, or both?) here's code far:

picture mypict = new picture(mypathname); mypict.show(); graphics2d graphicsobj = mypict.getgraphics2d(); final int width = mypict.getwidth() / 3; final int height = mypict.getheight() / 3; (int = 0; > width; = width * 2) { rectangle2d.double shape1 = new rectangle2d.double(width, height, 0, 0); graphicsobj.draw(shape1); }

i'd utilize combined (double) loop/if statement drawing solid parts of checkerboard. in pseudo-code might expressed as:

draw image each row { each column { if 'odd' square number { graphics fill rectangle } } }

java awt graphics2d

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -