code
stringlengths
10
1.34M
language
stringclasses
1 value
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sha3 // rc stores the round constants for use in the ι step. var rc = [24]uint64{ 0x0000000000000001, 0x0000000000008082, 0x800000000000808A, 0x800...
Go
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build go1.4 package sha3 import ( "crypto" ) func init() { crypto.RegisterHash(crypto.SHA3_224, New224) crypto.RegisterHash(crypto.SHA3_256, New256) ...
Go
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sha3 // This file defines the ShakeHash interface, and provides // functions for creating SHAKE instances, as well as utility // functions for hashing ...
Go
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sha3 import ( "encoding/binary" ) // spongeDirection indicates the direction bytes are flowing through the sponge. type spongeDirection int const ( ...
Go
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package sha3 implements the SHA-3 fixed-output-length hash functions and // the SHAKE variable-output-length hash functions defined by FIPS-202. // // Both t...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package ripemd160 implements the RIPEMD-160 hash algorithm. package ripemd160 // RIPEMD-160 is designed by by Hans Dobbertin, Antoon Bosselaers, and Bart //...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // RIPEMD-160 block step. // In its own file so that a faster assembly or C version // can be substituted easily. package ripemd160 // work buffer indices and...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package otr implements the Off The Record protocol as specified in // http://www.cypherpunks.ca/otr/Protocol-v2-3.1.0.html package otr import ( "bytes" "c...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This file implements the Socialist Millionaires Protocol as described in // http://www.cypherpunks.ca/otr/Protocol-v2-3.1.0.html. The protocol // specificati...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package clearsign generates and processes OpenPGP, clear-signed data. See // RFC 4880, section 7. // // Clearsigned messages are cryptographically signed, bu...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package s2k implements the various OpenPGP string-to-key transforms as // specified in RFC 4800 section 3.7.1. package s2k import ( "crypto" "hash" "io" ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package openpgp implements high level operations on OpenPGP messages. package openpgp import ( "crypto" _ "crypto/sha256" "golang.org/x/crypto/openpgp/ar...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "bytes" "image" "image/jpeg" "io" "io/ioutil" ) const UserAttrImageSubpacket = 1 // UserAttribute is capable of storing other ty...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "crypto" "encoding/binary" "golang.org/x/crypto/openpgp/errors" "golang.org/x/crypto/openpgp/s2k" "io" "strconv" ) // OnePassSig...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "crypto" "crypto/dsa" "crypto/rsa" "encoding/binary" "golang.org/x/crypto/openpgp/errors" "golang.org/x/crypto/openpgp/s2k" "has...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "crypto" "crypto/md5" "crypto/rsa" "encoding/binary" "fmt" "hash" "io" "math/big" "strconv" "time" "golang.org/x/crypto/ope...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "crypto/cipher" "crypto/sha1" "crypto/subtle" "golang.org/x/crypto/openpgp/errors" "hash" "io" "strconv" ) // SymmetricallyEncr...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "bytes" "crypto" "crypto/dsa" "crypto/ecdsa" "crypto/elliptic" "crypto/rsa" "crypto/sha1" _ "crypto/sha256" _ "crypto/sha512" ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "compress/bzip2" "compress/flate" "compress/zlib" "golang.org/x/crypto/openpgp/errors" "io" "strconv" ) // Compressed represents...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "bytes" "crypto/cipher" "crypto/dsa" "crypto/rsa" "crypto/sha1" "golang.org/x/crypto/openpgp/elgamal" "golang.org/x/crypto/openp...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "crypto/rsa" "encoding/binary" "golang.org/x/crypto/openpgp/elgamal" "golang.org/x/crypto/openpgp/errors" "io" "math/big" "strco...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // OpenPGP CFB Mode. http://tools.ietf.org/html/rfc4880#section-13.9 package packet import ( "crypto/cipher" ) type ocfbEncrypter struct { b cipher.B...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "crypto" "encoding/binary" "fmt" "io" "strconv" "time" "golang.org/x/crypto/openpgp/errors" "golang.org/x/crypto/openpgp/s2k" ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "io" "io/ioutil" "strings" ) // UserId contains text that is intended to represent the name and email // address of the key holder....
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "golang.org/x/crypto/openpgp/errors" "io" ) // Reader reads packets from an io.Reader and allows packets to be 'unread' so // that t...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "bytes" "crypto/cipher" "io" "strconv" "golang.org/x/crypto/openpgp/errors" "golang.org/x/crypto/openpgp/s2k" ) // This is the ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "encoding/binary" "io" ) // LiteralData represents an encrypted file. See RFC 4880, section 5.9. type LiteralData struct { IsBinary...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package packet implements parsing and serialization of OpenPGP packets, as // specified in RFC 4880. package packet import ( "bufio" "crypto/aes" "crypto...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "bytes" "golang.org/x/crypto/openpgp/errors" "io" "io/ioutil" ) // OpaquePacket represents an OpenPGP packet as raw, unparsed data...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "crypto" "crypto/rand" "io" "time" ) // Config collects a number of parameters along with sensible defaults. // A nil *Config is v...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package errors contains common error types for the OpenPGP packages. package errors import ( "strconv" ) // A StructuralError is returned when OpenPGP dat...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package openpgp import ( "crypto/rsa" "golang.org/x/crypto/openpgp/armor" "golang.org/x/crypto/openpgp/errors" "golang.org/x/crypto/openpgp/packet" "io" ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package elgamal implements ElGamal encryption, suitable for OpenPGP, // as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on // Discret...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package armor import ( "encoding/base64" "io" ) var armorHeaderSep = []byte(": ") var blockEnd = []byte("\n=") var newline = []byte("\n") var armorEndOfLine...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package armor implements OpenPGP ASCII Armor, see RFC 4880. OpenPGP Armor is // very similar to PEM except that it has an additional CRC checksum. package ar...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package openpgp import ( "crypto" "golang.org/x/crypto/openpgp/armor" "golang.org/x/crypto/openpgp/errors" "golang.org/x/crypto/openpgp/packet" "golang.or...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package openpgp import "hash" // NewCanonicalTextHash reformats text written to it into the canonical // form and then applies the hash h. See RFC 4880, sect...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package bcrypt implements Provos and Mazières's bcrypt adaptive hashing // algorithm. See http://www.usenix.org/event/usenix99/provos/provos.pdf package bcry...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bcrypt import "encoding/base64" const alphabet = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" var bcEncoding = base64.NewEncodi...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0. A key derivation function is useful when encrypting data...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package twofish implements Bruce Schneier's Twofish encryption algorithm. package twofish // Twofish is defined in http://www.schneier.com/paper-twofish-pap...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "crypto" "crypto/rand" "fmt" "io" "sync" _ "crypto/sha1" _ "crypto/sha256" _ "crypto/sha512" ) // These are string constants in ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "errors" "fmt" "io" "math/rand" "net" "strconv" "strings" "sync" "time" ) // Listen requests the remote peer open a listening so...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "crypto" "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "errors" "io" "math/big" ) const ( kexAlgoDH1SHA1 = "diffie-hellman-grou...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "io" "sync" ) // buffer provides a linked list buffer for data exchange // between producer and consumer. Theoretically the buffer is /...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "encoding/binary" "fmt" "io" "log" "sync" "sync/atomic" ) // debugMux, if set, causes messages in the connection protocol to be // ...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "bytes" "errors" "fmt" "io" "net" "sort" "time" ) // These constants from [PROTOCOL.certkeys] represent the algorithm names // for...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This package contains integration tests for the // code.google.com/p/go.crypto/ssh package. package test
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build darwin dragonfly freebsd linux,!appengine netbsd openbsd // Package terminal provides support functions for dealing with terminals, as // commonly fo...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build darwin dragonfly freebsd netbsd openbsd package terminal import "syscall" const ioctlReadTermios = syscall.TIOCGETA const ioctlWriteTermios = sysca...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package terminal import ( "bytes" "io" "sync" "unicode/utf8" ) // EscapeCodes contains escape sequences that can be written to the terminal in // order to...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package terminal // These constants are declared here, rather than importing // them from the syscall package as some syscall packages, even // on linux, for e...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build windows // Package terminal provides support functions for dealing with terminals, as // commonly found on UNIX systems. // // Putting a terminal int...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "bytes" "errors" "fmt" "io" ) // clientAuthenticate authenticates with the remote server. See RFC 4252. func (c *connection) clientAu...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh // Session implements an interactive session described in // "RFC 4254, section 6". import ( "bytes" "errors" "fmt" "io" "io/ioutil" "sync" ...
Go
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package agent import ( "bytes" "crypto/rand" "crypto/subtle" "errors" "fmt" "sync" "golang.org/x/crypto/ssh" ) type privKey struct { signer ssh.Sign...
Go
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package agent import ( "errors" "io" "net" "sync" "golang.org/x/crypto/ssh" ) // RequestAgentForwarding sets up agent forwarding for the session. // For...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package agent import ( "crypto/rsa" "encoding/binary" "fmt" "io" "log" "math/big" "golang.org/x/crypto/ssh" ) // Server wraps an Agent and uses it to ...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* Package agent implements a client to an ssh-agent daemon. References: [PROTOCOL.agent]: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCO...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh // Message authentication support import ( "crypto/hmac" "crypto/sha1" "hash" ) type macMode struct { keySize int new func(key []byte) h...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "crypto/rand" "errors" "fmt" "io" "log" "net" "sync" ) // debugHandshake, if set, prints messages sent and received. Key // excha...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "bytes" "encoding/binary" "errors" "fmt" "io" "math/big" "reflect" "strconv" ) // These are SSH message type numbers. They are sc...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "bytes" "crypto" "crypto/dsa" "crypto/ecdsa" "crypto/elliptic" "crypto/rsa" "crypto/x509" "encoding/asn1" "encoding/base64" "enc...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "bufio" "errors" "io" ) const ( gcmCipherID = "aes128-gcm@openssh.com" ) // packetConn represents a transport that implements packet...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "fmt" "net" ) // OpenChannelError is returned if the other side rejects an // OpenChannel request. type OpenChannelError struct { Reas...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "crypto/aes" "crypto/cipher" "crypto/rc4" "crypto/subtle" "encoding/binary" "errors" "fmt" "hash" "io" ) const ( packetSizeMult...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "encoding/binary" "errors" "fmt" "io" "log" "sync" ) const ( minPacketLength = 9 // channelMaxPacket contains the maximum number ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "bytes" "errors" "fmt" "io" "net" ) // The Permissions type holds fine-grained permissions that are // specific to a user or a speci...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* Package ssh implements an SSH client and server. SSH is a transport security protocol, an authentication protocol and a family of application protocols. The...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "errors" "fmt" "net" "sync" ) // Client implements a traditional SSH client that supports shells, // subprocesses, port forwarding an...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package ocsp parses OCSP responses as specified in RFC 2560. OCSP responses // are signed messages attesting to the validity of a certificate for a small // ...
Go
package main import ( "bufio" "fmt" "log" "os" "code.google.com/p/draw2d/draw2d" "image" "image/draw" "image/png" "math" ) func saveToPngFile(filePath string, m image.Image) { f, err := os.Create(filePath) if err != nil { log.Println(err) os.Exit(1) } defer f.Close() b := bufi...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package postscript import () //int array array -> Create array of length int func array(interpreter *Interpreter) { interpreter.Push(make([]Value, interpreter.PopInt())) } //array length int -> Return number...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff //Arithmetic and Math Operators package postscript import ( "math" "math/rand" ) // begin Primitive Operator implementation //num1 num2 add sum -> Return num1 plus num2 func add(interpreter *Interpreter) {...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package postscript import ( "code.google.com/p/draw2d/draw2d" "io" "log" "os" "strconv" ) type Interpreter struct { valueStack ValueStack dictionaryStack DictionaryStack gc draw2d.Gra...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package postscript func eq(interpreter *Interpreter) { value1 := interpreter.Pop() value2 := interpreter.Pop() interpreter.Push(value1 == value2) } func ne(interpreter *Interpreter) { value1 := interpreter...
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // postscript scanner derived form the scanner package of go sources package postscript import ( "bytes" "fmt" "io" "os" "unicode" "unicode/utf8" ) // A ...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package postscript type OperatorFunc func(interpreter *Interpreter) type PrimitiveOperator struct { f OperatorFunc } func NewOperator(f OperatorFunc) *PrimitiveOperator { return &PrimitiveOperator{f} } fun...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff // Graphics operators package postscript import ( "code.google.com/p/draw2d/draw2d" "image/color" "log" "math" ) //Path Construction Operators func newpath(interpreter *Interpreter) { interpreter.GetGraph...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package postscript import ( "log" ) //int dict dict -> Create dictionary with capacity for int elements func dict(interpreter *Interpreter) { interpreter.Push(NewDictionary(interpreter.PopInt())) } //dict l...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package postscript type ProcedureDefinition struct { Values []Value } func NewProcedureDefinition() *ProcedureDefinition { proceduredef := new(ProcedureDefinition) proceduredef.Values = make([]Value, 0, 100...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff //Operand Stack Manipulation Operators package postscript //any pop – -> Discard top element func pop(interpreter *Interpreter) { interpreter.Pop() } //any1 any2 exch any2 any1 -> Exchange top two elements ...
Go
package postscript import ( "fmt" "log" ) // dictionary copy conflict with stack copy // type dicriminant func commonCopy(interpreter *Interpreter) { switch v := interpreter.Peek().(type) { case float64: copystack(interpreter) case Dictionary: copydict(interpreter) default: panic(fmt.Sprintf("Not yet impl...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package postscript import ( "log" ) // any exec – Execute arbitrary object func exec(interpreter *Interpreter) { value := interpreter.Pop() if pdef, ok := value.(*ProcedureDefinition); ok { NewProcedure(p...
Go
// Copyright 2010 The postscript-go Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff // Miscellaneous Operators package postscript import ( //"log" ) //proc bind proc Replace operator names in proc with operators; perform idiom recognition func bind(interpreter *Interpreter) { pdef := interp...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package draw2d type DashVertexConverter struct { command VertexCommand next VertexConverter x, y, distance float64 dash []float64 currentDash int dashOffset float64 } func NewD...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 17/05/2011 by Laurent Le Goff package curve import ( "math" ) const ( CurveCollinearityEpsilon = 1e-30 CurveAngleToleranceEpsilon = 0.01 ) //mu ranges from 0 to 1, start to end of curve func (c *CubicCurveFloat64) ArbitraryPoint(mu float6...
Go
package main import "code.google.com/p/draw2d/draw2d/curve" import "testing" import __os__ "os" import __regexp__ "regexp" var tests = []testing.InternalTest{ {"curve.TestCubicCurveRec", curve.TestCubicCurveRec}, {"curve.TestCubicCurve", curve.TestCubicCurve}, {"curve.TestCubicCurveAdaptiveRec", curve.TestCubicCur...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff package draw2d import ( "code.google.com/p/freetype-go/freetype/raster" "math" ) func SegmentArc(t LineTracer, x, y, rx, ry, start, angle, scale float64) { end := start + angle clockWise := true if angle < 0 { ...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 17/05/2011 by Laurent Le Goff package curve import ( "math" ) //X1, Y1, X2, Y2, X3, Y3 float64 type QuadCurveFloat64 [6]float64 func (c *QuadCurveFloat64) Subdivide(c1, c2 *QuadCurveFloat64) { // Calculate all the mid-points of the line segm...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 17/05/2011 by Laurent Le Goff package curve import ( "math" ) const ( CurveRecursionLimit = 32 ) // X1, Y1, X2, Y2, X3, Y3, X4, Y4 float64 type CubicCurveFloat64 [8]float64 type LineTracer interface { LineTo(x, y float64) } func (c *Cubic...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package draw2d type DemuxConverter struct { converters []VertexConverter } func NewDemuxConverter(converters ...VertexConverter) *DemuxConverter { return &DemuxConverter{converters} } func (dc *DemuxConverter) Nex...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 13/12/2010 by Laurent Le Goff package draw2d import ( "code.google.com/p/freetype-go/freetype/truetype" "io/ioutil" "log" "path" ) var ( fontFolder = "../resource/font/" fonts = make(map[string]*truetype.Font) ) type FontStyle byte c...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff // see http://pippin.gimp.org/image_processing/chap_resampling.html package draw2d import ( "image" "image/color" "image/draw" "math" ) type ImageFilter int const ( LinearFilter ImageFilter = iota BilinearFilt...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff package draw2d import ( "math" ) var ( CurveRecursionLimit = 32 CurveCollinearityEpsilon = 1e-30 CurveAngleToleranceEpsilon = 0.01 ) /* The function has the following parameters: approximationScale :...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff package draw2d import ( "fmt" "math" ) type PathCmd int const ( MoveTo PathCmd = iota LineTo QuadCurveTo CubicCurveTo ArcTo Close ) type PathStorage struct { commands []PathCmd vertices []float64 x, y ...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff package draw2d type VertexCommand byte const ( VertexNoCommand VertexCommand = iota VertexStartCommand VertexJoinCommand VertexCloseCommand VertexStopCommand ) type VertexConverter interface { NextCommand(cmd ...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff package draw2d import ( "code.google.com/p/freetype-go/freetype/raster" "math" ) type MatrixTransform [6]float64 const ( epsilon = 1e-6 ) func (tr MatrixTransform) Determinant() float64 { return tr[0]*tr[3] - t...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff package draw2d import ( "code.google.com/p/freetype-go/freetype/raster" "math" ) func arc(t VertexConverter, x, y, rx, ry, start, angle, scale float64) (lastX, lastY float64) { end := start + angle clockWise := t...
Go
// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff package draw2d import ( "math" ) func distance(x1, y1, x2, y2 float64) float64 { dx := x2 - x1 dy := y2 - y1 return float64(math.Sqrt(dx*dx + dy*dy)) } func vectorDistance(dx, dy float64) float64 { return float...
Go