Commit graph

5609 commits

Author SHA1 Message Date
Jürg Lehni
9cafb6d55f Only set src attribute if it’s not empty
window.Image does not support clearing the attribute by setting it to null
2019-06-05 17:35:21 +02:00
Jürg Lehni
de36f39cbf Fix Raster#clear() to propagate content change 2019-06-05 15:31:09 +02:00
Jürg Lehni
ea91efe810 Add Raster.clear() to clear associated canvas 2019-04-11 19:38:19 +02:00
Jürg Lehni
e436d44f14 Allow new Raster(size) constructor 2019-04-11 19:38:19 +02:00
Jürg Lehni
fcfebdc43b Include Raster.context accessor 2019-04-11 19:38:19 +02:00
sapics
be4199b6eb Update copyright year to 2019 2018-12-27 16:13:01 +09:00
DD Liu
f6b8f8e309 Set preserve spaces, and insert spaces on blank lines when exporting text from paint. This makes render show the right thing. 2018-12-18 16:43:09 -05:00
sapics
5904a288e7 Fix css color parse 2018-12-14 11:44:24 +01:00
sasensi
449c5c3e6d Fix Tween#then() documentation.
Bug introduced in 9c684091f4: example
variable was renamed from `item` to `circle` in declaration but later
calls were still done with `item`.
2018-12-03 15:04:22 +01:00
sasensi
a7c2fb3ddf Improve Color.random() documentation. 2018-12-03 14:46:50 +01:00
sasensi
bbd65324bc Add typescript definition generation
This add a gulp task (`gulp docs:typescript`) to automatically generate
a typescript definition for the library. This should solve the problem
of having an out of sync type definition when we change the API.

This task takes advantage of existing JSDoc parsing to generate a
temporary file which is later formatted through a mustache template to
generate the final definition. This definition is then tested by
compiling a typescript file that use it.
The generated definition is added to the `gulp zip` task in order to be
published along with the bundled library.

So 2 new dev-dependencies are added with this change: `mustache` and
`typescript` packages. Using node and mustache to generate the
definition instead of relying on existing templating system is
motivated by a better development experience, with easier debugging
possibilities... through the usage of more modern tools.

