Resolve bugs
|
@ -1,7 +1,7 @@
|
|||
|
||||
include $(GOROOT)/src/Make.inc
|
||||
|
||||
TARG=gettingStarted testdraw2d testX11draw testandroid testgopher testimage testpostscript draw2dgl
|
||||
TARG=gettingStarted testdraw2d testX11draw testandroid testgopher testimage testpostscript #draw2dgl
|
||||
|
||||
OFILES=$(TARG:%=%.$O)
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ func saveToPngFile(filePath string, m image.Image) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
i := image.NewRGBA(200, 200)
|
||||
i := image.NewRGBA(image.Rect(0,0,200, 200))
|
||||
gc := draw2d.NewGraphicContext(i)
|
||||
gc.MoveTo(10.0, 10.0)
|
||||
gc.LineTo(100.0, 10.0)
|
||||
|
|
|
@ -2,8 +2,8 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"image/draw"
|
||||
"image/draw/x11"
|
||||
"exp/gui"
|
||||
"exp/gui/x11"
|
||||
"image"
|
||||
"math"
|
||||
"draw2d.googlecode.com/hg/draw2d"
|
||||
|
@ -37,11 +37,11 @@ func main() {
|
|||
for {
|
||||
|
||||
switch evt := (<-window.EventChan()).(type) {
|
||||
case draw.KeyEvent:
|
||||
case gui.KeyEvent:
|
||||
if evt.Key == 'q' {
|
||||
window.Close()
|
||||
}
|
||||
case draw.MouseEvent:
|
||||
case gui.MouseEvent:
|
||||
if evt.Buttons&1 != 0 {
|
||||
if nbclick%2 == 0 {
|
||||
gc.MoveTo(float64(evt.Loc.X), float64(evt.Loc.Y))
|
||||
|
|
|
@ -24,7 +24,7 @@ var (
|
|||
)
|
||||
|
||||
func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
|
||||
i := image.NewRGBA(w, h)
|
||||
i := image.NewRGBA(image.Rect(0, 0,w, h))
|
||||
gc := draw2d.NewGraphicContext(i)
|
||||
lastTime = time.Nanoseconds()
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ var (
|
|||
)
|
||||
|
||||
func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
|
||||
i := image.NewRGBA(w, h)
|
||||
i := image.NewRGBA(image.Rect(0, 0, w, h))
|
||||
gc := draw2d.NewGraphicContext(i)
|
||||
lastTime = time.Nanoseconds()
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ var (
|
|||
)
|
||||
|
||||
func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
|
||||
i := image.NewRGBA(w, h)
|
||||
i := image.NewRGBA(image.Rect(0, 0, w, h))
|
||||
gc := draw2d.NewGraphicContext(i)
|
||||
lastTime = time.Nanoseconds()
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ func loadFromPngFile(filePath string) image.Image {
|
|||
|
||||
func main() {
|
||||
source := loadFromPngFile("../resource/image/TestAndroid.png")
|
||||
dest := image.NewRGBA(1024, 768)
|
||||
dest := image.NewRGBA(image.Rect(0, 0, 1024, 768))
|
||||
width, height := float64(source.Bounds().Dx()), float64(source.Bounds().Dy())
|
||||
tr := draw2d.NewIdentityMatrix()
|
||||
tr.Translate(width/2, height/2)
|
||||
|
|
|
@ -38,7 +38,7 @@ func saveToPngFile(filePath string, m image.Image) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
i := image.NewRGBA(600, 800)
|
||||
i := image.NewRGBA(image.Rect(0, 0, 600, 800))
|
||||
gc := draw2d.NewGraphicContext(i)
|
||||
gc.Translate(0, 380)
|
||||
gc.Scale(1, -1)
|
||||
|
|
|
@ -37,8 +37,8 @@ func NewGraphicContext(img draw.Image) *ImageGraphicContext {
|
|||
switch selectImage := img.(type) {
|
||||
case *image.RGBA:
|
||||
painter = raster.NewRGBAPainter(selectImage)
|
||||
case *image.NRGBA:
|
||||
painter = NewNRGBAPainter(selectImage)
|
||||
//case *image.NRGBA:
|
||||
// painter = NewNRGBAPainter(selectImage)
|
||||
default:
|
||||
panic("Image type not supported")
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright 2010 The draw2d Authors. All rights reserved.
|
||||
// created: 21/11/2010 by Laurent Le Goff
|
||||
package draw2d
|
||||
|
||||
/*
|
||||
import (
|
||||
"image/draw"
|
||||
"image"
|
||||
"freetype-go.googlecode.com/hg/freetype/raster"
|
||||
)
|
||||
)*/
|
||||
|
||||
const M = 1<<16 - 1
|
||||
|
||||
/*
|
||||
type NRGBAPainter struct {
|
||||
// The image to compose onto.
|
||||
Image *image.NRGBA
|
||||
|
@ -46,7 +46,7 @@ func (r *NRGBAPainter) Paint(ss []raster.Span, done bool) {
|
|||
ma := s.A >> 16
|
||||
if r.Op == draw.Over {
|
||||
for i, nrgba := range p {
|
||||
dr, dg, db, da := nrgba.RGBA()
|
||||
dr, dg, db, da := nrgba.
|
||||
a := M - (r.ca*ma)/M
|
||||
da = (da*a + r.ca*ma) / M
|
||||
if da != 0 {
|
||||
|
@ -74,6 +74,7 @@ func (r *NRGBAPainter) Paint(ss []raster.Span, done bool) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// SetColor sets the color to paint the spans.
|
||||
|
@ -85,3 +86,4 @@ func (r *NRGBAPainter) SetColor(c image.Color) {
|
|||
func NewNRGBAPainter(m *image.NRGBA) *NRGBAPainter {
|
||||
return &NRGBAPainter{Image: m}
|
||||
}
|
||||
*/
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 160 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |