-
Notifications
You must be signed in to change notification settings - Fork 209
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
attempting webgl-distort #1022
attempting webgl-distort #1022
Conversation
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #1022 +/- ##
=========================================
- Coverage 37.04% 35.5% -1.55%
=========================================
Files 100 102 +2
Lines 1857 1946 +89
Branches 291 298 +7
=========================================
+ Hits 688 691 +3
- Misses 1169 1255 +86
|
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
Oh silly me!! I put the code to run it in onload which was running it again and again! I fixed it! |
cc @VibhorCodecianGupta |
Does this run in node environment as well? In theory, i mean. Is it supported? |
Yes this is running just fine in node. :D |
@tech4GT sweet, this works perfectly. The next steps could be:
Do you have any other improvements in mind? |
Okay Vibhor, that sounds great, would you like to implement the custom options part? |
@VibhorCodecianGupta Once you are done make a pull request at my branch! Thanks! |
Will do. |
So, for initial implementation, i think we should have x,y for all four corners, because one main use case is MapKnitter.org exporting. But i agree, we may think of other UIs that will be better -- and eventually, we could even have a "dragging" UI similar to https://github.com/publiclab/Leaflet.DistortableImage/ -- although that's a big project!!! |
Awesome. Working on x,y coordinates and the angle approach now. |
Does it still generate images cut off if it goes outside the original canvas? This is so rad!!!!!!!!! |
I do think we should protect this with a test, esp. for how complex it is. Vibhor, did you want to try that too? Once we have a test, we should feel comfortable swapping the webgl-distort library to source via NPM (although we can attempt it in a follow-up PR!) What do you think? |
Sounds good. I'll write the tests along as well. So this PR will be the custom inputs and test cases. |
Good work Vibhor!! Yeah you won't be able to push directly! Push to your fork and make a pull request from there to my branch. |
@tech4GT actually, I just did. My rebase commits and custom input code are all in your branch now. I apparently had to name my local branch the same as yours. Is that a problem, should I just make a PR instead? |
Oh, if you are able to push then that's fine! |
@@ -0,0 +1,230 @@ | |||
/* | |||
* Resolves Fisheye Effect |
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.
I think this isn't the correct description.
/* | ||
* Resolves Fisheye Effect | ||
*/ | ||
module.exports = function DoNothing(options, UI) { |
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.
function DoNothing
? 😂
try { | ||
var canvas = fx.canvas(1500, 1500); | ||
} catch (e) { | ||
alert(e); |
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.
How about an alet that says "Not Supported" instead of just throwing the error. It will mostly be gibberish (i guess).
var defaults = require('./../../util/getDefaults.js')(require('./info.json')); | ||
|
||
var output; | ||
var fx = require('./glfx') |
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.
Why is it added to npm if it is included from the module folder?
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.
@tech4GT pointed out how the npm distribution wasn't working for him, so he put the script in. For now, the script is utilised but let's not remove the npm dist either
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.
Ok
@VibhorCodecianGupta what do the negative coordinates indicate? Is the center of the image (0, 0)? |
Look at the img. It has anti-aliasing problems. Is it because of the library(webgl-distort)? Can it be fixed? |
Oh wait. The library is added to npm but never used? |
Are they relative to the original coords? |
No, they are absolute. 0,0 is the top left corner of the image. |
If (0,0) is the top left, will a negative coordinate lie outside the image/canvas? |
@harshkhandeparkar pull the branch and try it out locally once, you'll understand how it'll work. If you find some odd behaviour, let us know here |
Can you or someone publish it to your github pages? I don't have my pc right now. I will only be able to use it tmrw or the day after |
By the way, can't the image be anti alliased during the rasterisation stage? |
Also, from what I have tried out, it works in a relative fashion. The image will not overflow out of the canvas, the coordinates adjust themselves so that the maximum value of a point will be inside the canvas and every other point will be placed relatively. I'll check the anti-aliasing |
Ok |
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.
Cool, just a few things noted here! Great work!!!
test/core/modules/webgl-distort.js
Outdated
}; | ||
var target = 'test_outputs'; | ||
var red = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABlBMVEX+AAD///+KQee0AAAAAWJLR0QB/wIt3gAAAAd0SU1FB+EGHRIVAvrm6EMAAAAMSURBVAjXY2AgDQAAADAAAceqhY4AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMDYtMjlUMTg6MjE6MDIrMDI6MDDGD83DAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTA2LTI5VDE4OjIxOjAyKzAyOjAwt1J1fwAAAABJRU5ErkJggg=="; | ||
var benchmark = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAH0lEQVQ4T2NkoBAwUqifYdQAhtEwYBgNA1A+Gvi8AAAmmAARf9qcXAAAAABJRU5ErkJggg=="; |
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.
Hi! Hmm, not sure; is this supposed to show anything? I tried opening it in a browser but don't see an image.
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.
I do see a small grey-ish 16x16 pixel img.
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.
I'll check it out!
test/core/modules/webgl-distort.js
Outdated
// Test 2 to check options are correct | ||
test('Check Options', function(t) { | ||
t.equal(sequencer.steps[1].options.nw, '0 100', 'Options are correct'); | ||
t.equal(sequencer.steps[1].options.ne, '1023 50', 'Options are correct'); |
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, that's a really big distortion; it's a very tiny image; could we just say something under 100?
Also, would it be possible to pass comma-separated values rather than space-separated? I think it'll render better in a URL, don't you think?
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.
Agreed, comma separated it is, then
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.
Comma separated values can have spaces as well. We have to replace those as well using regex. A better approach would be to do both. We can first separate it at spaces, then remove all commas, if there are no spaces, separate at commas.
Let's bump the version number to 3.2.0, too! I'm about to publish 3.1.0. |
I'll rectify these, then the following bump will support gl-context, fix the crop module bug and support various input methods. Sweet! It'll be of great help here |
Just noting that i had already released |
test/core/modules/webgl-distort.js
Outdated
ne: '1023 50', | ||
se: '1223 867', | ||
sw: '100 767' | ||
nw: '0 0', |
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.
These coords aren't space separted. Shouldn't they be?
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.
You are too fast.
module.exports = function parseDistortCoordinates(options) { | ||
|
||
let coord = [] | ||
coord.push(options.nw.split(',')) |
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.
I think we can also replace any spaces using regex.
Awesome, perfect! I can publish to NPM if you bump the version too. |
|
Yep! |
@jywarren version bumped, distort working. IS is maturing! |
Amazing!!! |
Publishing to NPM too! |
@jywarren As of now the image sort of falls out of the canvas, after the module runs, can you try this and see how the inputs need to be changed for a sizeable demo.