Beispiel #1
0
func (this *ProcChainBuilder) getRotateProcessor(channel string, params map[string]string) (proc.ImageProcessor, error) {
	rotate, ok := params[":6"]
	if !ok {
		return nil, nil
	}

	rotateStr, err := data.GetRotates(channel)
	if err != nil {
		return nil, err
	}

	var checkstr = JoinString(",", rotate, ",")
	if !strings.Contains(rotateStr, checkstr) {
		opacitiesStr, err := data.GetDissolves(Hotel)
		if err != nil {
			return nil, err
		}
		if strings.Contains(opacitiesStr, checkstr) {
			return nil, nil
		} else {
			return nil, errors.New(JoinString("channel: ", channel, ", reason: not support rotate degree ", rotate))
		}
	}
	degress, err := strconv.ParseFloat(rotate, 64)
	if err != nil {
		return nil, err
	}
	return &proc.RotateProcessor{degress, this.Cat}, nil
}
Beispiel #2
0
func (this *hotelrotatefeature) Process() (proc.ImageProcessor, bool, error) {
	rotateStr, err := data.GetRotates(Hotel)
	if err != nil {
		return nil, true, err
	}

	var checkstr = JoinString(",", strconv.FormatFloat(this.rotate, 'f', -1, 64), ",")
	if strings.Contains(rotateStr, checkstr) {
		return nil, true, nil
	}
	opacitiesStr, err := data.GetDissolves(Hotel)
	if err != nil {
		return nil, true, err
	}
	if strings.Contains(opacitiesStr, checkstr) {
		return nil, false, nil
	}
	return nil, false, errors.New(JoinString("channel: hotel, reason: not support rotate degree", strconv.FormatFloat(this.rotate, 'f', -1, 64)))
}
func (this *ProcChainBuilder) getRotateProcessor(channel string, params map[string]string) (proc.ImageProcessor, error) {
	rotate, ok := params[":6"]
	if !ok {
		return nil, nil
	}
	degress, err := strconv.ParseFloat(rotate, 64)
	if err != nil {
		return nil, err
	}

	var (
		process proc.ImageProcessor = nil
		isnext  bool                = true
	)
	if channel == Hotel || channel == Globalhotel {
		ft := hotelrotatefeature{degress}
		process, isnext, err = ft.Process()
	}
	if err != nil {
		return nil, err
	}
	if process != nil {
		return process, nil
	}
	if !isnext {
		return nil, nil
	}

	const key = "rotates"
	rotateStr, err := data.GetRotates(channel)
	if err != nil {
		return nil, err
	}
	if !strings.Contains(rotateStr, JoinString(",", rotate, ",")) {
		return nil, errors.New(JoinString("channel: ", channel, ", reason: not support rotate degree ", rotate))
	}

	return &proc.RotateProcessor{degress, this.Cat}, nil
}