Skip to content

Instantly share code, notes, and snippets.

@PhilAndrew
Created February 25, 2015 04:57
Show Gist options
  • Save PhilAndrew/4ec8836528d07859aa03 to your computer and use it in GitHub Desktop.
Save PhilAndrew/4ec8836528d07859aa03 to your computer and use it in GitHub Desktop.
import scala.scalajs.js
import scala.scalajs.js.annotation.JSName
package object sjs_paper extends js.GlobalScope {
def paper: PaperScope = js.native
}
package sjs_paper
import org.scalajs.dom._
import scala.scalajs.js
import scala.scalajs.js.UndefOr
import scala.scalajs.js.annotation.JSName
import Point.origin
class PaperScope() extends js.Object {
def setup(canvas: html.Canvas): PaperScope = js.native
def activate(): Unit = js.native
def view: View = js.native
def version: String = js.native
var settings: js.Object = js.native
var project: Project = js.native
def projects: js.Array[Project] = js.native
}
object PaperScope {
def get(id: String): PaperScope = ???
def get(canvas: html.Canvas): PaperScope = ???
}
@JSName("paper.Style")
class Style protected() extends js.Object {
def this(obj: js.Object) = this()
var strokeScaling: Boolean = js.native
def view: View = js.native
var strokeColor: Color = js.native
var strokeWidth: Int = js.native
var strokeCap: String = js.native
var strokeJoin: String = js.native
var dashOffset: Int = js.native
var dashArray: js.Array[Int] = js.native
var miterLimit: Double = js.native
var fillColor: Color = js.native
var shadowColor: Color = js.native
var shadowBlur: Double = js.native
var shadowOffset: Point = js.native
var selectedColor: Color = js.native
var fontFamily: String = js.native
var fontWeight: String = js.native
//Either String or Int. Default 10
var fontSize: Any = js.native
var leading: Double = js.native
var justification: String = js.native
}
object FontFamily {
//non-exhaustive
val serif = "serif"
val sansSerif = "sans-serif"
val cursive = "cursive"
val fantasy = "fantasy"
val monospace = "monospace"
}
object FontWeight {
//non-exhaustive
val normal = "normal"
val lighter = "lighter"
val bold = "bold"
val bolder = "bolder"
}
object Justification {
val left = "left"
val right = "right"
val center = "center"
}
@JSName("paper.Layer")
class Layer(children: js.Array[Item]) extends Group {
def this(properties: js.Object) = this(null)
def activate(): Unit = js.native
}
@JSName("paper.Item")
class Item extends js.Object {
def id: Int = js.native
def className: String = js.native
var name: String = js.native
var style: Style = js.native
var visible: Boolean = js.native
var blendMode: String = js.native
var opacity: Double = js.native
var selected: Boolean = js.native
var clipMask: Boolean = js.native
var data: js.Object = js.native
var position: Point = js.native
var pivot: Point = js.native
def bounds: Rectangle = js.native
def strokeBounds: Rectangle = js.native
def handleBounds: Rectangle = js.native
def rotation: Double = js.native
def scaling: Point = js.native
var matrix: Matrix = js.native
def globalMatrix: Matrix = js.native
var applyMatrix: Boolean = js.native
def project: Project = js.native
def view: View = js.native
def layer: Layer = js.native
var parent: Item = js.native
def children: js.Array[Item] = js.native
def firstChild: Item = js.native
def lastChild: Item = js.native
def nextSibling: Item = js.native
def previousSibling: Item = js.native
def index: Int = js.native
var strokeColor: Color = js.native
var strokeWidth: Int = js.native
var strokeCap: String = js.native
var strokeJoin: String = js.native
var dashOffset: Int = js.native
var dashArray: js.Array[Int] = js.native
var miterLimit: Int = js.native
var windingRule: String = js.native
var fillColor: Color = js.native
var selectedColor: Color = js.native
var onFrame: js.Function1[Event, Unit] = js.native
var onMouseDown: js.Function1[Event, Unit] = js.native
var onMouseUp: js.Function1[Event, Unit] = js.native
var onClick: js.Function1[Event, Unit] = js.native
var onDoubleClick: js.Function1[Event, Unit] = js.native
var onMouseMove: js.Function1[Event, Unit] = js.native
var onMouseEnter: js.Function1[Event, Unit] = js.native
var onMouseLeave: js.Function1[Event, Unit] = js.native
def set(props: js.Object): Item = js.native
def clone(insert: Boolean = true): Item = js.native
def copyTo(item: Item): Item = js.native
def copyTo(layer: Layer): Item = js.native
def copyTo(group: Group): Item = js.native
def copyTo(path: CompoundPath): Item = js.native
def rasterize(): Raster = js.native
def rasterize(resolution: Int): Raster = js.native
def contains(point: Point): Boolean = js.native
def hitTest(point: Point, options: js.Object): HitResult = js.native
def matches(criteria: js.Object): Boolean = js.native
def getItems(criteria: js.Object): js.Array[Item] = js.native
def getItem(criteria: js.Object): Item = js.native
def exportJSON(asString: Boolean = true, precision: Int = 5): String = js.native
def importJSON(json: String): Unit = js.native
def exportSVG(asString: Boolean = false,
precision: Int = 5, matchShape: Boolean = false): AnyRef = js.native
def importSVG(svgElementOrString: AnyRef,
expandShapes: Boolean = false): Item = js.native
def addChild(item: Item): Item = js.native
def insertChild(index: Int, item: Item): Item = js.native
def addChildren(items: js.Array[Item]): js.Array[Item] = js.native
def insertChildren(index: Int, items: js.Array[Item]): js.Array[Item] = js.native
def insertAbove(item: Item): Item = js.native
def insertBelow(item: Item): Item = js.native
def sendToBack(): Unit = js.native
def bringToFront(): Unit = js.native
def reduce(): Item = js.native
def remove(): Boolean = js.native
def removeChildren(): js.Array[Item] = js.native
def removeChildren(from: Int): js.Array[Item] = js.native
def removeChildren(from: Int, to: Int): js.Array[Item] = js.native
def reverseChildren(): Unit = js.native
def isEmpty(): Boolean = js.native
def hasFill(): Boolean = js.native
def hasStroke(): Boolean = js.native
def hasShadow(): Boolean = js.native
def hasChildren(): Boolean = js.native
def isInserted(): Boolean = js.native
def isAbove(item: Item): Boolean = js.native
def isBelow(item: Item): Boolean = js.native
def isParent(item: Item): Boolean = js.native
def isChild(item: Item): Boolean = js.native
def isDescendant(item: Item): Boolean = js.native
def isAncestor(item: Item): Boolean = js.native
def isGroupedWith(item: Item): Boolean = js.native
def translate(delta: Point): Unit = js.native
def rotate(angle: Double): Unit = js.native
def rotate(angle: Double, center: Point): Unit = js.native
def scale(scale: Point): Unit = js.native
def scale(scale: Point, center: Point): Unit = js.native
def scale(hor: Double, ver: Double): Unit = js.native
def scale(hor: Double, ver: Double, center: Point): Unit = js.native
def shear(shear: Point): Unit = js.native
def shear(shear: Point, center: Point): Unit = js.native
def shear(hor: Double, ver: Double): Unit = js.native
def shear(hor: Double, ver: Double, center: Point): Unit = js.native
def skew(skew: Point, center: Point): Unit = js.native
def skew(skew: Point): Unit = js.native
def skew(hor: Double, ver: Double): Unit = js.native
def skew(hor: Double, ver: Double, center: Point): Unit = js.native
def transform(matrix: Matrix): Unit = js.native
def globalToLocal(point: Point): Point = js.native
def localToGlobal(point: Point): Point = js.native
def fitBounds(rectangle: Rectangle, fill: Boolean = false): Unit = js.native
def attach(eventType: String, handler: js.Function1[Event, Unit]): Unit = js.native
def attach(handlers: js.Object): Unit = js.native
def detach(eventType: String, handler: js.Function1[Event, Unit]): Unit = js.native
def detach(handlers: js.Object): Unit = js.native
def fire(eventType: String, event: js.Object): Unit = js.native
def responds(eventType: String): Boolean = js.native
def removeOn(events: js.Object): Unit = js.native
def removeOnMove(): Unit = js.native
def removeOnDown(): Unit = js.native
def removeOnDrag(): Unit = js.native
def removeOnUp(): Unit = js.native
}
object EventType {
val mousedown = "mousedown"
val mouseup = "mouseup"
val mousedrag = "mousedrag"
val click = "click"
val doubleclick = "doubleclick"
val mousemove = "mousemove"
val mouseenter = "mouseenter"
val mouseleave = "mouseleave"
}
@JSName("paper.Raster")
class Raster protected() extends Item {
def this(source: html.Canvas) = this()
def this(source: html.Canvas, position: Point) = this()
def this(source: html.Image) = this()
def this(source: html.Image, position: Point) = this()
def this(sourceId: String) = this()
def this(sourceId: String, position: Point) = this()
var size: Size = js.native
def width: Int = js.native
def height: Int = js.native
def resolution: Int = js.native
def image: html.Image = js.native
def canvas: html.Canvas = js.native
def context: CanvasRenderingContext2D = js.native
var source: Any = js.native
def getSubCanvas(rect: Rectangle): html.Canvas = js.native
def getSubRaster(rect: Rectangle): Raster = js.native
def toDataURL(): String = js.native
def drawImage(image: html.Image, point: Point): Unit = js.native
def drawImage(image: html.Canvas, point: Point): Unit = js.native
def getAverageColor(path: Path): Color = js.native
def getAverageColor(rect: Rectangle): Color = js.native
def getAverageColor(point: Point): Color = js.native
def getPixel(x: Int, y: Int): Color = js.native
def getPixel(point: Point): Color = js.native
def setPixel(x: Int, y: Int, color: Color): Unit = js.native
def setPixel(point: Point, color: Color): Unit = js.native
def createImageData(size: Size): ImageData = js.native
def getImageData(rect: Rectangle): ImageData = js.native
def setImageData(data: ImageData, point: Point): Unit = js.native
}
@JSName("paper.Group")
/** [[http://paperjs.org/reference/group/]] */
class Group protected() extends Item {
def this(children: js.Array[Item]) = this()
//ctor body ignored by scalajs, can"t use ??? here
def this(properties: js.Object) = this()
var clipped: Boolean = js.native
}
@JSName("paper.Shape")
class Shape extends Item {
def `type`: String = js.native
var size: Size = js.native
var radius: Any = js.native
}
@JSName("paper.Shape.Rectangle")
class ShapeRectangle protected() extends Shape {
def this(rectangle: Rectangle, radius: Double = 0) = this()
def this(point: Point, size: Size) = this()
def this(from: Point, to: Point) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.Shape.Circle")
class ShapeCircle protected() extends Shape {
def this(center: Point, radius: Double) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.Shape.Ellipse")
class ShapeEllipse protected() extends Shape {
def this(rectangle: Rectangle) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.CompoundPath")
class CompoundPath protected() extends PathItem {
def this(obj: js.Object) = this()
def this(pathData: String) = this()
var clockwise: Boolean = js.native
def firstSegment: Segment = js.native
def lastSegment: Segment = js.native
def curves: js.Array[Curve] = js.native
def firstCurve: Curve = js.native
def lastCurve: Curve = js.native
def area: Double = js.native
def reverse(): Unit = js.native
}
object StrokeCap {
val Round = "round"
val Square = "square"
val Butt = "butt"
}
object StrokeJoin {
val Miter = "miter"
val Round = "round"
val Bevel = "bevel"
}
object WindingRule {
val NonZero = "nonzero"
val EvenOdd = "evenodd"
}
object BlendMode {
val normal = "normal"
val multiply = "multiply"
val screen = "screen"
val overlay = "overlay"
val softLight = "soft-light"
val hardLight = "hard-light"
val colorDodge = "color-dodge"
val colorBurn = "color-burn"
val darken = "darken"
val lighten = "lighten"
val difference = "difference"
val exclusion = "exclusion"
val hue = "hue"
val saturation = "saturation"
val luminosity = "luminosity"
val color = "color"
val add = "add"
val subtract = "subtract"
val average = "average"
val pinLight = "pin-light"
val negation = "negation"
val sourceOver = "source-over"
val sourceIn = "source-in"
val sourceOut = "source-out"
val sourceAtop = "source-atop"
val destinationOver = "destination-over"
val destinationIn = "destination-in"
val destinationOut = "destination-out"
val destinationAtop = "destination-atop"
val lighter = "lighter"
val darker = "darker"
val copy = "copy"
val xor = "xor"
}
@JSName("paper.Project")
class Project(canvas: html.Canvas) extends js.Object {
def view: View = js.native
var currentStyle: Style = js.native
def index: Int = js.native
def selectedItems: js.Array[Item] = js.native
def layers: js.Array[Layer] = js.native
def activeLayer: Layer = js.native
def symbols: Array[Symbol] = js.native
def activate(): Unit = js.native
def clear(): Unit = js.native
def isEmpty(): Boolean = js.native
def remove(): Unit = js.native
def selectAll(): Unit = js.native
def deselectAll(): Unit = js.native
// tolerance: Double = 0,
// itemClass: String = null,
// includeFill: Boolean = true,
// includeStroke: Boolean = true,
// includeSegments: Boolean = true,
// includeCurves: Boolean = false,
// includeHandles: Boolean = false,
// includeEnds: Boolean = false,
// includeBounds: Boolean = false,
// includeCenter: Boolean = false,
// onlyGuideObjects: Boolean = false,
// onlySelectedObjects: Boolean = false
def hitTest(point: Point, options: js.Object): HitResult = js.native
def getItems(criteria: js.Object): js.Array[Item] = js.native
def getItem(criteria: js.Object): Item = js.native
def exportJSON(asString: Boolean = true, precision: Int = 5): String = js.native
def importJSON(json: String): Unit = js.native
def exportSVG(asString: Boolean = false,
precision: Int = 5, matchShape: Boolean = false): AnyRef = js.native
def importSVG(svgElementOrString: AnyRef,
expandShapes: Boolean = false): Item = js.native
}
object ItemClass {
val Any: String = null
val Group = "Group"
val Layer = "Layer"
val Path = "Path"
val CompoundPath = "CompoundPath"
val Shape = "Shape"
val Raster = "Raster"
val PlacedSymbol = "PlacedSymbol"
val PointText = "PointText"
}
@JSName("paper.HitResult")
class HitResult extends js.Object {
@JSName("type")
def resultType: String = js.native
def name: String = js.native
def item: Item = js.native
def location: CurveLocation = js.native
def color: Color = js.native
def segment: Segment = js.native
def point: Point = js.native
}
@JSName("paper.Segment")
class Segment protected() extends js.Object {
def this(point: Point) = this()
def this(point: Point, handleIn: Point) = this()
def this(point: Point, handleIn: Point, handleOut: Point) = this()
def this(obj: js.Object) = this()
var point: Point = js.native
var handleIn: Point = js.native
var handleOut: Point = js.native
var linear: Boolean = js.native
var selected: Boolean = js.native
def index: Int = js.native
def path: Path = js.native
def curve: Curve = js.native
def location: CurveLocation = js.native
}
@JSName("paper.Curve")
class Curve protected() extends js.Object {
def this(segment1: Segment, segment2: Segment) = this()
def this(point1: Point, handle1: Point, handle2: Point, point2: Point) = this()
//properties
var point1: Point = js.native
var point2: Point = js.native
var handle1: Point = js.native
var handle2: Point = js.native
def segment1: Segment = js.native
def segment2: Segment = js.native
def path: Path = js.native
def index: Int = js.native
def next: Curve = js.native
def previous: Curve = js.native
var selected: Boolean = js.native
def length: Double = js.native
def bounds: Rectangle = js.native
def strokeBounds: Rectangle = js.native
def handleBounds: Rectangle = js.native
//methods
def isLinear(): Boolean = js.native
def divide(offset: Double = 0.5, isParameter: Boolean = false): Curve = js.native
def split(offset: Double = 0.5, isParameter: Boolean = false): Path = js.native
def reverse(): Curve = js.native
def remove(): Boolean = js.native
override def clone(): Curve = js.native
def getParameterAt(offset: Double): Double = js.native
def getParameterAt(offset: Double, start: Double): Double = js.native
def getParameterOf(point: Point): Double = js.native
def getLocationAt(offset: Double, isParameter: Boolean = false): CurveLocation = js.native
def getLocationOf(point: Point): CurveLocation = js.native
def getPointAt(offset: Double, isParameter: Boolean): Point = js.native
def getTangentAt(offset: Double, isParameter: Boolean): Point = js.native
def getNormalAt(offset: Double, isParameter: Boolean): Point = js.native
def getCurvatureAt(offset: Double, isParameter: Boolean): Point = js.native
}
@JSName("paper.CurveLocation")
class CurveLocation(val curve: Curve, val parameter: Double, val point: Point) extends js.Object {
def segment: Segment = js.native
def intersection: CurveLocation = js.native
def path: PathItem = js.native
def index: Int = js.native
def offset: Double = js.native
def curveOffset: Double = js.native
def tangent: Point = js.native
def normal: Point = js.native
def distance: Double = js.native
}
object BoundingRectangleCornerNames {
val topLeft = "top-left"
val topRight = "top-right"
val bottomLeft = "bottom-left"
val bottomRight = "bottom-right"
val leftCenter = "left-center"
val topCenter = "top-center"
val rightCenter = "right-center"
val bottomCenter = "bottom-center"
}
@JSName("paper.Symbol")
class Symbol(item: Item, dontCenter: Boolean = false) extends Item {
var definition: Item = js.native
def place(): PlacedSymbol = js.native
def place(position: Point): PlacedSymbol = js.native
}
@JSName("paper.PlacedSymbol")
class PlacedSymbol protected() extends Item {
def this(symbol: Symbol, point: Point) = this()
def this(symbol: Symbol) = this()
var symbol: Symbol = js.native
}
@JSName("paper.View")
trait View extends js.Object {
def draw(): Unit = js.native
def element: html.Canvas = js.native
def pixelRatio: Double = js.native
def resolution: Int = js.native
def viewSize: Size = js.native
def bounds: Rectangle = js.native
def size: Size = js.native
var center: Point = js.native
var zoom: Double = js.native
var onFrame: js.Function1[Event, Unit] = js.native
var onResize: js.Function1[Event, Unit] = js.native
def remove(): Unit = js.native
def isVisible(): Boolean = js.native
def scrollBy(point: Point): Unit = js.native
def play(): Unit = js.native
def pause(): Unit = js.native
def update(): Unit = js.native
def projectToView(point: Point): Point = js.native
def viewToProject(point: Point): Point = js.native
def attach(eventType: String, handler: js.Function1[Event, Unit]): Unit = js.native
def attach(handlers: js.Object): Unit = js.native
def detach(eventType: String, handler: js.Function1[Event, Unit]): Unit = js.native
def detach(handlers: js.Object): Unit = js.native
def fire(eventType: String, event: js.Object): Unit = js.native
def responds(eventType: String): Boolean = js.native
}
@JSName("paper.PathItem")
class PathItem extends Item {
//properties
var pathData: String = js.native
//methods
def getIntersections(path: PathItem, sorted: Boolean = false): js.Array[CurveLocation] = js.native
def smooth(): Unit = js.native
def moveTo(p: Point): Unit = js.native
def lineTo(p: Point): Unit = js.native
def cubicCurveTo(handle1: Point, handle2: Point, to: Point): Unit = js.native
def quadraticCurveTo(handle: Point, to: Point): Unit = js.native
def curveTo(through: Point, to: Point, parameter: Double = 0.5): Unit = js.native
def arcTo(through: Point, to: Point): Unit = js.native
def arcTo(to: Point, clockwise: Boolean = true): Unit = js.native
def closePath(join: Boolean): Unit = js.native
def moveBy(to: Point): Unit = js.native
def lineBy(to: Point): Unit = js.native
def curveBy(through: Point, to: Point, parameter: Double = 0.5): Unit = js.native
def cubicCurveBy(handle1: Point, handle2: Point, to: Point): Unit = js.native
def quadraticCurveBy(handle: Point, to: Point): Unit = js.native
def arcBy(through: Point, to: Point): Unit = js.native
def arcBy(to: Point, clockwise: Boolean = true): Unit = js.native
}
@JSName("paper.Path")
class Path() extends PathItem {
def this(segments: js.Array[Segment]) = this()
def this(obj: js.Object) = this()
def this(pathData: String) = this()
//properties
var segments: js.Array[Segment] = js.native
def firstSegment: Segment = js.native
def lastSegment: Segment = js.native
def curves: js.Array[Curve] = js.native
def firstCurve: Curve = js.native
def lastCurve: Curve = js.native
var closed: Boolean = js.native
def length: Double = js.native
def area: Double = js.native
var fullySelected: Boolean = js.native
var clockwise: Boolean = js.native
def interiorPoint: Point = js.native
def add(segment: Segment): Segment = js.native
def add(segment: Point): Segment = js.native
def insert(index: Int, segment: Segment): Segment = js.native
def addSegments(segments: js.Array[Segment]): js.Array[Segment] = js.native
def insertSegments(index: Int, segments: js.Array[Segment]): js.Array[Segment] = js.native
def removeSegment(index: Int): Segment = js.native
def removeSegments(): js.Array[Segment] = js.native
def removeSegments(from: Int, to: Int = 0): js.Array[Segment] = js.native
def flatten(maxDistance: Double): Unit = js.native
override def reduce(): Item = js.native
def simplify(tolerance: Double = 2.5): Unit = js.native
def split(offset: Int): Path = js.native
def split(location: CurveLocation): Path = js.native
def split(index: Int, parameter: Double): Path = js.native
def reverse(): Unit = js.native
def join(path: Path): Unit = js.native
def getLocationAt(offset: Double, isParameter: Boolean = false): CurveLocation = js.native
def getLocationOf(point: Point): CurveLocation = js.native
def getPointAt(offset: Double, isParameter: Boolean): Point = js.native
def getTangentAt(offset: Double, isParameter: Boolean): Point = js.native
def getNormalAt(offset: Double, isParameter: Boolean): Point = js.native
def getCurvatureAt(offset: Double, isParameter: Boolean): Point = js.native
def getNearestLocation(point: Point): CurveLocation = js.native
def getNearestPoint(point: Point): Point = js.native
}
@JSName("paper.Path.Line")
class PathLine protected() extends Path {
def this(from: Point, to: Point) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.Path.Circle")
class PathCircle protected() extends Path {
def this(center: Point, radius: Double) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.Path.Rectangle")
class PathRectangle protected() extends Path {
def this(rectangle: Rectangle, radius: Double) = this()
def this(point: Point, size: Size) = this()
def this(from: Point, to: Point) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.Path.Ellipse")
class PathEllipse protected() extends Path {
def this(rectangle: Rectangle) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.Path.Arc")
class PathArc protected() extends Path {
def this(from: Point, through: Point, to: Point) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.Path.RegularPolygon")
class PathRegularPolygon protected() extends Path {
def this(center: Point, sides: Int, radius: Double) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.Path.Star")
class PathStar protected() extends Path {
def this(center: Point, points: Int, radius1: Double, radius2: Double) = this()
def this(obj: js.Object) = this()
}
@JSName("paper.Color")
class Color(val name: String) extends js.Object
object Color {
val Black = new Color("black")
}
@JSName("paper.Gradient")
class Gradient(var stops: js.Array[GradientStop], radial: Boolean)
@JSName("paper.GradientStop")
class GradientStop(var color: Color, var rampPoint: Double) {
def this(color: Color) = this(color, 0)
def this() = this(Color.Black, 0)
}
@JSName("paper.Point")
class Point(x: Double, y: Double) extends js.Object {
override def clone: Point = js.native
def add(p: Point): Point = js.native
@JSName("add")
def #+(p: Point): Point = add(p)
def subtract(p: Point): Point = js.native
@JSName("subtract")
def #-(p: Point): Point = subtract(p)
def multiply(p: Point): Point = js.native
@JSName("multiply")
def #*(p: Point): Point = multiply(p)
def divide(p: Point): Point = js.native
@JSName("divide")
def #/(p: Point): Point = divide(p)
def modulo(p: Point): Point = js.native
@JSName("modulo")
def #%(p: Point): Point = modulo(p)
var length: Double = js.native
var angle: Double = js.native
var angleInRadians: Double = js.native
def quadrant: Int = js.native
def selected: UndefOr[Boolean] = js.native
def normalize(): Point = js.native
def rotate(angle: Double, center: Point = origin): Point = js.native
def transform(m: Matrix): Point = js.native
}
object Point {
val origin = new Point(0, 0)
}
@JSName("paper.Matrix")
class Matrix(val a: Double, val b: Double, val c: Double, val d: Double,
val tx: Double, val ty: Double) extends js.Object {
def translation: Point = js.native
def scaling: Point = js.native
def rotation: Point = js.native
def set(a: Double, b: Double, c: Double, d: Double,
tx: Double, ty: Double): Unit = js.native
override def clone: Matrix = js.native
def reset: Unit = js.native
def apply: Boolean = js.native
def translate(p: Point): Matrix = js.native
def translate(dx: Double, dy: Double): Matrix = js.native
def scale(scale: Double, center: Point = origin): Matrix = js.native
def scale(hor: Double, ver: Double): Matrix = js.native
def scale(hor: Double, ver: Double, center: Point): Matrix = js.native
def rotate(angle: Double, center: Point = origin): Matrix = js.native
def rotate(angle: Double, x: Double, y: Double): Matrix = js.native
def shear(shear: Double, center: Point = origin): Matrix = js.native
def shear(hor: Double, ver: Double): Matrix = js.native
def shear(hor: Double, ver: Double, center: Point): Matrix = js.native
def skew(skew: Double, center: Point = origin): Matrix = js.native
def skew(hor: Double, ver: Double): Matrix = js.native
def skew(hor: Double, ver: Double, center: Point): Matrix = js.native
def concatenate(mx: Matrix): Matrix = js.native
def preConcatenate(mx: Matrix): Matrix = js.native
def isIdentity(): Boolean = js.native
def isInvertible(): Boolean = js.native
def isSingular(): Boolean = js.native
def transform(point: Point): Point = js.native
def transform(src: js.Array[Double], dst: js.Array[Double], count: Int): js.Array[Double] = js.native
def inverseTransform(point: Point): Point = js.native
def decompose(): Matrix = js.native
def inverted(): Matrix = js.native
def applyToContext(ctx: CanvasRenderingContext2D): Unit = js.native
}
@JSName("paper.Size")
class Size(val width: Double, val height: Double) extends js.Object {
def add(n: Double): Size = js.native
def add(s: Size): Size = js.native
def subtract(n: Double): Size = js.native
def subtract(s: Size): Size = js.native
def multiply(n: Double): Size = js.native
def multiply(s: Size): Size = js.native
def divide(n: Double): Size = js.native
def divide(s: Size): Size = js.native
def modulo(n: Double): Size = js.native
def modulo(s: Size): Size = js.native
def isZero(): Boolean = js.native
def isNaN(): Boolean = js.native
def round(): Size = js.native
def ceil(): Size = js.native
def floor(): Size = js.native
def abs(): Size = js.native
}
@JSName("paper.Size")
object Size extends js.Object {
def min(size1: Size, size2: Size): Size = js.native
def max(size1: Size, size2: Size): Size = js.native
def random(): Size = js.native
}
@JSName("paper.Rectangle")
class Rectangle(val point: Point, val size: Size) extends js.Object {
def this(x: Double, y: Double, w: Double, h: Double) = this(null, null: Size)
def this(from: Point, to: Point) = this(null, null: Size)
def x: Double = js.native
def y: Double = js.native
def width: Double = js.native
def height: Double = js.native
def left: Double = js.native
def top: Double = js.native
def right: Double = js.native
def bottom: Double = js.native
def center: Point = js.native
def topLeft: Point = js.native
def topRight: Point = js.native
def bottomLeft: Point = js.native
def bottomRight: Point = js.native
def leftCenter: Point = js.native
def topCenter: Point = js.native
def rightCenter: Point = js.native
def bottomCenter: Point = js.native
def area: Double = js.native
def selected: UndefOr[Boolean] = js.native
def isEmpty(): Boolean = js.native
def contains(point: Point): Boolean = js.native
def contains(rect: Rectangle): Boolean = js.native
def intersects(rect: Rectangle): Boolean = js.native
def intersect(rect: Rectangle): Rectangle = js.native
def unite(rect: Rectangle): Rectangle = js.native
def include(point: Point): Rectangle = js.native
def expand(amount: Double): Rectangle = js.native
def expand(amount: Size): Rectangle = js.native
def expand(hor: Double, ver: Double): Rectangle = js.native
def scale(amount: Double): Rectangle = js.native
def scale(hor: Double, ver: Double): Rectangle = js.native
def unite(path: PathItem): PathItem = js.native
def intersect(path: PathItem): PathItem = js.native
def subtract(path: PathItem): PathItem = js.native
def exclude(path: PathItem): Group = js.native
def divide(path: PathItem): Group = js.native
}
@JSName("paper.TextItem")
class TextItem extends Item {
var content: String = js.native
var fontFamily: String = js.native
var fontWeight: String = js.native
//Either String or Int. Default 10
var fontSize: Any = js.native
var leading: Double = js.native
var justification: String = js.native
}
@JSName("paper.PointText")
class PointText(var point: Point) extends TextItem {
def this(props: js.Object) = this(null)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment