-
Notifications
You must be signed in to change notification settings - Fork 785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Line Retool #682
Merged
Merged
Line Retool #682
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c94f65c
Improves performance of line tool for large pen sizes.
smiegrin e4009ab
Merge branch 'lineRetool'
smiegrin 2662a03
Adjusts lineTool ends to square shape.
smiegrin 55f39a1
Merge branch 'lineRetool'
smiegrin b3948ab
Adds comments to Stroke tool for drawing lines.
smiegrin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,8 +97,31 @@ | |
linePixels = pskl.PixelUtils.getLinePixels(col, this.startCol, row, this.startRow); | ||
} | ||
|
||
pskl.PixelUtils.resizePixels(linePixels, penSize).forEach(function (point) { | ||
targetFrame.setPixel(point[0], point[1], color); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Below, I implement a (potentially verbose) procedural diamond at each end of the line. It is accomplished by conditionally coloring a square on the basis of the taxicab distance from the center of a square. |
||
//draw the square ends of the line | ||
pskl.PixelUtils.resizePixel(linePixels[0].col, linePixels[0].row, penSize) | ||
.forEach(function (point) {targetFrame.setPixel(point[0], point[1], color);}); | ||
pskl.PixelUtils.resizePixel(linePixels[linePixels.length - 1].col, linePixels[linePixels.length - 1].row, penSize) | ||
.forEach(function (point) {targetFrame.setPixel(point[0], point[1],color);}); | ||
|
||
//for each step along the line, draw an x centered on that pixel of size penSize | ||
linePixels.forEach(function (point) { | ||
for (var i = 0; i < penSize; i++) { | ||
targetFrame.setPixel( | ||
point.col - Math.floor(penSize / 2) + i, point.row - Math.floor(penSize / 2) + i, color | ||
); | ||
targetFrame.setPixel( | ||
point.col - Math.floor(penSize / 2) + i, point.row + Math.ceil(penSize / 2) - i - 1, color | ||
); | ||
//draw an additional x directly next to the first to prevent unwanted dithering | ||
if (i !== 0) { | ||
targetFrame.setPixel( | ||
point.col - Math.floor(penSize / 2) + i, point.row - Math.floor(penSize / 2) + i - 1, color | ||
); | ||
targetFrame.setPixel( | ||
point.col - Math.floor(penSize / 2) + i, point.row + Math.ceil(penSize / 2) - i, color | ||
); | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I exchange the square-style resize for a cross-shape resize in lines 124-129.