Example #1
0
func (B *Imp) Locate(x, y, w, h uint) {
	//
	if x+min > scr.NX() {
		x = scr.NX() - min
	}
	B.x0 = x
	if y+min > scr.NY() {
		y = scr.NY() - min
	}
	B.y0 = y
	if w < min {
		w = min
	}
	if B.x0+w > scr.NX() {
		w = scr.NX() - B.x0
	}
	B.width = w
	if h < min {
		h = min
	}
	if B.y0+h > scr.NY() {
		h = scr.NY() - B.y0
	}
	B.height = h
	scr.SaveGr(B.x0, B.y0, B.x0+B.width, B.y0+B.height)
}
Example #2
0
func moon(x0 int) {
	//
	const r = 40
	x, y, y1, ny := x0, r, 0, int(scr.NY())
	for y < ny-r {
		scr.SaveGr(uint(x-r), uint(y-r), uint(x+r), uint(y+r))
		scr.Colour(col.Sandgelb)
		scr.CircleFull(x, y, r)
		ker.Msleep(33)
		scr.RestoreGr(uint(x-r), uint(y-r), uint(x+r), uint(y+r))
		y1++
		y += y1
	}
}
Example #3
0
func colour(FZ, B uint) col.Colour {
	//
	MausAn := scr.MouseCursorOn()
	if !MausAn {
		scr.MouseCursor(true)
	}
	xm, ym := scr.MousePosGr()
	X, Y = uint(xm), uint(ym)
	M := FZ * B / 2
	if X >= scr.NY()-M {
		X = scr.NX() - M
	}
	if X >= M {
		X -= M
	} else {
		X = 0
	}
	if Y >= H {
		Y -= H
	} else {
		Y = 0
	}
	scr.SaveGr(X, Y, X+2*FZ*B, Y+H)
	write(FZ, B, X, Y)
	clicked := false
	C := col.ScreenF
loop:
	for {
		scr.MouseCursor(true)
		K, _ := kbd.Command()
		switch K {
		case kbd.Esc, kbd.Back, kbd.There, kbd.This:
			break loop
		case kbd.Here:
			define(FZ, B, &C)
			clicked = true
		case kbd.Hither:
			if clicked {
				break loop
			}
		}
	}
	scr.RestoreGr(X, Y, X+2*FZ*B, Y+H)
	if !MausAn {
		scr.MouseCursor(false)
	}
	return C
}
Example #4
0
func (f *Imp) editText() {
	//
	if f.sort != Text {
		return
	}
	scr.MouseCursor(false)
	bx.Wd(lenText)
	bx.ColourF(f.colour)
	x1 := f.x[0] + int(lenText*scr.NX1()) - 1
	if x1 >= xx {
		x1 = xx - 1
	}
	y1 := f.y[0] + int(scr.NY1()) - 1
	if y1 >= yy {
		y1 = yy - 1
	}
	scr.SaveGr(uint(f.x[0]), uint(f.y[0]), uint(x1), uint(y1))
	bx.SetTransparent(false)
	f.tx = str.Clr(lenText) // wörkeraunt
	bx.EditGr(&f.tx, uint(f.x[0]), uint(f.y[0]))
	bx.SetTransparent(true)
	scr.RestoreGr(uint(f.x[0]), uint(f.y[0]), uint(x1), uint(y1))
	var T uint
	if kbd.LastCommand(&T) == kbd.Enter {
		bx.SetTransparent(true)
		//    scr.RestoreGr (f.x[0], f.y[0], x1, y1)
		bx.WriteGr(f.tx, f.x[0], f.y[0])
		k := str.ProperLen(f.tx)
		x0 := make([]int, 2)
		x0[0] = f.x[0]
		f.x = x0
		y0 := make([]int, 2)
		y0[0] = f.y[0]
		f.y = y0
		f.x[1] = f.x[0] + int(scr.NX1()*k) - 1
		f.y[1] = f.y[0] + int(scr.NY1()) - 1
		scr.WarpMouseGr(f.x[0], f.y[1])
	} else {
		//    f.tx = str.Clr (lenText)
		//    bx.WriteGr (f.tx, f.x[0], f.y[0])
		//    f.tx = ""
		//    f.x, f.y = nil, nil
	}
	scr.MouseCursor(true)
}
Example #5
0
func dr(x0, x1, y int, c col.Colour, f bool) {
	//
	const dx = 2
	nx1, ny, y1 := int(scr.NX1()), int(scr.NY()), 0
	for x := x0; x < x1; x += dx {
		if !f {
			scr.SaveGr(uint(x), uint(y), uint(x)+car.W, uint(y)+car.H)
		}
		car.Draw(true, c, x, y)
		ker.Msleep(10)
		car.Draw(true, col.ScreenB, x, y)
		if f && x > x0+26*nx1 && x%8 == 0 && y+car.H < ny {
			y1++
			y += y1
		}
		if !f {
			scr.RestoreGr(uint(x), uint(y), uint(x)+car.W, uint(y)+car.H)
		}
	}
}
Example #6
0
func joke(x0, x1, y0, nx1, ny1, x, y, w int, cl col.Colour, s string, b bool) {
	//
	h := y + 8 + 1
	y1 := y0 + 8*h
	if b {
		y1 -= 40
	}
	dr(x0, x0+x*nx1, y0+y*ny1, cl, false)
	scr.SaveGr(uint(x0+x*nx1), uint(y1), uint(x0+(x+w)*nx1), uint(y1+8*w))
	img.Get(s, uint(x0+x*nx1), uint(y1))
	t := uint(1)
	if b {
		t = 2
	}
	ker.Sleep(t)
	scr.RestoreGr(uint(x0+x*nx1), uint(y1), uint(x0+(x+w)*nx1), uint(y1+8*w))
	if b {
		w = 2 * w / 3
	}
	dr(x0+(x+w)*nx1, x1, y0+y*ny1, cl, false)
}