-
Notifications
You must be signed in to change notification settings - Fork 479
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
Artist draw pattern backward #20989
Merged
Merged
Artist draw pattern backward #20989
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e724825
work is still in progress
nkiruka 3ee4c7e
work in progress
nkiruka 0948cd2
testing artist drawing backward
nkiruka ce524cd
passing test for moving backward
nkiruka 583ed86
Passing test for artist draws pattern forward
nkiruka 3badbd9
Removed whitespace
nkiruka 2c696fd
Merge remote-tracking branch 'origin/staging' into artist-draw-patter…
nkiruka c7ecf29
Change x coordinate start point for clipping image when drawing backw…
nkiruka 319b1c7
Update draw pattern tests
nkiruka File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 |
---|---|---|
|
@@ -228,6 +228,10 @@ class Visualization { | |
this.turtleFrame_ = 0; | ||
} | ||
|
||
clipImage() { | ||
|
||
} | ||
|
||
// Helper for creating canvas elements. | ||
createCanvas_(id, width, height) { | ||
var el = document.createElement('canvas'); | ||
|
@@ -547,15 +551,24 @@ class Visualization { | |
// Need to subtract 90 to accommodate difference in canvas vs. Turtle direction | ||
this.ctxScratch.rotate(this.degreesToRadians_(this.heading - 90)); | ||
|
||
if (img.width !== 0) { | ||
this.ctxScratch.drawImage(img, | ||
// Start point for clipping image | ||
0, 0, | ||
// clip region size | ||
distance + img.height / 2, img.height, | ||
// draw location relative to the ctx.translate point pre-rotation | ||
-img.height / 4, -img.height / 2, | ||
distance+img.height / 2, img.height); | ||
if ((distance > 0) && (img.width !== 0)) { | ||
this.ctxScratch.drawImage(img, | ||
// Start point for clipping image forward | ||
0, 0, | ||
// clip region size | ||
distance, img.height, | ||
// draw location relative to the ctx.translate point pre-rotation | ||
-img.height / 4, -img.height / 2, | ||
distance+img.height / 2, img.height); | ||
} else if ((distance < 0) && (img.width !== 0)) { | ||
this.ctxScratch.drawImage(img, | ||
// Start point for clipping image backward | ||
img.width, 0, | ||
// clip region size | ||
distance, img.height, | ||
// draw location relative to the ctx.translate point pre-rotation | ||
-img.height / 4, -img.height / 2, | ||
distance+img.height / 2, img.height); | ||
} | ||
|
||
this.ctxScratch.restore(); | ||
|
@@ -902,6 +915,7 @@ Artist.prototype.afterInject_ = function (config) { | |
var visualization = document.getElementById('visualization'); | ||
visualization.appendChild(this.visualization.displayCanvas); | ||
|
||
// TODO (br-pair): - pull this out? | ||
if (this.studioApp_.isUsingBlockly() && this.isFrozenSkin()) { | ||
// Override colour_random to only generate random colors from within our frozen | ||
// palette | ||
|
@@ -1510,7 +1524,7 @@ Artist.prototype.step = function (command, values, options) { | |
result = this.calculateSmoothAnimate(options, distance); | ||
tupleDone = result.tupleDone; | ||
this.visualization.setHeading(heading); | ||
this.visualization.jumpForward(result.distance); | ||
this.jumpForward(result.distance); | ||
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. This changed with Josh's recent refactoring, it should be |
||
break; | ||
case 'RT': // Right Turn | ||
distance = values[0]; | ||
|
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
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.
It looks like you didn't end up using this function, so you can remove it.