unity 调整画布大小
It's a massive honor to have Tom "Trenkavision" Trenka write a guest post for this blog. Tom was one of the original contributors of the Dojo Toolkit and my mentor at SitePen. I've seen his genius first hand and he's always the first one to foresee issues with a potential solution. He also thinks outside the box, coming up with unconventional but reliable solutions to edge case problems. This is a perfect example.
让Tom“ Trenkavision” Trenka为这个博客写客座帖子,这是非常荣幸。 Tom是Dojo Toolkit的原始作者之一,也是我在SitePen的导师。 我亲眼目睹了他的天才,他始终是第一个预见到具有潜在解决方案问题的人。 他还开创了思路,提出了解决边缘案例问题的非常规但可靠的解决方案。 这是一个完美的例子。
Recently I was asked to create a user interface that allows someone to upload an image to a server (among other things) so that it could be used in the various web sites my company provides to its clients. Normally this would be an easy task—create a form with a File input, let someone navigate to the image in question on their computer, and upload it using multipart/form-data
as the enctype
in the form
tag. Simple enough, right? In fact, there's a simple enough example right on this site.
最近,有人要求我创建一个用户界面,该界面允许某人将图像上传到服务器(除其他外),以便可以在公司向其客户提供的各种网站中使用该图像。 通常,这是一项容易的任务-使用文件输入创建表单,让某人导航到计算机上有问题的图像,然后使用multipart/form-data
作为form
标签中的enctype
上载该图像。 很简单,对不对? 实际上, 此站点上有一个足够简单的示例。
But what if you had pre-prepare that image in some way? In other words, what if you had to resize that image first? What if you needed that image to be a particular file type, like a PNG or a JPG? Canvas to the rescue!
但是,如果您已经以某种方式预先准备了该图像怎么办? 换句话说,如果必须先调整该图像的大小怎么办? 如果您需要将该图像设为特定的文件类型(如PNG或JPG),该怎么办? 帆布救援!
什么是画布? (What is the Canvas?)
The Canvas is a DOM element, added in HTML5, that allows a user to draw graphics directly in a page, usually through Java