Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@svgdotjs/svg.select.js
Advanced tools
An extension of svg.js which allows to select elements with mouse
An extension of svg.js which allows to select elements with mouse
For a demo see http://svgdotjs.github.io/svg.select.js/
Install svg.js
and svg.select.js
using npm:
npm i @svgdotjs/svg.js @svgdotjs/svg.select.js
Or get it from a cnd:
<script src="https://unpkg.com/@svgdotjs/svg.js"></script>
<script src="https://unpkg.com/@svgdotjs/svg.select.js"></script>
Select a rectangle using this simple piece of code:
var canvas = new SVG().addTo('body').size(500, 500)
canvas.rect(50, 50).fill('red').select()
Select
var canvas = SVG().addTo('body')
var rect = canvas.rect(100, 100)
var polygon = canvas.polygon([
[100, 100],
[200, 100],
[200, 200],
[100, 200],
])
rect.select()
polygon.pointSelect()
// both also works
polygon.select().pointSelect()
Unselect
rect.select(false)
Sometimes, the default shape is not to your liking. Therefore, you can create your own handles by passing in a create and update function:
rect.select({
createHandle: (group, p, index, pointArr, handleName) => group.circle(10).css({ stroke: '#666', fill: 'blue' }),
updateHandle: (group, p, index, pointArr, handleName) => group.center(p[0], p[1]),
createRot: (group) => group.circle(10).css({ stroke: '#666', fill: 'blue' }),
updateRot: (group, rotPoint, handlePoints) => group.center(p[0], p[1]),
})
polygon.pointSelect({
createHandle: (group, p, index, pointArr, handleName) => group.circle(10).css({ stroke: '#666', fill: 'blue' }),
updateHandle: (group, p, index, pointArr, handleName) => group.center(p[0], p[1]),
})
You can style the selection with the classes
svg_select_shape
- normal selectionsvg_select_shape_pointSelection
- point selectionsvg_select_handle
- any normal selection handlessvg_select_handle_lt
- left topsvg_select_handle_rt
- right topsvg_select_handle_rb
- right bottomsvg_select_handle_lb
- left bottomsvg_select_handle_t
- topsvg_select_handle_r
- rightsvg_select_handle_b
- bottomsvg_select_handle_l
- leftsvg_select_handle_rot
- rotation pointsvg_select_handle_point
- point select pointgit clone https://github.com/svgdotjs/svg.select.js.git
cd svg.select.js
npm install
npm run dev
create
and update
functions
pointSelect
FAQs
An extension of svg.js which allows to select elements with mouse
We found that @svgdotjs/svg.select.js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.