package imageEffects_test

import "seekia/internal/imageFiles"
import "seekia/internal/helpers"
import "seekia/internal/imageEffects"
import "seekia/internal/imagery"

import "testing"


func TestImageEffects(t *testing.T){

	testImageBytes := imageFiles.PNG_SmileyA

	testImage, err := imagery.ConvertPNGImageFileBytesToGolangImage(testImageBytes)
	if (err != nil){
		t.Fatal("ConvertPNGImageFileBytesToGolangImage failed: " + err.Error())
	}

	for strength:=0; strength <= 100; strength += 20{

		_, err := imageEffects.ApplyCartoonEffect(testImage, strength)
		if (err != nil){
			t.Fatal("ApplyCartoonEffect failed: " + err.Error())
		}

		_, err = imageEffects.ApplyPencilEffect(testImage, strength)
		if (err != nil){
			t.Fatal("ApplyPencilEffect failed: " + err.Error())
		}

		_, err = imageEffects.ApplyOilPaintingEffect(testImage, strength)
		if (err != nil){
			t.Fatal("ApplyOilPaintingEffect failed: " + err.Error())
		}

		_, err = imageEffects.ApplyWireframeEffect(testImage, strength)
		if (err != nil){
			t.Fatal("ApplyWireframeEffect failed: " + err.Error())
		}
		_, err = imageEffects.ApplyStrokeEffect(testImage, strength)
		if (err != nil){
			t.Fatal("ApplyStrokeEffect failed: " + err.Error())
		}
	}

	testEmojiBytes := imageFiles.Emoji_3629

	testEmoji, err := imagery.ConvertSVGImageFileBytesToGolangImage(testEmojiBytes)
	if (err != nil){
		t.Fatal("ConvertSVGImageFileBytesToGolangImage failed: " + err.Error())
	}

	for i:=0; i < 100; i++{

		randomEmojiScale := helpers.GetRandomIntWithinRange(0, 100)

		randomXPercentage := helpers.GetRandomIntWithinRange(0, 100)

		randomYPercentage := helpers.GetRandomIntWithinRange(0, 100) 

		_, err := imageEffects.GetImageWithEmojiOverlay(testImage, testEmoji, randomEmojiScale, randomXPercentage, randomYPercentage)
		if (err != nil){
			t.Fatal("GetImageWithEmojiOverlay failed: " + err.Error())
		}
	}
}



