private fun leftEdge(image: java.awt.image.BufferedImage): Shape? { val path: java.awt.geom.GeneralPath = java.awt.geom.GeneralPath() var p1: java.awt.geom.Point2D? = null var p2: java.awt.geom.Point2D? = null val line: java.awt.geom.Line2D = java.awt.geom.Line2D.Float() var p: java.awt.geom.Point2D = java.awt.geom.Point2D.Float() var foundPointY = -1 for (i in 0 until image.getHeight()) { for (j in 0 until image.getWidth()) { if (image.getRGB(j, i) and -0x1000000 != 0) { p = java.awt.geom.Point2D.Float(j, i) foundPointY = i break } } if (foundPointY >= 0) { if (p2 == null) { p1 = java.awt.geom.Point2D.Float(image.getWidth() - 1, foundPointY) path.moveTo(p1.getX(), p1.getY()) p2 = java.awt.geom.Point2D.Float() p2.setLocation(p) } else { p2 = detectLine(p1, p2, p, line, path) } } } path.lineTo(p.getX(), p.getY()) if (foundPointY >= 0) { path.lineTo((image.getWidth() - 1).toFloat(), foundPointY.toFloat()) } path.closePath() return path }
trace the left side of the image