Swiftpack.co - Package - SusanDoggie/Doggie
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

Doggie - A Cross-platform Library for Swift

Github Actions codecov Platform GitHub release Swift MIT

Doggie is a foundational library for Apple's swift. It includes mathematics, accelerate, signal processing and graphic functions.

Apps Using This Library

Features

let shape = try Shape(code: "M100 0c0-100-236.60 36.60-150 86.60S36.60-136.60-50-86.60 100 100 100 0z")

let region = ShapeRegion(shape, winding: .nonZero)
let ellipse = ShapeRegion(ellipseIn: shape.boundary)
operation preview
region.union(ellipse) union
region.intersection(ellipse) union
ellipse.subtracting(region) union
region.subtracting(ellipse) union
region.symmetricDifference(ellipse) union
let collection = try FontCollection(data: fontFileData)

if let font = collection.first?.with(size: 64) {

    let string = "Doggie\u{0301}".precomposedStringWithCanonicalMapping

    let glyphs = font.glyphs(with: string.unicodeScalars)
    let advances = glyphs.map { font.advance(forGlyph: $0) }.scan(0, +)

    var shape = Shape()

    for (advance, glyph) in zip(advances, glyphs) {
        var outline = font.shape(forGlyph: glyph)
        outline.center.x += advance
        shape.append(contentsOf: outline.identity)
    }

    print(shape.encode())
}

let context = ImageContext<ARGB32ColorPixel>(width: 100, height: 100, colorSpace: ColorSpace.sRGB)

let ellipse1 = Shape(ellipseIn: Rect(x: 10, y: 35, width: 55, height: 55))
let ellipse2 = Shape(ellipseIn: Rect(x: 35, y: 10, width: 55, height: 55))

context.draw(shape: ellipse1, winding: .nonZero, color: RGBColorModel(red: 247/255, green: 217/255, blue: 12/255))
context.draw(shape: ellipse1, stroke: Stroke(width: 1, cap: .round, join: .round, color: RGBColorModel()))
context.draw(shape: ellipse2, winding: .nonZero, color: RGBColorModel(red: 234/255, green: 24/255, blue: 71/255))
context.draw(shape: ellipse2, stroke: Stroke(width: 1, cap: .round, join: .round, color: RGBColorModel()))

let image: Image<ARGB32ColorPixel> = context.image

drawing sample

  • others
<svg width="200" height="200" viewBox="0 0 220 220"
     xmlns="http://www.w3.org/2000/svg">
  <filter id="displacementFilter">
     <feTurbulence type="turbulence" baseFrequency="0.05"
        numOctaves="2" result="turbulence"/>
     <feDisplacementMap in2="turbulence" in="SourceGraphic"
        scale="50" xChannelSelector="R" yChannelSelector="G"/>
  </filter>

  <circle cx="100" cy="100" r="100"
     style="filter: url(#displacementFilter)"/>
</svg>
let context = ImageContext<Gray16ColorPixel>(width: 220, height: 220, colorSpace: .default)

context.draw(ellipseIn: Rect(x: 0, y: 0, width: 200, height: 200), color: .black)

var image = context.image

let turbulence: Image<RGBA32ColorPixel> = SVGTurbulence(220, 220, .turbulence, nil, .identity, 0, 0.05, 2)

image = DisplacementMap(image, turbulence, 0, 1, 50)

turbulence

Documents

Documents can find in here.

Status

ColorSpace

Format

  • ☑ ICC
  • ☑ CIEXYZ
  • ☑ CIELab
  • ☑ CIELuv
  • ☑ Calibrated Gray
  • ☑ Calibrated RGB

Rendering Intent

  • ☑ perceptual
  • ☐ saturation
  • ☑ absolute colorimetric
  • ☑ relative colorimetric

ImageRep

  • ☑ bmp
  • ☐ gif
  • ☑ jpeg
  • ☐ jpeg2000
  • ☑ png
  • ☑ tiff
  • ☑ webp

Font

Format

  • ☑ TrueType
  • ☑ TrueType/TTC
  • ☑ OpenType
  • ☑ OpenType/CFF
  • ☐ OpenType/CFF2
  • ☑ WOFF
  • ☑ WOFF/CFF
  • ☐ WOFF/CFF2
  • ☐ WOFF2

SFNT Tables

  • ☑ HEAD
  • ☑ POST
  • ☑ OS/2
  • ☑ MAXP
  • ☑ CMAP
  • ☑ NAME
  • ☑ HHEA
  • ☑ HMTX
  • ☑ VHEA
  • ☑ VMTX
  • ☑ LOCA
  • ☑ GLYF
  • ☑ SBIX
  • ☑ FEAT
  • ☐ KERX
  • ☐ MORX
    • ☑ Rearrangement
    • ☑ Contextual
    • ☑ Ligature
    • ☑ Noncontextual
    • ☐ Insertion
  • ☐ GSUB
  • ☐ GPOS
  • ☐ GDEF
  • ☑ CFF
  • ☐ CFF2

CMAP

Platform

The table below lists the available platform/specific values in the order.

platform specific Description
0 max( <= 4 ) Unicode
3 10 Windows, Unicode UCS-4
3 1 Windows, Unicode BMP (UCS-2)
Format
  • ☑ Format 0
  • ☑ Format 4
  • ☑ Format 12
  • ☑ Format 14 (Unicode Variation Selectors)

How To Contribute

It's welcome everyone to create a pull request.

License

Doggie is licensed under the MIT license.

Github

link
Stars: 78

Related Packages

Releases

Ready for Swift 5.3 - 2020-09-24T17:47:47

Latest version for Swift 5.1 - 2020-09-09T09:03:38

- 2020-08-04T05:47:01

- 2020-07-13T05:52:16

- 2020-06-19T05:15:07

- 2020-05-31T15:12:01

- 2020-05-07T11:37:44

- 2020-04-21T08:39:25

- 2020-04-17T16:04:40

- 2020-04-13T09:05:57

- 2020-04-06T07:14:40

- 2020-03-25T09:31:48

- 2020-03-17T06:00:38

- 2020-02-19T12:54:10

- 2020-02-05T09:35:54

- 2019-12-24T09:05:23

- 2019-12-23T10:55:25

- 2019-12-19T11:20:38

- 2019-09-21T11:37:16

3.5.0 - 2019-05-28T06:59:51

3.4.2 - 2019-04-23T04:08:28

- 2019-04-06T05:54:34

PDFContext available now! - 2019-04-04T09:00:06

Swift 5 released - 2019-03-26T02:52:10

SVGContext - 2019-03-25T03:00:32

3.2.2 - 2019-03-08T04:27:45

3.2.1 - 2019-02-22T06:05:09

3.2.0 - 2019-01-25T04:12:59

3.1.0 - 2018-11-20T10:27:32

swift 4.2 - 2018-09-13T03:32:52