Sebastian
30419d0766
Fix #553 ( #555 )
...
* use a Result for font functions that can fail
* derive Debug for FontError and add data to the variants
2024-03-10 15:08:16 +00:00
Andrea Frigido
d0f8005169
Update license field following SPDX 2.1 license expression standard ( #540 )
2024-02-06 16:59:01 +00:00
Maxwell Huang-Hobbs
c5da885fec
Scale offset in source image's own cooridnate space
...
This fixes https://github.com/servo/pathfinder/issues/481
2021-11-24 11:38:15 -05:00
Patrick Walton
0c1fda4abb
Implement `putImageData()` on canvas.
...
Partially addresses #388 .
2020-07-28 16:46:51 -07:00
Patrick Walton
c8a6d8e1f7
Allow clip paths to nest in the canvas API.
...
Closes #372 .
2020-07-28 14:27:53 -07:00
Patrick Walton
d01bc5d002
Make the fields of `TextMetrics` lazily calculated, and add an API that
...
eliminates double layouts.
This adds an extension to the HTML canvas API that allows you to pass the
`TextMetrics` object returned by `measure_text()` to `fill_text()` and/or
`stroke_text()` to draw the measured text without laying it out again. It
improves performance on the `canvas_nanovg` demo.
2020-07-21 19:33:15 -07:00
Patrick Walton
a49714e0ba
Flesh out the `web_canvas` crate a bit more
2020-07-06 11:01:38 -07:00
Patrick Walton
e54e0e4760
Start a new `web_canvas` crate, for usage in the browser as a `<canvas>` replacement
2020-07-04 09:33:49 -07:00
Patrick Walton
769dae4a9c
Update various front-end libraries
2020-06-23 13:15:59 -07:00
Patrick Walton
ef20671ab7
Publish `pathfinder_canvas` to crates.io
2020-04-17 13:50:36 -07:00
Patrick Walton
171fb21fe7
Switch back to upstream `skribo`
2020-04-17 12:15:55 -07:00
Patrick Walton
0b43f629cd
Cache loaded fonts and glyph outlines.
...
Approximately a 70% CPU time improvement on the NanoVG demo.
2020-04-16 16:28:44 -07:00
Patrick Walton
83c05e9f77
Improve the fidelity of the NanoVG demo some more
2020-04-14 18:49:47 -07:00
Patrick Walton
5efdf2a04a
Implement the missing pieces of `TextMetrics` for canvas.
...
This required a `font-kit` upgrade, and with it a `skribo` upgrade.
2020-04-14 15:01:30 -07:00
Patrick Walton
b9b1472b6c
Resolve fill and stroke paints when filling and stroking text.
...
Makes text respect global alpha.
2020-04-14 10:08:11 -07:00
Patrick Walton
667a6c7c43
Fix definition of `TextBaseline::Middle`
2020-04-14 09:45:18 -07:00
Patrick Walton
cdbe2fbb6b
Introduce the concept of a base color in order to handle canvas shadow alpha
...
correctly
2020-04-13 18:31:25 -07:00
Patrick Walton
e598249186
Use column vector length to extract scale from matrices.
...
Closes #298 .
2020-04-10 13:38:25 -07:00
Patrick Walton
55f89c4ffa
Merge pull request #293 from pyfisch/canvas-reexport
...
Re-export necessary items in pathfinder-canvas
2020-04-09 10:29:39 -07:00
Patrick Walton
895f73096e
Switch back to instanced drawing for tiles.
...
Improves tile build time by something around 2x in the NanoVG demo.
2020-04-08 17:16:54 -07:00
Pyfisch
dfb035dec0
Re-export necessary items in pathfinder-canvas
...
Export types need to use the canvas API from other pathfinder crates.
From pathfinder-color all types and convinience functions are exported.
From pathfinder-geometry only the 2D vector and rect types with
their convinience functions are exported.
Items from pathfinder-renderer are not re-exported as they also
belong to the back-end.
Pattern, while used in the canvas API, is not re-exported as
it is not needed for basic usage and depends on a lot of other types.
See #283
2020-04-04 14:06:40 +02:00
Patrick Walton
9d5dd7fd6a
Make text respect clip, blend mode, and opacity
2020-04-03 15:37:59 -07:00
Patrick Walton
bba6aab0fe
Don't blur the entire canvas
2020-04-03 14:32:51 -07:00
Patrick Walton
eb2b622615
Remove `draw_render_target()` in favor of the standard tile-based rendering
...
path
2020-04-03 13:05:53 -07:00
Patrick Walton
cd37791d72
Implement the `drawImage()` method on canvas.
...
Closes #223 .
2020-04-02 16:30:49 -07:00
Patrick Walton
ba7fe4be39
Add the ability to merge scenes together, and expose it to the canvas API.
...
Closes #268 .
2020-04-02 14:04:58 -07:00
Patrick Walton
542d2c27fa
Add `translate`, `rotate`, and `scale` methods to `CanvasRenderingContext2D`.
2020-04-02 11:40:53 -07:00
Patrick Walton
794dd55038
Add some implicit conversions between scalars and vectors where appropriate
2020-04-01 17:20:32 -07:00
Patrick Walton
ae97ccea5a
Improve ergonomics of the canvas font interface, and use the right fonts in the
...
NanoVG demo.
2020-04-01 16:25:13 -07:00
Patrick Walton
bf6890b341
Fix `canvas_minimal`
2020-03-31 20:21:27 -07:00
Patrick Walton
93f5fbc6d2
Add convenience constructors: `vec2f`, `vec2i`, `Vector2F::zero()`,
...
`Vector2I::zero()`
2020-03-31 11:29:21 -07:00
Patrick Walton
4af74f225d
Add support to canvas for the commonly-used `textBaseline` values
2020-03-30 22:00:13 -07:00
Patrick Walton
6d6b5191bb
Clean up the `text` module inside `canvas` a bit
2020-03-30 21:32:30 -07:00
Patrick Walton
e864536b31
Add a `From` implementation to `FillStyle` and use it in `canvas` for brevity
2020-03-30 21:31:18 -07:00
Patrick Walton
f1d5906c9e
Switch to my branch of `skribo` for much better `fill_text()` performance
2020-03-30 21:30:14 -07:00
Patrick Walton
cf78ac4569
Fix image pattern texture atlas logic.
2020-03-30 16:19:03 -07:00
Patrick Walton
b6762cecb8
Don't include the closing segment when printing a path as a string.
...
Closes #279 .
Closes #282 .
2020-03-27 15:40:27 -07:00
Patrick Walton
6239356d89
Add a `Debug` impl for `Path2D`
2020-03-27 15:05:10 -07:00
Patrick Walton
c258616bad
Add `Path2D::add_path()`
2020-03-27 12:33:06 -07:00
Patrick Walton
0c93045f50
Replace the individual tile shaders with an ubershader
2020-03-25 21:59:51 -07:00
Lillian Primrose
22d54a82ca
CanvasFontContext now implements .clone()
2020-03-24 22:15:09 -04:00
Patrick Walton
a8f7438cd9
Remove transforms from paths.
...
Paints aren't scale-invariant when rendered into the texture atlas, so they
actually do need individual transforms.
2020-03-04 16:28:21 -08:00
Patrick Walton
d0f4579864
Move `RenderTargetId` out of the `pattern` module
2020-03-03 15:50:48 -08:00
Patrick Walton
12574101e5
Add a transform field to `DrawPath`.
...
This is currently applied to the outline and should eventually be applied to
paints as well.
2020-03-03 11:18:01 -08:00
Alex Zepeda
c8496a1cb2
Make Path2D#into_outline public
2020-03-02 00:14:24 -08:00
Adam Nemecek
3d39c5e9b7
trimmed whitespace
2020-02-27 08:13:14 -08:00
Patrick Walton
e913f83eee
Remove obsolete TODOs
2020-02-27 04:03:08 -08:00
Patrick Walton
3a014d78eb
Implement a blur filter for canvas shadows
2020-02-26 18:43:41 -08:00
Patrick Walton
d1c7da8bd2
Implement pattern repeating and image smoothing control
2020-02-26 14:56:05 -08:00
Patrick Walton
77b3555828
Separate opacity out from paint.
...
This allows `globalAlpha` to work on render targets.
2020-02-26 12:43:07 -08:00
Patrick Walton
1deb53fa9c
Implement the remaining Porter-Duff compositing operators
2020-02-25 18:37:23 -08:00
Patrick Walton
0a3f64eb44
Implement the difference and exclusion blend modes
2020-02-25 14:55:58 -08:00
Patrick Walton
a8e33d3d3d
Add the soft light blend mode
2020-02-25 14:39:06 -08:00
Patrick Walton
9b4217300f
Implement the source-in, destination-in, source-out, and destination-atop blend
...
modes to round out the assortment of Porter-Duff blend modes
2020-02-25 12:52:11 -08:00
Patrick Walton
02012431ca
Implement color dodge and color burn blend modes
2020-02-25 11:37:42 -08:00
Patrick Walton
5b228ed825
Implement multiply, screen, hard light, and overlay blend modes.
2020-02-24 21:23:17 -08:00
Patrick Walton
5421525eaa
Implement the HSL filters (called "non-separable blend modes" in the spec).
...
These cannot be implemented with the standard OpenGL blending functions, so we
have to do them manually in a shader, which requires a good deal of machinery
to create intermediate framebuffers and so forth.
2020-02-24 15:37:44 -08:00
Patrick Walton
36538d5748
Implement a few more blend modes and switch to premultiplied alpha for layer
...
compositing
2020-02-20 22:22:15 -08:00
Patrick Walton
4933efb513
Add Lighten and Darken composite ops
2020-02-20 20:38:43 -08:00
Patrick Walton
ab55b9509b
Fix handling of solid tiles with the Clear blend mode
2020-02-20 18:15:20 -08:00
Patrick Walton
6acd2d91f7
Implement `clear_rect()` in the canvas front-end by introducing the concept of
...
per-path blend modes.
These should be useful for some canvas composite operations as well.
2020-02-20 15:52:40 -08:00
Patrick Walton
95d5fab5ef
Minor cleanup in `pathfinder_canvas`
2020-02-19 10:59:40 -08:00
Patrick Walton
cc9711e151
Transform some paints in the canvas API
2020-02-18 16:06:39 -08:00
Patrick Walton
3ad1c25796
Implement the even-odd fill rule
2020-02-17 14:44:48 -08:00
Patrick Walton
496b55ee4e
Add front-end support for clip paths. They don't do anything yet.
2020-02-15 13:21:12 -08:00
Patrick Walton
fefa3c3cd3
Rename `PathObject` to `DrawPath` to differentiate it from a clip path
2020-02-15 12:39:15 -08:00
Patrick Walton
84ffc3151e
Split shaders out into a separate module.
2020-02-14 11:56:38 -08:00
Patrick Walton
90445bac7e
Implement basic support for non-repeating image patterns.
2020-02-11 17:20:21 -08:00
Patrick Walton
5a21557a6d
Implement basic linear gradients.
...
This is not a very efficient implementation yet, but it seems to work.
2020-02-10 16:01:05 -08:00
Emmanuel Gil Peyrot
6ce416e77c
Bump all outdated dependencies
...
I’m pleasantly surprised that none of these required any (visible) code
change, but tests pass so let’s go with that. :)
2020-02-06 09:39:50 +01:00
Patrick Walton
706b6dbd1d
Add an API for gradients to the canvas frontend, not implemented yet
2020-02-05 20:01:11 -08:00
Patrick Walton
2db43797c3
Split colors out into their own crate.
...
A lot of downstream consumers of `pathfinder_gpu` want to use colors without
the path stuff.
2020-01-31 09:17:04 +01:00
Kamal Ahmad
29713c5cd9
Bump lyon, font-kit and skribo versions to fix crashes
2019-11-20 22:51:03 +05:00
Sebastian Köln
3d0e911c3e
fix #219 (minimum stroke thickness)
2019-08-10 18:35:56 +03:00
est31
3928e8d964
Rename the feature text → pf-text
2019-08-05 22:49:08 +02:00
est31
38df17696a
Put the text stuff into separate files
2019-07-27 19:18:10 +02:00
est31
fa1a32bdbb
Make text rendering optional in pathfinder_canvas
2019-07-27 06:13:02 +02:00
Sebastian Köln
e12821350e
fix canvas
2019-07-16 09:55:01 +03:00
Sebastian Köln
6acab74fae
Merge branch 'master' of https://github.com/servo/pathfinder
2019-07-16 09:43:37 +03:00
Patrick Walton
2c984de1ea
Add convenience translation, rotation, and scaling methods to `Transform2D`
2019-07-12 11:34:48 -07:00
Patrick Walton
1eb28a5539
Fix incorrect definition of 2D transform multiplication
2019-07-12 11:26:09 -07:00
Patrick Walton
bcac119324
Rename `Transform2DF` to `Transform2F` and `Transform3DF` to `Transform4F`
2019-07-11 14:59:10 -07:00
Sebastian Köln
251785db67
cleanup
2019-06-25 11:39:31 +03:00
Sebastian Köln
17f0e50878
Merge https://github.com/servo/pathfinder
2019-06-24 18:23:10 +03:00
Sebastian Köln
2a129b7bbd
add CanvasRenderingContext2D::fill_layout – a method to draw layouts directly, without using skribo
2019-06-24 16:12:05 +03:00
Patrick Walton
431dcf3d2e
Rename `pathfinder_geometry::basic` to simply `pathfinder_geometry`, and move
...
the remaining code in that crate to a new crate, `pathfinder_content`
The old hierarchy was confusing.
2019-06-21 10:06:19 -07:00
Patrick Walton
0012f09eeb
Fix examples
2019-06-20 21:43:57 -07:00
Patrick Walton
7973148603
Implement basic shadows (no blur yet)
2019-06-03 21:09:04 -07:00
Patrick Walton
bd248bf850
Implement line dash offset
2019-06-03 19:36:08 -07:00
Patrick Walton
1a42bbf4d3
Implement dashing for line segments (no curves yet)
2019-06-03 14:16:58 -07:00
Patrick Walton
a1b0df0a42
Rename `Point2DF` to `Vector2F`, `Point3DF` to `Vector4F`, and `LineSegmentF`
...
to `LineSegment2F`.
Straw poll on Twitter suggested that these names were preferred.
2019-06-03 12:39:29 -07:00
Patrick Walton
678b6f12c7
Add support for counterclockwise winding to arcs
2019-06-01 12:56:31 -07:00
Patrick Walton
44167beff5
Implement `Path2D::arc_to`.
2019-05-31 16:01:53 -07:00
Patrick Walton
0b9a41c533
Treat the miter limit as part of the canvas state, allowing it to be saved and
...
restored even if miter joins are not in use.
In my opinion, this behavior is less logical, but it matches the behavior of
the HTML canvas API, which we aim to remain close to.
2019-05-30 21:39:08 -07:00
Patrick Walton
95f3337c6f
Add the `ellipse` method to canvas paths
2019-05-30 17:24:12 -07:00
Patrick Walton
9756aa89f9
Base the core arc primitive on a unit chord and transform.
...
This lets us handle ellipses better.
2019-05-30 17:19:21 -07:00
Patrick Walton
607a518544
Implement canvas text align
2019-05-30 15:08:15 -07:00
Patrick Walton
8d078ff345
Add an initial implementation of canvas `measureText`
2019-05-30 12:38:32 -07:00
Patrick Walton
9138e1e0bb
Pass in the font context to the canvas rendering context constructor so that it
...
can be reused.
Creating a system font source can do I/O on some platforms, so obviously we
don't want to do it every frame.
2019-05-29 21:15:42 -07:00
Patrick Walton
e1bcc11ace
Change the `F32` and `I32` suffixes to `F` and `I` to match the C API.
...
They're shorter and less noisy.
2019-05-29 19:17:16 -07:00