Ask your own question, for FREE!
LaTeX Practicing! :) 11 Online
geerky42 (geerky42):

Not really LaTeX related, but... How can I modify image size in canvas? @rational

geerky42 (geerky42):

For example if I want to put this (attachment) into canvas;

geerky42 (geerky42):

|dw:1432454414010:dw|

OpenStudy (rational):

|dw:1432454439414:dw|

geerky42 (geerky42):

Yeah/ how did you do that?

OpenStudy (rational):

earlier script is automatically resizing the image to 500x300 creating that blur

OpenStudy (rational):

one sec il put the updated script

OpenStudy (rational):

you may have to refresh the page before getting that script in console

geerky42 (geerky42):

It works, thanks! |dw:1432454806261:dw|

OpenStudy (rational):

it is very easy to play wid canvas i can show u if u know a bit of javascript

geerky42 (geerky42):

I do know a bit of javascript, but this doesn't look short and nice haha. http://assets.openstudy.com/updates/attachments/556184f6e4b0e23384b8d22f-rational-1432454693607-draw.js then again I am not familiar using javascript on canvas.

OpenStudy (rational):

Ahh thats because i have minified it so that it loads faster

OpenStudy (rational):

try this in console: ``` var canvas = $('#drawing-dialog .canvas').data()["whiteboard"].canvas; ```

OpenStudy (rational):

open drawing board before typing that

OpenStudy (rational):

that gives you the canvas object now we can draw anything we want using that object

OpenStudy (rational):

for example, to draw a circle, we do : ``` canvas.circle(100, 100, 50); ```

geerky42 (geerky42):

woah

OpenStudy (rational):

is it working

geerky42 (geerky42):

yeah it does

OpenStudy (rational):

pretty easy

OpenStudy (rational):

to insert an image try this : ``` canvas.image(url, x, y, width, height); ```

geerky42 (geerky42):

What do you enclose URL with? quote, right? because it doesn't work?

OpenStudy (rational):

yes double quotes, example canvas.image(" http://assets.openstudy.com/updates/attachments/556184f6e4b0e23384b8d22f-geerky42-1432454398350-123-thumbnail.png ", 0, 0, 500, 500);

geerky42 (geerky42):

Still doesn't work. Error is "Cannot read property 'image' of null"

OpenStudy (rational):

after opening drawing board, did u assign "canvas" variable again ?

OpenStudy (rational):

type below two commands after opening drawing board : ``` var canvas = $('#drawing-dialog .canvas').data()["whiteboard"].canvas canvas.image(" http://assets.openstudy.com/updates/attachments/556184f6e4b0e23384b8d22f-geerky42-1432454398350-123-thumbnail.png ", 0, 0, 500, 500); ```

geerky42 (geerky42):

ahh I see. now it works.

OpenStudy (rational):

it creates a fresh canvas everytime u click draw so canvas variable needs to be updated

geerky42 (geerky42):

oh I see. I need to go now... Thanks for all helps!|dw:1432455932330:dw|

OpenStudy (rational):

np for more info look at raphaeljs documentation http://raphaeljs.com/reference.html#Paper.image

TheSmartOne (thesmartone):

Ahhh, thanks again @rational for the amazing work :D

OpenStudy (bloomlocke367):

DEAN!!!!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!