Skip to content

Commit de892d3

Browse files
committed
Svg circle support
1 parent 1a96003 commit de892d3

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

Sources/SwiftHtml/Svg/Circle.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// File.swift
3+
//
4+
//
5+
// Created by Tibor Bodecs on 2021. 11. 29..
6+
//
7+
8+
9+
public final class Circle: Tag {
10+
11+
public init(cx: Int, cy: Int, r: Int) {
12+
super.init(Node(type: .standard, name: "circle", attributes: [
13+
.init(key: "cx", value: String(cx)),
14+
.init(key: "cy", value: String(cy)),
15+
.init(key: "r", value: String(r)),
16+
]))
17+
18+
}
19+
}

Tests/SwiftHtmlTests/SvgTests.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import XCTest
1010

1111
final class SvgTests: XCTestCase {
1212

13-
func testSvg() {
14-
13+
func testSvgWithLine() {
1514
let doc = Document(.unspecified) {
1615
Svg {
1716
Line(x1: 1, y1: 2, x2: 3, y2: 4)
@@ -27,5 +26,14 @@ final class SvgTests: XCTestCase {
2726
}
2827
XCTAssertEqual(DocumentRenderer(minify: true).render(doc), #"<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="1" y1="2" x2="3" y2="4"></line></svg>"#)
2928
}
29+
30+
func testSvgWithCircle() {
31+
let doc = Document(.unspecified) {
32+
Svg {
33+
Circle(cx: 1, cy: 2, r: 3)
34+
}
35+
}
36+
XCTAssertEqual(DocumentRenderer(minify: true).render(doc), #"<svg><circle cx="1" cy="2" r="3"></circle></svg>"#)
37+
}
3038

3139
}

0 commit comments

Comments
 (0)