diff --git a/pdf2d/samples/android/android.go b/pdf2d/samples/android/android.go deleted file mode 100644 index 600e080..0000000 --- a/pdf2d/samples/android/android.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2010 The draw2d Authors. All rights reserved. -// created: 21/11/2010 by Laurent Le Goff, Stani Michiels - -// Draw an android avatar to android.png -package main - -import ( - "image/color" - "math" - - "github.com/stanim/draw2d" - "github.com/stanim/draw2d/pdf2d" -) - -func main() { - // Initialize the graphic context on a pdf document - dest := pdf2d.NewPdf("P", "mm", "A4") - gc := pdf2d.NewGraphicContext(dest) - - // set the fill and stroke color of the droid - gc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff}) - gc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff}) - - // Draw the droid - DrawDroid(gc, 10, 10) - - // Save to pdf - pdf2d.SaveToPdfFile("android.pdf", dest) -} - -func DrawDroid(gc draw2d.GraphicContext, x, y float64) { - gc.SetLineCap(draw2d.RoundCap) - gc.SetLineWidth(5) - - // head - gc.MoveTo(x+30, y+70) - gc.ArcTo(x+80, y+70, 50, 50, 180*(math.Pi/180), 180*(math.Pi/180)) - gc.Close() - gc.FillStroke() - gc.MoveTo(x+60, y+25) - gc.LineTo(x+50, y+10) - gc.MoveTo(x+100, y+25) - gc.LineTo(x+110, y+10) - gc.Stroke() - - // left eye - draw2d.Circle(gc, x+60, y+45, 5) - gc.FillStroke() - - // right eye - draw2d.Circle(gc, x+100, y+45, 5) - gc.FillStroke() - - // body - draw2d.RoundRect(gc, x+30, y+75, x+30+100, y+75+90, 10, 10) - gc.FillStroke() - draw2d.Rect(gc, x+30, y+75, x+30+100, y+75+80) - gc.FillStroke() - - // left arm - draw2d.RoundRect(gc, x+5, y+80, x+5+20, y+80+70, 10, 10) - gc.FillStroke() - - // right arm - draw2d.RoundRect(gc, x+135, y+80, x+135+20, y+80+70, 10, 10) - gc.FillStroke() - - // left leg - draw2d.RoundRect(gc, x+50, y+150, x+50+20, y+150+50, 10, 10) - gc.FillStroke() - - // right leg - draw2d.RoundRect(gc, x+90, y+150, x+90+20, y+150+50, 10, 10) - gc.FillStroke() -} diff --git a/pdf2d/samples/frame-image/frame-image.go b/pdf2d/samples/frame-image/frame-image.go deleted file mode 100644 index 728a88a..0000000 --- a/pdf2d/samples/frame-image/frame-image.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2010 The draw2d Authors. All rights reserved. -// created: 21/11/2010 by Laurent Le Goff, Stani Michiels - -// Load a png image and rotate it -package main - -import ( - "math" - - "github.com/stanim/draw2d" - "github.com/stanim/draw2d/pdf2d" -) - -func main() { - // Margin between the image and the frame - const margin = 30 - // Line width od the frame - const lineWidth = 3 - - // Initialize the graphic context on a pdf document - dest := pdf2d.NewPdf("P", "mm", "A3") - gc := pdf2d.NewGraphicContext(dest) - // Size of destination image - dw, dh := dest.GetPageSize() - // Draw frame - draw2d.RoundRect(gc, lineWidth, lineWidth, dw-lineWidth, dh-lineWidth, 100, 100) - gc.SetLineWidth(lineWidth) - gc.FillStroke() - - // load the source image - source, err := draw2d.LoadFromPngFile("gopher.png") - if err != nil { - panic(err) - } - // Size of source image - sw, sh := float64(source.Bounds().Dx()), float64(source.Bounds().Dy()) - // Draw image to fit in the frame - // TODO Seems to have a transform bug here on draw image - scale := math.Min((dw-margin*2)/sw, (dh-margin*2)/sh) - gc.Save() - gc.Translate(margin, margin) - gc.Scale(scale, scale) - - gc.DrawImage(source) - gc.Restore() - - // Save to pdf - pdf2d.SaveToPdfFile("frame-image.pdf", dest) -} diff --git a/pdf2d/samples/frame-image/gopher.png b/pdf2d/samples/frame-image/gopher.png deleted file mode 100644 index 26b9893..0000000 Binary files a/pdf2d/samples/frame-image/gopher.png and /dev/null differ diff --git a/pdf2d/samples/gopher/gopher.go b/pdf2d/samples/gopher/gopher.go deleted file mode 100644 index cb6696c..0000000 --- a/pdf2d/samples/gopher/gopher.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2010 The draw2d Authors. All rights reserved. -// created: 21/11/2010 by Laurent Le Goff, Stani Michiels - -// Draw a gopher avatar to gopher.png translating from this svg https://github.com/golang-samples/gopher-vector/ -package main - -import ( - "image/color" - - "github.com/stanim/draw2d" - "github.com/stanim/draw2d/pdf2d" -) - -func main() { - // Initialize the graphic context on an RGBA image - dest := pdf2d.NewPdf("P", "mm", "A4") - gc := pdf2d.NewGraphicContext(dest) - - // Draw a gopher - Gopher(gc, 48, 48, 240, 72) - - // Save to pdf - pdf2d.SaveToPdfFile("gopher.pdf", dest) -} - -// Gopher draw a gopher using a gc thanks to https://github.com/golang-samples/gopher-vector/ -func Gopher(gc draw2d.GraphicContext, x, y, w, h float64) { - // Initialize Stroke Attribute - gc.SetLineWidth(3) - gc.SetLineCap(draw2d.RoundCap) - gc.SetStrokeColor(color.Black) - - // Left hand - // - gc.SetFillColor(color.RGBA{0xF6, 0xD2, 0xA2, 0xff}) - gc.MoveTo(10.634, 300.493) - gc.RCubicCurveTo(0.764, 15.751, 16.499, 8.463, 23.626, 3.539) - gc.RCubicCurveTo(6.765, -4.675, 8.743, -0.789, 9.337, -10.015) - gc.RCubicCurveTo(0.389, -6.064, 1.088, -12.128, 0.744, -18.216) - gc.RCubicCurveTo(-10.23, -0.927, -21.357, 1.509, -29.744, 7.602) - gc.CubicCurveTo(10.277, 286.542, 2.177, 296.561, 10.634, 300.493) - gc.FillStroke() - - // - gc.MoveTo(10.634, 300.493) - gc.RCubicCurveTo(2.29, -0.852, 4.717, -1.457, 6.271, -3.528) - gc.Stroke() - - // Left Ear - // - gc.MoveTo(46.997, 112.853) - gc.CubicCurveTo(-13.3, 95.897, 31.536, 19.189, 79.956, 50.74) - gc.LineTo(46.997, 112.853) - gc.Close() - gc.Stroke() -} diff --git a/pdf2d/samples/helloworld/helloworld.go b/pdf2d/samples/helloworld/helloworld.go deleted file mode 100644 index 42263f4..0000000 --- a/pdf2d/samples/helloworld/helloworld.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2010 The draw2d Authors. All rights reserved. -// created: 21/11/2010 by Laurent Le Goff, Stani Michiels - -// Display Hello world in a Rectangle save it to a png -package main - -import ( - "image" - - "github.com/stanim/draw2d" - "github.com/stanim/draw2d/pdf2d" -) - -func main() { - // Set the global folder for searching fonts - // The pdf backend needs for every ttf file its corresponding json - // file which is generated by gofpdf/makefont. - draw2d.SetFontFolder(".") - - // Initialize the graphic context on a pdf document - dest := pdf2d.NewPdf("P", "mm", "A4") - gc := pdf2d.NewGraphicContext(dest) - - // Draw a rounded rectangle using default colors - draw2d.RoundRect(gc, 5, 5, 135, 95, 10, 10) - gc.FillStroke() - - // Set the font luximbi.ttf - gc.SetFontData(draw2d.FontData{"luxi", draw2d.FontFamilyMono, draw2d.FontStyleBold | draw2d.FontStyleItalic}) - // Set the fill text color to black - gc.SetFillColor(image.Black) - gc.SetFontSize(14) - // Display Hello World - gc.FillStringAt("Hello World", 8, 52) - - // Save to pdf - pdf2d.SaveToPdfFile("helloworld.pdf", dest) -} diff --git a/pdf2d/samples/helloworld/luximbi.json b/pdf2d/samples/helloworld/luximbi.json deleted file mode 100644 index a03565e..0000000 --- a/pdf2d/samples/helloworld/luximbi.json +++ /dev/null @@ -1 +0,0 @@ -{"Tp":"TrueType","Name":"LuxiMono-BoldOblique","Desc":{"Ascent":783,"Descent":-205,"CapHeight":783,"Flags":97,"FontBBox":{"Xmin":-29,"Ymin":-211,"Xmax":764,"Ymax":1012},"ItalicAngle":-8,"StemV":120,"MissingWidth":600},"Up":0,"Ut":0,"Cw":[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,653,600,653,600,600,653,600,653,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],"Enc":"cp1252","Diff":"","File":"","Size1":0,"Size2":0,"OriginalSize":0,"I":0,"N":0,"DiffN":0} \ No newline at end of file diff --git a/pdf2d/samples/helloworld/luximbi.ttf b/pdf2d/samples/helloworld/luximbi.ttf deleted file mode 100644 index 734201b..0000000 Binary files a/pdf2d/samples/helloworld/luximbi.ttf and /dev/null differ