首页 \ 问答 \ 在HTML Canvas中定位绘制的形状(Positioning drawn shape in HTML Canvas)

在HTML Canvas中定位绘制的形状(Positioning drawn shape in HTML Canvas)

我有一个复杂的形状,它是从SVG文件生成的,我们正在将图像剪切到画布中。

但是,所有贝塞尔曲线坐标都基于0,0。 我们的形状尺寸根据画布的大小(根据用户的屏幕宽度进行缩放)来缩放。

有没有办法采取已经绘制的形状,然后将其移动到画布上的某个位置? 就像ctx.scale(#,#)会缩放绘制的形状一样?

谢谢!


I have a complex shape that's been generated from an SVG file that we're clipping images to in canvas.

However, all of the bezier curve coordinates are based on 0,0. Our shape's size scales depending on the size of the canvas (which scales based on the user's screen width).

Is there a way to take the shape that's already been drawn and then move it to a certain position on the canvas? Much like ctx.scale(#, #) will scale the drawn shape?

Thanks!


原文:https://stackoverflow.com/questions/38122085
更新时间:2023-11-07 06:11

最满意答案

对于可能面临同样问题的人,这可能会有所帮助:

Model :: delete()可以删除多个记录。

[
    'id' => 1,
    'category_id' => 3,
    'price' => 10000,
]

会生成

DELETE FROM elements WHERE id IN (1, 3, 10000).

For somebody that can face the same problem this could help:

Model::delete() can delete multiple records.

[
    'id' => 1,
    'category_id' => 3,
    'price' => 10000,
]

Will generate

DELETE FROM elements WHERE id IN (1, 3, 10000).

相关问答

更多
  • 对于可能面临同样问题的人,这可能会有所帮助: Model :: delete()可以删除多个记录。 [ 'id' => 1, 'category_id' => 3, 'price' => 10000, ] 会生成 DELETE FROM elements WHERE id IN (1, 3, 10000). For somebody that can face the same problem this could help: Model::delete() can delete ...
  • 您必须将Security组件添加到控制器的$ components数组中: public $ components = array('Security'); 当您使用表单助手创建表单时,CakePHP会自动为您的表单添加一个随机数。 You have to add the Security component to the $components array of your controller(s): public $components = array('Security'); CakePHP will ...
  • 也许是因为你没有运行sqlserver? Wamp配置了apache / MySQL ...因此WAMP的首字母缩略词...... 在这种情况下,您的配置文件应该类似于此示例中给出的配置文件... http://book.cakephp.org/2.0/en/development/configuration.html In the end, i've found the solution. It's the problem of WAMPP server. Tho i have it installed ...
  • 通过在bootstrap.php中使用CakePlugin::load()加载插件解决了我的问题,但我不知道为什么CakePlugin::loadAll()没有加载它。 CakePlugin::loadAll(); CakePlugin::load('Migrations'); By loading the plugin using CakePlugin::load() in bootstrap.php solved my problem, but I don't know why CakePlugin: ...
  • 我无法得到上面的帮助,所以我尝试了CakeDC制作的这个插件解决了这个问题: https : //github.com/CakeDC/TinyMCE 在app / plugin目录中提取文件后,您只需要在控制器中添加一个类似于以下内容的帮助程序: public $helpers = array('TinyMCE.TinyMCE'); 在/app/config/bootstrap.php文件中,我添加了: CakePlugin::load('TinyMCE'); ... Configure::write ...
  • 在保存数据之前,请从阵列中删除空的值。 foreach ($this->request->data as $key => $value) { if (empty($value)) unset($this->request->data[$key]); } if ($this->User->save($this->request->data)) { return $this->User->id; } Before saving your data, remove your em ...
  • 将其用作.gitignore文件的内容 /vendor/* /config/app.php /tmp/* /logs/* .htaccess /webroot/.htaccess 这样只有你的相关文件将被git推送。 如果你提交你的composer.lock文件,那么你可以使用composer所包含的所有包的相同版本。 Use this as the content of your .gitignore file /vendor/* /config/app.php /tmp/* /logs/* .ht ...
  • 您需要恢复PagesController所有代码,并将静态页面路由到display方法。 You need to restore all codes of PagesController, and route static pages to display method.
  • 查看源代码,看起来这可能是一个错误或预期的行为。 CookieComponent类有一个内部__values数组,用于跟踪cookie信息。 如果你调用delete('User.email'),它将从__values数组中删除'User'索引,包括索引下的所有数据。 但是,它只会取消设置名为“用户”的cookie。 下次Cake启动时,会看到名为“User.email”的cookie仍然存在并将其加载回__values数组。 假设它不是预期的行为,我写了一个修复程序,我将继续将其提交给Cake团队。 Loo ...
  • 解: core.php中 配置::写( 'Exception.handler', 'AppErrorHandler :: handleException'); bootstrap.php中 App :: uses('AppErrorHandler','Lib'); 使用以下函数在Lib文件夹中添加AppErrorHandler类 public static function handleException(Exception $exception) { if($exception instanceo ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。