Skip to content

Commit

Permalink
Fix rasterization
Browse files Browse the repository at this point in the history
  • Loading branch information
JD557 committed Sep 7, 2024
1 parent b7334d0 commit e14caf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ final case class ConvexPolygon(vertices: Vector[Shape.Point]) extends Shape {
.sum

def faceAt(x: Int, y: Int): Option[Shape.Face] = {
val sides = rawWeights(x, y).map(_ >= 0).distinct.toVector
val sides = rawWeights(x, y).filter(_ != 0).map(_ >= 0).distinct.toVector
if (sides.size == 1) {
if (sides.head) Shape.someFront else Shape.someBack
} else None
}

override def contains(x: Int, y: Int): Boolean = {
rawWeights(x, y).map(_ >= 0).distinct.size == 1
rawWeights(x, y).filter(_ != 0).map(_ >= 0).distinct.size == 1
}

/** Checks if this polygon contains another polygon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ trait MutableSurface extends Surface {
* @param frontfaceColor color of the front face
* @param backfaceColor color of the back face
* @param blendMode blend strategy to use
* @param x position of the shap origin on the destination surface
* @param y position of the shap origin on the destination surface
* @param x position of the shape origin on the destination surface
* @param y position of the shape origin on the destination surface
*/
def rasterize(
shape: Shape,
frontfaceColor: Option[Color],
backfaceColor: Option[Color] = None,
blendMode: BlendMode = BlendMode.Copy
)(x: Int, y: Int): Unit = {
Rasterizer.rasterizeShape(this, shape.translate(-x, -y), frontfaceColor, backfaceColor, blendMode)
Rasterizer.rasterizeShape(this, shape.translate(x, y), frontfaceColor, backfaceColor, blendMode)
}

/** Modifies this surface using surface view transformations
Expand Down

0 comments on commit e14caf0

Please sign in to comment.