Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions FIDELITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4944,8 +4944,10 @@ dependency (BSD-3, "build from source").
**What oksvg does / doesn't do (documented, not faked):** it handles the drawing
subset above plus `currentColor` (we feed the element's computed CSS `color` via
`ReadReplacingCurrentColor`, so `fill="currentColor"` logos take their real
colour). It does **not** implement SVG `<filter>` effects, `<mask>`/`<clipPath>`
compositing, `<pattern>` fills, embedded raster `<image>`, `<text>`/font shaping,
colour). (Since the engine moved to the fleet fork `github.com/go-gfx/oksvg`,
`<clipPath>` and the `clip-path` property are implemented, with `clip-rule`,
and arc commands with several parameter sets are drawn correctly.) It does
**not** implement SVG `<filter>` effects, `<mask>` compositing, `<pattern>` fills, embedded raster `<image>`, `<text>`/font shaping,
CSS `<style>` selectors inside the SVG, or animation. Such features degrade to
"drawn without them" or empty, never a crash.

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ PNGs, measured vs headless Chrome) is in [`FIDELITY.md`](FIDELITY.md) and
- **Containers and shadow DOM**: `@container` size queries, and declarative
shadow DOM (`<template shadowrootmode>`) with `<slot>` distribution.
- **Images**: `<img>` over http(s) + `data:` (PNG/JPEG) and **SVG**
(oksvg/rasterx) via `<img *.svg>`, `data:image/svg+xml` and **inline `<svg>`**.
([go-gfx/oksvg](https://github.com/go-gfx/oksvg), a fork of srwiley/oksvg
with `clipPath`, over rasterx) via `<img *.svg>`, `data:image/svg+xml` and **inline `<svg>`**.
- **JavaScript**: page scripts run via [goja](https://github.com/dop251/goja)
against a real DOM, with `fetch()`/XHR and read-back of real laid-out geometry
(`getBoundingClientRect`, `offsetWidth/Height`, `getComputedStyle`). A
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ require (
github.com/evanw/esbuild v0.28.2
github.com/go-browserhttp/browserhttp v0.2.0
github.com/go-gfx/gfx v0.35.0
github.com/go-gfx/oksvg v0.1.0
github.com/go-images/images v0.1.0
github.com/go-opentype/fonts v0.12.0
github.com/go-opentype/opentype v0.15.0
github.com/go-pdfkit/pdfkit v0.15.0
github.com/go-webengine/esbuildsandbox v0.1.0
github.com/go-widgets/painter v0.16.0
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef
golang.org/x/image v0.46.0
golang.org/x/net v0.61.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/go-crdt/crdt v0.57.0 h1:sNLDTVCEnSb20gm77BUuYav8dzj5krmly/z9O7eRMCo=
github.com/go-crdt/crdt v0.57.0/go.mod h1:zdVTTDLGV5JYAoTJDqCivcAT+/B5gGebDsVd8QNZpVs=
github.com/go-gfx/gfx v0.35.0 h1:AaXMxDMxNB1hROxzx+3EoO06KxsrQUvnw/10olmSgVo=
github.com/go-gfx/gfx v0.35.0/go.mod h1:qIZS9u2+VnBk5CX7o4f/fQ5uD8c+mPFTtAPE85s8V90=
github.com/go-gfx/oksvg v0.1.0 h1:gK9AJ948GoKapOPikT391sD95YVnaNLq2PcvedDGxPo=
github.com/go-gfx/oksvg v0.1.0/go.mod h1:ap7jj7yma4qOcwiAFzPMC9/eODo7Q2nt71DkEZlHA0k=
github.com/go-icons/iconoir v0.3.0 h1:kHG2sU5IsCvtBS1JICuXgfFo5f8UfwY1m7KYMVy97CI=
github.com/go-icons/iconoir v0.3.0/go.mod h1:lPh5OuzVQ+rR4qDPGgAdSRUhnCbHeCAX70HDdwp8/RI=
github.com/go-images/gif v0.2.0 h1:8Xl4Nan+PvyqH4wPre7wJUH61T2eJKOKonFKOdMdpkU=
Expand Down Expand Up @@ -74,8 +76,6 @@ github.com/sergeymakinen/go-bmp v1.0.0 h1:SdGTzp9WvCV0A1V0mBeaS7kQAwNLdVJbmHlqNW
github.com/sergeymakinen/go-bmp v1.0.0/go.mod h1:/mxlAQZRLxSvJFNIEGGLBE/m40f3ZnUifpgVDlcUIEY=
github.com/sergeymakinen/go-ico v1.0.0 h1:uL3khgvKkY6WfAetA+RqsguClBuu7HpvBB/nq/Jvr80=
github.com/sergeymakinen/go-ico v1.0.0/go.mod h1:wQ47mTczswBO5F0NoDt7O0IXgnV4Xy3ojrroMQzyhUk=
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c h1:km8GpoQut05eY3GiYWEedbTT0qnSxrCjsVbb7yKY1KE=
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c/go.mod h1:cNQ3dwVJtS5Hmnjxy6AgTPd0Inb3pW05ftPSX7NZO7Q=
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef h1:Ch6Q+AZUxDBCVqdkI8FSpFyZDtCVBc2VmejdNrm5rRQ=
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE=
github.com/tannevaled/gobig2 v0.2.0 h1:yx97/ltljALrIWDFVqHjPUIjAp3bfUUhH8Z8UROvNLc=
Expand Down
2 changes: 1 addition & 1 deletion svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strconv"
"strings"

"github.com/srwiley/oksvg"
"github.com/go-gfx/oksvg"
"github.com/srwiley/rasterx"

"github.com/go-webengine/engine/css"
Expand Down
30 changes: 30 additions & 0 deletions svg_clip_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) the go-webengine/engine authors.
// SPDX-License-Identifier: BSD-3-Clause

package engine

import (
"image/color"
"testing"
)

// TestRasterizeSVGClipPath: an SVG clipPath is honoured (the rasteriser is
// go-gfx/oksvg, which implements it; srwiley/oksvg dropped the property).
func TestRasterizeSVGClipPath(t *testing.T) {
src := `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<defs><clipPath id="c"><circle cx="50" cy="50" r="30"/></clipPath></defs>
<rect width="100" height="100" fill="#ff0000" clip-path="url(#c)"/></svg>`
img, ok := RasterizeSVG([]byte(src), 100, 100, "")
if !ok {
t.Fatal("not rasterised")
}
alpha := func(x, y int) uint8 { return color.NRGBAModel.Convert(img.At(x, y)).(color.NRGBA).A }
if a := alpha(50, 50); a != 255 {
t.Errorf("inside the clip: alpha %d", a)
}
for _, p := range [][2]int{{5, 5}, {95, 5}, {50, 90}} {
if a := alpha(p[0], p[1]); a != 0 {
t.Errorf("outside the clip at %v: alpha %d", p, a)
}
}
}
2 changes: 1 addition & 1 deletion svg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"testing"

"github.com/srwiley/oksvg"
"github.com/go-gfx/oksvg"

"github.com/go-webengine/engine/css"
"github.com/go-webengine/engine/dom"
Expand Down
Loading