예제 #1
0
파일: fades.go 프로젝트: DrItanium/moo
func (this *FadeData) SetActive(result bool) {
	if result {
		this.Flags |= cseries.Word(0x8000)
	} else {
		this.Flags &^= cseries.Word(0x8000)
	}
}
예제 #2
0
파일: fades.go 프로젝트: DrItanium/moo
func BurnColorTable(original, animated ColorTable, color *RgbColor, transparency cseries.Fixed) {
	customCeiling := func(n, ceiling int32) int32 {
		if n > ceiling {
			return ceiling
		} else {
			return n
		}
	}
	updateElement := func(adjusted cseries.Word, component int32) cseries.Word {
		return cseries.Word(customCeiling(component, int32(adjusted)))
	}
	computeComponent := func(unadjusted, color cseries.Word, transparency cseries.Fixed) int32 {
		return int32(cseries.Fixed(((color * unadjusted) >> cseries.FixedFractionalBits)) + transparency)
	}
	transparency = cseries.FixedOne - transparency
	for i := 0; i < len(original); i++ {
		r, g, b := original[i].Red, original[i].Green, original[i].Blue
		component := computeComponent(r, color.Red, transparency)
		animated[i].Red = updateElement(r, component)
		component = computeComponent(g, color.Green, transparency)
		animated[i].Green = updateElement(g, component)
		component = computeComponent(b, color.Blue, transparency)
		animated[i].Blue = updateElement(b, component)
	}

	//component= ((color->red*unadjusted->red)>>FIXED_FRACTIONAL_BITS) + transparency, adjusted->red= CEILING(component, unadjusted->red);
	//component= ((color->green*unadjusted->green)>>FIXED_FRACTIONAL_BITS) + transparency, adjusted->green= CEILING(component, unadjusted->green);
	//component= ((color->blue*unadjusted->blue)>>FIXED_FRACTIONAL_BITS) + transparency, adjusted->blue= CEILING(component, unadjusted->blue);

}
예제 #3
0
파일: fades.go 프로젝트: DrItanium/moo
func DodgeColorTable(original, animated ColorTable, color *RgbColor, transparency cseries.Fixed) {
	customCeiling := func(n, ceiling int32) int32 {
		if n > ceiling {
			return ceiling
		} else {
			return n
		}
	}
	computeComponent := func(unadjusted, color cseries.Word) int32 {
		return int32(0xffff - cseries.Fixed((((color ^ 0xffff) * unadjusted) >> cseries.FixedFractionalBits)) - transparency)
	}
	updateElement := func(adjusted cseries.Word, component int32) cseries.Word {
		return cseries.Word(customCeiling(component, int32(adjusted)))
	}
	for i := 0; i < len(original); i++ {
		var component int32

		component = computeComponent(original[i].Red, color.Red)
		animated[i].Red = updateElement(original[i].Red, component)
		component = computeComponent(original[i].Blue, color.Blue)
		animated[i].Blue = updateElement(original[i].Blue, component)
		component = computeComponent(original[i].Green, color.Green)
		animated[i].Green = updateElement(original[i].Green, component)
	}

	// Using the comma operator instead of ; for assignment...why?
	//component= 0xffff - (((color->red^0xffff)*unadjusted->red)>>FIXED_FRACTIONAL_BITS) - transparency, adjusted->red= CEILING(component, unadjusted->red);
	//component= 0xffff - (((color->green^0xffff)*unadjusted->green)>>FIXED_FRACTIONAL_BITS) - transparency, adjusted->green= CEILING(component, unadjusted->green);
	//component= 0xffff - (((color->blue^0xffff)*unadjusted->blue)>>FIXED_FRACTIONAL_BITS) - transparency, adjusted->blue= CEILING(component, unadjusted->blue);
}
예제 #4
0
파일: fades.go 프로젝트: DrItanium/moo
func SoftTintColorTable(original, animated ColorTable, color *RgbColor, transparency cseries.Fixed) {
	adjustedTransparency := cseries.Word(transparency >> AdjustedTransparencyDownshift)
	fn := func(x, y, z, w cseries.Word) cseries.Word {
		return cseries.Word(x + (((((y * w) >> (cseries.FixedFractionalBits - AdjustedTransparencyDownshift)) - x) * z) >> (cseries.FixedFractionalBits - AdjustedTransparencyDownshift)))
	}
	for i := 0; i < len(original); i++ {
		intensity := cseries.Word(cseries.Max(int64(original[i].Red), int64(original[i].Green)))
		intensity = cseries.Word(cseries.Max(int64(intensity), int64(original[i].Blue)) >> AdjustedTransparencyDownshift)

		animated[i].Red = fn(original[i].Red, color.Red, adjustedTransparency, intensity)
		animated[i].Green = fn(original[i].Green, color.Green, adjustedTransparency, intensity)
		animated[i].Blue = fn(original[i].Blue, color.Blue, adjustedTransparency, intensity)

	}
	//adjusted->red= unadjusted->red + (((((color->red*intensity)>>(FIXED_FRACTIONAL_BITS-ADJUSTED_TRANSPARENCY_DOWNSHIFT))-unadjusted->red)*adjusted_transparency)>>(FIXED_FRACTIONAL_BITS-ADJUSTED_TRANSPARENCY_DOWNSHIFT));
	//adjusted->green= unadjusted->green + (((((color->green*intensity)>>(FIXED_FRACTIONAL_BITS-ADJUSTED_TRANSPARENCY_DOWNSHIFT))-unadjusted->green)*adjusted_transparency)>>(FIXED_FRACTIONAL_BITS-ADJUSTED_TRANSPARENCY_DOWNSHIFT));
	//adjusted->blue= unadjusted->blue + (((((color->blue*intensity)>>(FIXED_FRACTIONAL_BITS-ADJUSTED_TRANSPARENCY_DOWNSHIFT))-unadjusted->blue)*adjusted_transparency)>>(FIXED_FRACTIONAL_BITS-ADJUSTED_TRANSPARENCY_DOWNSHIFT));
}
예제 #5
0
파일: fades.go 프로젝트: DrItanium/moo
// unlike pathways, all colors won't pass through 50% gray at the same time
func NegateColorTable(original, animated ColorTable, color *RgbColor, transparency cseries.Fixed) {
	transparency = cseries.FixedOne - transparency

	fn := func(ov, cv cseries.Word) cseries.Word {
		var tmp cseries.Word
		if ov > 0x8000 {
			tmp = (ov ^ cv) + cseries.Word(transparency)
			return tmp.Ceiling(ov)
		} else {
			tmp = (ov ^ cv) - cseries.Word(transparency)
			return tmp.Floor(ov)
		}
	}
	for i := 0; i < len(original); i++ {
		animated[i].Red = fn(original[i].Red, color.Red)
		animated[i].Green = fn(original[i].Green, color.Green)
		animated[i].Blue = fn(original[i].Blue, color.Blue)
	}
}
예제 #6
0
파일: fades.go 프로젝트: DrItanium/moo
func TintColorTable(original, animated ColorTable, color *RgbColor, transparency cseries.Fixed) {
	adjustedTransparency := transparency >> AdjustedTransparencyDownshift
	fn := func(unadjustedValue, colorValue cseries.Word) cseries.Word {
		return cseries.Word(cseries.Fixed(unadjustedValue) + ((cseries.Fixed(colorValue-unadjustedValue) * adjustedTransparency) >> (cseries.FixedFractionalBits - AdjustedTransparencyDownshift)))
	}
	for i := 0; i < len(original); i++ {
		animated[i].Red = fn(original[i].Red, color.Red)
		animated[i].Green = fn(original[i].Green, color.Green)
		animated[i].Blue = fn(original[i].Blue, color.Blue)
	}
}
예제 #7
0
파일: fades.go 프로젝트: DrItanium/moo
func RandomizeColorTable(original, animated ColorTable, color *RgbColor, transparency cseries.Fixed) {
	var mask cseries.Word
	adjustedTransparency := transparency.Pin(0, 0xffff)
	// calculate a mask which has all bits including and lower than the high-bit in the transparency set
	for mask = 0; (cseries.Word(adjustedTransparency) &^ mask) != 0; mask = (mask << 1) | 1 {
		// empty loop body
	}
	fn := func(value, mask cseries.Word) cseries.Word {
		return value + (FadesRandom() & mask)
	}
	for i := 0; i < len(original); i++ {
		animated[i].Red = fn(original[i].Red, mask)
		animated[i].Green = fn(original[i].Green, mask)
		animated[i].Blue = fn(original[i].Blue, mask)
	}
}
예제 #8
0
파일: fades.go 프로젝트: DrItanium/moo
func GammaCorrectColorTable(uncorrected, corrected ColorTable, gammaLevel int16) error {
	var gamma float32
	if !(gammaLevel >= 0 && gammaLevel < NumberOfGammaLevels) {
		return &cseries.AssertionError{
			Function: "GamaCorrectColorTable",
			Message:  fmt.Sprintf("Gamma level (%d) is not between [0,%d)", gammaLevel, NumberOfGammaLevels),
		}
	}
	gamma = ActualGammaValues[gammaLevel]

	fn := func(value cseries.Word, g float32) cseries.Word {
		return cseries.Word(math.Pow(float64(value/65535.0), float64(g)) * 65535.0)
	}
	for i := 0; i < len(uncorrected); i++ {
		corrected[i].Red = fn(uncorrected[i].Red, gamma)
		corrected[i].Green = fn(uncorrected[i].Green, gamma)
		corrected[i].Blue = fn(uncorrected[i].Blue, gamma)
	}

	return nil
}
예제 #9
0
파일: render.go 프로젝트: DrItanium/moo
func (this RenderFlags) Set(index, flag int16) {
	this[index] |= cseries.Word(flag)
}
예제 #10
0
파일: render.go 프로젝트: DrItanium/moo
func (this RenderFlags) Test(index, flag int16) bool {
	return (this[index] & cseries.Word(flag)) == 1
}
예제 #11
0
파일: flood-map.go 프로젝트: DrItanium/moo
func (this *FloodMapNodeData) MarkAsUnexpanded() {
	this.Flags |= cseries.Word(0x8000)
}
예제 #12
0
파일: flood-map.go 프로젝트: DrItanium/moo
func (this *FloodMapNodeData) IsExpanded() bool {
	return (this.flags & cseries.Word(0x8000)) != 0
}
예제 #13
0
파일: fades.go 프로젝트: DrItanium/moo
func (this *FadeDefinition) IsActive() bool {
	return this.Flags&cseries.Word(0x8000) != 0
}
예제 #14
0
파일: fades.go 프로젝트: DrItanium/moo
	EffectUnderLaval
	EffectUnderSewage
	EffectUnderGoo
	NumberOfFadeEffectTypes
)
const (
	AdjustedTransparencyDownshift = 8

	MinimumFadeRestartTicks = cseries.MachineTicksPerSecond / 2
	MinimumFadeUpdateTicks  = cseries.MachineTicksPerSecond / 8

	FullScreenFlag         = 0x0001
	RandomTransparencyFlag = 0x0002
)

var FadesRandomSeed = cseries.Word(0x1)

func FadesRandom() cseries.Word {
	if (FadesRandomSeed & 1) != 0 {
		FadesRandomSeed = (FadesRandomSeed >> 1) ^ 0xb400
	} else {
		FadesRandomSeed >>= 1
	}
	return FadesRandomSeed
}

type FadeProcedure func(ColorTable, ColorTable, *RgbColor, cseries.Fixed)

type FadeEffectDefinition struct {
	Type         int16
	Transparency cseries.Fixed