As a side note, support of "rest parameters" (when a parameter can be
present multiple times) is added to existing JSDoc parser in order to
support this pattern on typescript side (E.g. for `Color#set()` method
which accept any sequence of parameters that is supported by `Color`
constructors).
2018-12-03 14:41:47 +01:00
Jürg Lehni
a66391678e Release version 0.12.0 2018-12-03 14:26:23 +01:00
Jürg Lehni
4a5f558057 Some minor tween example changes 2018-12-03 13:59:51 +01:00
Jürg Lehni
9c684091f4 Move Tween class to anim namespace + changes
- Change from item to object, as it can be used to tween any property on any object really
- Make _handleFrame() private
- Minor documentation tweaks
2018-12-03 12:51:31 +01:00
sasensi
a97382d1c5 Document tween update event as Tween#onUpdate. 2018-12-03 09:44:37 +01:00
sasensi
6d411e9b7f Add Tween documentation 2018-11-30 15:10:31 +01:00
sasensi
f2b6e67bcb Fix Item#tweenFrom() documentation example.
Example code was not matching example title.
2018-11-30 12:07:01 +01:00
sasensi
266cf365f5 Fix Item#tween() documentation. 2018-11-30 11:50:10 +01:00
Jürg Lehni
e52a33b9cb Fix linting errors 2018-11-29 14:10:08 +01:00
arnoson
684f504930 Implement tweening 2018-11-29 12:04:03 +01:00
Jürg Lehni
d46b6cbef4 Fix Emitter.once() 2018-11-28 11:40:17 +01:00
Jürg Lehni
b1705f628b Fix typos 2018-11-21 11:58:22 +01:00
sasensi
a4a2fb7eef Fix various documentation problems
- typos in comments
- wrong or missing types
- missing default values
2018-11-21 11:27:51 +01:00
sasensi
b363a5cc95 Remove Line from documentation
Line class was not displayed in online documentation but it was parsed
and a file was created for it because it lacked a @private JSDoc tag.
2018-11-21 11:21:51 +01:00
sasensi
dd2c15ac83 Add documentation for Color.random() 2018-11-21 11:18:02 +01:00
sapics
531479c0a0 Add param type in raster method
Add param type in Raster#getPixel and Raster#setPixel
2018-11-20 08:44:38 +09:00
sasensi
ef7beacd8b Fix several return values documentation 2018-11-17 09:37:06 +01:00
sasensi
12731f2fd1 Fix typo in Raster#getCanvas documentation 2018-11-16 18:58:18 +01:00
sapics
cfc5a912da Replace url to avoid redirection
Replace http://jonathanpuckey.com to https://puckey.studio
2018-11-14 11:24:32 +01:00
sapics
d8f9eb8890 Replace http to https in comment
http://www.w3.org/TR/SVG/* to https://www.w3.org/TR/SVG/*
2018-11-14 11:24:04 +01:00
sapics
c219bb7345 Replace http to https in comment 2018-11-14 11:22:29 +01:00
Samuel Asensi
2968faad51 Fix empty image drawing (#1605)
Empty raster (for example coming from path with empty bound
rasterization, ...) drawing threw error.
This change prevent raster drawing in that case.
Closes #1320
2018-11-14 11:21:40 +01:00
sasensi
8202f78453 Fix typo in Color#convert documentation 2018-11-13 10:12:59 +01:00
sasensi
1462178799 Fix typo in Path(pathData) documentation
Empty parameter was resulting in `Path(pathData)` being documented as
`Path(, pathData)` with an empty first parameter.
2018-11-13 09:52:19 +01:00
sasensi
910aecb7e5 Fix CurveLocation#distance documentation
@see tag was pointing to an inherited method which is not compatible
with current jsdoc parser implementation.
Problem is resolved by making reference point to the parent class
owning the method.
2018-11-12 16:44:36 +01:00
sasensi
8b33eccd52 Fix beans documentation links
Several documentation "see also" links concerning beans were broken
because they were referenced as `ClassName#getProperty()` instead of
`ClassName#property`.
2018-11-12 16:38:34 +01:00
sasensi
0b52720bdf Fix CompoundPath#lastSegment documentation 2018-11-12 16:27:23 +01:00
sasensi
6301aeb82d Fix Raster#context documented type 2018-11-12 16:20:39 +01:00
sasensi
4f545d243b Fix unexisting type Symbol in documentation 2018-11-12 16:18:05 +01:00
sasensi
bb63310578 Fix CurveLocation#index documented type 2018-11-12 16:12:01 +01:00
sasensi
df109ab096 Fix typo in PathItem documentation
PathItem was misspelled PahtItem, breaking documentation links.
2018-11-12 16:08:04 +01:00
sasensi
d3f617b98e Fix Path#divide() documentation
Divide operation was described as subtract & subtract instead of
subtract & intersect.
2018-11-09 14:24:04 +01:00
sasensi
2e75467fb4 Fix group selected bounds and position color
Group selected color was applied differently to its bounds and position
depending on whether it had children or not when selected color was set.
This resulted in an unpredictable behaviour from a user point of view.
To change that:
- When `item.setSelectedColor()` is called, value is now always stored
in `item._style._values`, independently from the fact that item has
children or not.
- An helper method `compareCanvas()` is added to the test suite to allow
comparing selection rendering of a known working case to a failing one.
Two provided callbacks are executed in a dedicated `<canvas>`/`Project`
context and both results are compared with `resemble.js`.
2018-11-06 11:26:12 +01:00
DD
9d4ab1e38f Default raster smoothing to false for Scratch 2018-11-05 15:10:56 -05:00
sasensi
c44f56d52f Fix Rectangle documentation
Add missing return values in Rectangle boolean operations.
Closes #1399
2018-11-05 08:34:50 +01:00
DD
b1dd6fbb87 Match spacing 2018-10-25 15:31:52 -04:00
DD
f3991edc0a Fix RTL 2018-10-25 15:15:12 -04:00
DD
e893cb1325 Clean up/ 2018-10-25 14:19:45 -04:00
DD
893f85bdfe rename the bound type and fix cache flags 2018-10-25 14:19:45 -04:00
DD
f85e3a7947 Use different bounds for different situations 2018-10-25 14:19:45 -04:00
DD
edfa5aedfa Implement more accurate text measurement, but bounding boxes are totally broken and RTL needs checking 2018-10-25 14:19:45 -04:00
DD
46436c561b Merge branch 'doubleUpstreamDevelop' into mergePaper 2018-10-23 10:40:50 -04:00
DD
ab7fa1e091 Merge branch 'doubleUpstreamDevelop' into mergePaper 2018-10-23 10:16:40 -04:00
sasensi
8ce5cc97cc Minor code cleaning 2018-10-20 15:59:18 +02:00
sasensi
e9135589b1 Fix mousedrag error with in front items
When dragging item A behind item B, mousedrag event was emitted on
item B instead of mousemove.
Bug introduced in fbd5eeb
Closes #1465
2018-10-20 15:59:18 +02:00
sapics
f50a81e089 Minor code minifier
We can minify some codes which relate matrix.decompose(),
because matrix.decompose() must return non-null object
2018-10-20 15:14:41 +02:00
sasensi
bd70511b70 Add documentation for PaperScope#setup(size)
Documentation did not mention that a size can be passed as argument to
PaperScope#setup() and Project#initialize() for usage of paper.js in
web workers.
Closes #1412
2018-10-17 17:43:06 +02:00
Jürg Lehni
e5cedd3cef Release version 0.11.8 2018-10-17 17:05:40 +02:00
Jürg Lehni
3cc3ce8f13 Release version 0.11.7 2018-10-17 16:56:58 +02:00
sasensi
3fd73f92f2 Minor code refactoring 2018-10-17 14:40:05 +02:00
sasensi
1bd67b2d9b Add mouse interaction tests
- Tests common mouse interactions scenarios to prevent regressions
when making changes. These tests are not run in node context.
- Prevent name collision between Javascript native classes and Paper.js
classes (Event and MouseEvent) by patching load.js.
- Uses a polyfill for MouseEvent which is missing in PhantomJS.
- Adds View._clearState() method and use it in tests to make sure that
each new test is started with a fresh state.
2018-10-17 14:40:05 +02:00
sapics
e3ed85e395 Fix error in single segment closed path flatten 2018-10-15 11:01:51 +02:00
sapics
623c554dfe Remove PaperScript code from core version 2018-10-15 10:53:06 +02:00
sapics
3e15cf09c2 Trim space in jsdoc comment 2018-10-15 10:19:45 +02:00
Jürg Lehni
348886365a Revert "Improve use of global matrix in selected position"
This reverts commit 91d3499191.
2018-10-15 10:12:15 +02:00
Jürg Lehni
91d3499191 Improve use of global matrix in selected position
Relates to #1545
2018-10-14 23:12:03 +02:00
Takahiro Nishino
6f2d75442c Improve color parsing for 4 characters hex code (#1565) 2018-10-14 21:44:22 +02:00
Samuel Asensi
54b20c0268 Improve global matrix cache invalidation performance (#1563) 2018-10-13 19:53:45 +02:00
Jürg Lehni
70e58162f0 PaperScript: Better deal with compile exceptions 2018-10-13 18:49:54 +02:00
Jürg Lehni
d6d5accd1a Allow PaperScripts to export from their code
Supporting `export default`, named exports, as well as `module.exports`
2018-10-13 18:44:25 +02:00
Jürg Lehni
c41509479f Use separate ChangeFlag for matrix changes
See https://github.com/paperjs/paper.js/pull/1552#issuecomment-429547010
2018-10-13 16:44:35 +02:00
Jürg Lehni
c5b822da79 Improve validity check for cached global matrix
Relates to #1552, #1448
2018-10-13 16:32:53 +02:00
Samuel Asensi
8bef865892 Fix children global matrices are not cleared (#1552)
Between a parent transformation and next view update, children global
matrix was invalid, leading to wrong global coordinates calculation.
Closes #1448
2018-10-13 16:28:20 +02:00
Samuel Asensi
60f9d868a6 Fix Path#arcTo() do not pass by through point (#1543)
Closes #1477
2018-10-13 15:33:21 +02:00
Samuel Asensi
5cd1ca13c5 Fix item global matrix error (#1562)
Bug happen when item is drawn after an empty symbol that should be drawn
in a separate canvas context (partial opacity or special blend mode).
As bounds are empty, symbol drawing process is interrupted but its
global matrix is not removed from the stack.
Closes #1561
2018-10-13 14:41:38 +02:00
Jürg Lehni
5245436e36 Do not polute global scope with paper object
Closes #1544
2018-10-10 23:10:51 +02:00
Jürg Lehni
4c035ada36 Minor fixes in comments and tests. 2018-10-10 23:03:57 +02:00
Samuel Asensi
76d07892d1 Add Item#locked to documentation (#1556)
Closes #1436
2018-10-09 22:05:22 +02:00
Samuel Asensi
bca5480640 Fix first mouse drag event is emitted twice (#1553)
Closes #1447
2018-10-09 22:04:18 +02:00
Samuel Asensi
dfe4397a96 Improve hit test point documentation (#1559)
Specifies that hit test point should be provided in global coordinates
system.
Closes #1430
2018-10-09 21:44:04 +02:00
Samuel Asensi
c0abbe1459 Fix raster shadow is not drawn (#1555)
Closes #1437
2018-10-09 11:38:52 +02:00
Jürg Lehni
fd1a517e84 Improve hex Color parser
Addresses changes in #1469
2018-10-06 21:57:30 +02:00
sasensi
f7ce43a9e9 Fix item selected position with matrix not applied
Make sure selected position is drawn in global coordinates system
whether item is in a group or not and whether matrix is applied or not.
Correct a bug introduced in 34679614c0.
2018-10-06 13:15:27 +02:00
PeterLazar
a8f78859cb Add hexadecimal with alpha color parsing
Closes #1468
2018-10-05 20:14:20 +02:00
Jürg Lehni
f5366fb3cb Some minor adjustments for #1530 2018-10-05 10:01:51 +02:00
Samuel Asensi
c235d6a917 Implement Curve#getTimesWithTangent()
and Path#getOffsetsWithTangent()
2018-10-05 09:44:42 +02:00
Jürg Lehni
47af603173 Support alpha channel in named CSS colors
Closes #1539
2018-10-04 17:26:48 +02:00
Jürg Lehni
28dec90a88 Wrap up Raster#smoothing feature 2018-10-03 19:01:02 +02:00
Jürg Lehni
144370169e
Merge pull request #1529 from sasensi/Fix_#1521_adding_raster.smoothing_property
Fix #1521 adding Raster.smoothing property
2018-10-03 18:38:01 +02:00
Jürg Lehni
6a278c040a Minor clean-ups for the past few PRs 2018-10-03 18:21:26 +02:00
Jürg Lehni
959ccc83c2
Merge pull request #1531 from sasensi/Fix_#1503_Item#position_caching_issue
Fix #1503 Item#position caching issue
2018-10-03 17:33:24 +02:00
Jürg Lehni
27b92a6007 Improve handling of push() with lots of items
Improves fix for #1493, should pass CI again
2018-10-03 16:45:38 +02:00
Jürg Lehni
da3a36230f Color: Improve CSS string parser and docs 2018-10-03 15:56:15 +02:00
Jürg Lehni
9201ea973e
Merge pull request #1533 from sasensi/Fix_#1501_errors_with_event_listeners_on_mobile
Fix #1501 errors with event listeners on mobile
2018-10-03 10:22:49 +02:00
Jürg Lehni
a148e61129
Merge pull request #1534 from sasensi/Fix_#1493_Path#add_crashes_whith_1000000_segments
Fix #1493 Path#add crashes whith 1000000 segments
2018-10-03 10:18:15 +02:00
Jürg Lehni
f032dcbf06
Merge pull request #1535 from sasensi/Fix_selected_position_is_wrongly_placed_when_item_is_in_a_group_with_matrix_not_applied
Fix: selected position is wrongly placed when item is in a group with matrix not applied
2018-10-03 10:16:59 +02:00
sasensi
34679614c0 Fix: selected position is wrongly placed when item is in a group with matrix not applied 2018-10-03 09:43:40 +02:00
sasensi
d12b99e252 Improve Path#add performance with big arrays 2018-10-03 08:59:36 +02:00
sasensi
f673542640 Refactor code to fit style rules 2018-10-02 19:28:35 +02:00
sasensi
c034ebf554 Refactor code to fit style rules 2018-10-02 19:20:12 +02:00
sasensi
fc5bb4b10e Fix #1493 Path#add crashes whith 1000000 segments 2018-10-02 14:09:34 +02:00
sasensi
54e1a0c1ef Fix: calling event.preventDefault() on not cancelable events produces errors 2018-10-02 10:31:49 +02:00
sasensi
cb9fbd7789 Fix #1501 document touchstart/touchmove events are passive by default in chrome and event.preventDefault() calls are ignored 2018-10-02 10:29:39 +02:00
sapics
cce5b24e9a Fix:SvgImport apply attributes to item #1416 2018-10-02 16:35:32 +09:00
sasensi
704d37be2f Fix #1503 Item#position caching issue 2018-10-01 19:25:04 +02:00
sasensi
07ae09a76a Fix #1521 adding raster.smoothing property 2018-09-30 18:46:02 +02:00
Jürg Lehni
53897d7498 Simplify code from #1528 2018-09-29 16:26:47 +02:00
DD
bf63bf223c Add rotate case as well 2018-09-29 16:19:32 +02:00
DD
8d0fecbb1b For SVG import, If second argument is missing in translate, assume that it's zero. Currently it assumes that y matches x if y is missing. 2018-09-29 16:19:09 +02:00
Jürg Lehni
8792d142b3 Some code cleanup for #1515 2018-09-29 15:09:02 +02:00
Jürg Lehni
ef2c56b164
Merge pull request #1515 from sasensi/Fix_#1506_#1513_by_checking_winding_quality_in_boolean_subtraction
Fix #1506 #1513 by checking winding quality in boolean subtraction
2018-09-29 14:51:18 +02:00
sapics
e057f20f37
Merge pull request #1511 from sapics/free-memory2
Release memory on Color
2018-09-29 13:31:38 +09:00
sapics
eb740c2452 Minor fix 2018-09-29 12:29:12 +09:00
Bojan Hribernik
6925888024 Fix Cannot read property 'parent' of undefined in node
This happens in webpack bundle in node server rendering react application:
```js
TypeError: Cannot read property 'parent' of undefined
    at Object.eval (webpack:///./node_modules/paper/dist/node/self.js?:20:28)
    at eval (webpack:///./node_modules/paper/dist/node/self.js?:62:30)
    at Object../node_modules/paper/dist/node/self.js (/home/bojan/www/climbuddy/client/server/map.bundle.js:34531:1)
    at __webpack_require__ (/home/bojan/www/climbuddy/client/server/map.bundle.js:26:30)
    at Object.eval (webpack:///./node_modules/paper/dist/paper-core.js?:35:16)
    at eval (webpack:///./node_modules/paper/dist/paper-core.js?:14798:3)
    at Object../node_modules/paper/dist/paper-core.js (/home/bojan/www/climbuddy/client/server/map.bundle.js:34553:1)
    at __webpack_require__ (/home/bojan/www/climbuddy/client/server/map.bundle.js:26:30)
    at eval (webpack:///./node_modules/react-paper-bindings/lib/View.js?:15:18)
    at Object../node_modules/react-paper-bindings/lib/View.js (/home/bojan/www/climbuddy/client/server/map.bundle.js:37188:1)
```
2018-09-29 12:14:32 +09:00
sapics
e9c4e8cf3b Release memory on Color 2018-09-27 18:39:39 +09:00
sapics
f8d8b5cc03
Code style fix: replace tabs to spaces 2018-09-27 16:47:17 +09:00
sasensi
9a8aae00bd Fix #1506 #1513 by checking winding quality in boolean subtraction 2018-09-26 14:05:29 +02:00
sasensi
6ca654d6d3 fix Path.splitAt() documentation example 2018-09-20 12:24:35 +02:00
DD Liu
c7042d79e1 Turn off image smoothing on rasterize and allow user-set bounds 2018-08-03 16:01:07 -04:00
DD Liu
3b68397a5e Fix uses of const 2018-08-02 16:07:26 -04:00
DD Liu
9f9f210537
Merge pull request #16 from fsih/safariDrawImage
Fix Safari when selection exceeds canvas bounds
2018-08-01 15:38:38 -04:00
DD Liu
e0b6759add Make raster's getSubRaster function allow rectangles that exceed the bounds of the canvas. This fixes Safari, which returns a blank canvas in that case. 2018-07-26 15:08:48 -04:00
Paul Kaplan
7519590321 Fix gradients applied to text.
Two things:
1. Apply a gradientTransform for text items that reverse the text transform. This is required because we do not use x/y for text, and gradients are impacted by the transforms.
2. Always apply the style to text elements instead of allowing them to be applied to the parent group if the text element is alone. This is so the fill property is always on the text element so the gradient transforms work.
2018-07-17 10:09:41 -04:00
DD Liu
51a1b93df6
Merge pull request #14 from fsih/bearEars
Fix SVG import of translate with one argument
2018-06-27 16:55:54 -04:00
DD
011a353c08 Add rotate case as well 2018-06-27 16:47:19 -04:00
DD
4c72f3f89e For SVG import, If second argument is missing in translate, assume that it's zero. Currently it assumes that y matches x if y is missing. 2018-06-27 16:29:46 -04:00
Paul Kaplan
9065cad302
Use childNodes instead of children 2018-06-14 11:40:56 -04:00
DD Liu
df08aa10c1
Remove || '' 2018-05-23 15:27:07 -04:00
DD
26868e4cab Add support for text before edge baseline 2018-05-22 12:40:59 -04:00
DD
15470a90b7 Be able to import leading 2018-05-17 17:33:36 -04:00
DD
e29749a266 Allow hitting unfilled text and compound paths when hitUnfilledPaths option is on 2018-04-03 18:09:24 -04:00
Paul Kaplan
dd276b92f7 Export and import SVGs with multiline text 2018-03-29 13:23:52 -04:00
Jürg Lehni
a61e83edf2 Simplify fix for #1452 2018-03-06 12:57:05 +01:00
Jonathan Park
74bb49d8c0 fix issue with svg import of raster images
When importing rasters after load if the image has a matrix with any translation/skew value
the image will calculate the wrong matrix after loading.

In order to correct this we append the translation rather than prepend so
that it happens in the correct order relative to the transformation.
2018-03-02 00:19:43 +00:00
Jürg Lehni
5f6c70d316 Use proper new statement in deserialization 2018-02-03 22:39:57 +01:00
Jürg Lehni
ec1e3262b6
Merge pull request #1374 from alexjlockwood/patch-2
Fix documentation for Shape#toPath()
2018-01-16 11:03:55 +01:00
DD
2af28e6c0e Merge branch 'develop' of github.com:LLK/paper.js into develop 2017-12-18 12:02:00 -05:00
DD
f2ae9bc6db Don't show handles when fully selected, it is too crowded 2017-12-18 12:01:45 -05:00
DD Liu
241d0749c8
Merge pull request #5 from fsih/hitTransparent
Add an option to hit closed paths with transparent or alpha 0 fill
2017-12-14 15:37:03 -05:00
DD
bf2a405ede Fix size 0 handle rendering 2017-12-12 15:05:00 -05:00
DD
4abc415002 Add an option to hit closed paths with transparent or alpha 0 fill 2017-12-12 12:14:59 -05:00
DD
fd1435d94d Fix tests and make Travis deploy scratch paperjs 2017-12-04 18:34:59 -05:00
DD
2d790a3f34 Copy changes in selection mode to src files 2017-12-04 18:23:42 -05:00
Jürg Lehni
193592b88b Release version 0.11.5 2017-10-08 17:48:07 +02:00
Jürg Lehni
0deddebb2c Merge pull request #1382 from sapics/patch-1
Fix path.isSelected
2017-10-05 16:16:29 +02:00
Jürg Lehni
702ab748a2 JSHint: Fix error 2017-10-05 12:09:07 +02:00
Jürg Lehni
6c5f1dc671 Node.js: Clean up image stream handling 2017-10-04 22:39:19 +02:00
therewasaguy
6939c1674b Node.js: Add JPEG support to exportFrames()
Closes #1166
2017-10-04 22:25:30 +02:00
Jürg Lehni
7412939096 Boolean: Add better filtering for invalid segments
Fixes #1385
2017-10-04 21:43:56 +02:00
Jürg Lehni
10f464edfc Boolean: Check that overlaps are on the right path
Closes #1321
2017-10-04 17:52:09 +02:00