Move color functionality into subpackage of internal
This commit is contained in:
		
							parent
							
								
									45a6634e73
								
							
						
					
					
						commit
						ac1a952b40
					
				| @ -6,7 +6,7 @@ import "git.tebibyte.media/tomo/tomo/input" | |||||||
| import "git.tebibyte.media/tomo/tomo/event" | import "git.tebibyte.media/tomo/tomo/event" | ||||||
| import "git.tebibyte.media/tomo/tomo/canvas" | import "git.tebibyte.media/tomo/tomo/canvas" | ||||||
| import "git.tebibyte.media/tomo/objects/layouts" | import "git.tebibyte.media/tomo/objects/layouts" | ||||||
| import "git.tebibyte.media/tomo/objects/internal" | import icolor "git.tebibyte.media/tomo/objects/internal/color" | ||||||
| 
 | 
 | ||||||
| var _ tomo.Object = new(HSVAColorPicker) | var _ tomo.Object = new(HSVAColorPicker) | ||||||
| 
 | 
 | ||||||
| @ -18,7 +18,7 @@ var _ tomo.Object = new(HSVAColorPicker) | |||||||
| //     saturation and the Y axis controls value. | //     saturation and the Y axis controls value. | ||||||
| type HSVAColorPicker struct { | type HSVAColorPicker struct { | ||||||
| 	box tomo.ContainerBox | 	box tomo.ContainerBox | ||||||
| 	value internal.HSVA | 	value icolor.HSVA | ||||||
| 	 | 	 | ||||||
| 	pickerMap   *hsvaColorPickerMap | 	pickerMap   *hsvaColorPickerMap | ||||||
| 	hueSlider   *Slider | 	hueSlider   *Slider | ||||||
| @ -80,7 +80,7 @@ func (this *HSVAColorPicker) Value () color.Color { | |||||||
| // SetValue sets the color of the picker. | // SetValue sets the color of the picker. | ||||||
| func (this *HSVAColorPicker) SetValue (value color.Color) { | func (this *HSVAColorPicker) SetValue (value color.Color) { | ||||||
| 	if value == nil { value = color.Transparent } | 	if value == nil { value = color.Transparent } | ||||||
| 	this.value = internal.HSVAModel.Convert(value).(internal.HSVA) | 	this.value = icolor.HSVAModel.Convert(value).(icolor.HSVA) | ||||||
| 	this.hueSlider.SetValue(this.value.H) | 	this.hueSlider.SetValue(this.value.H) | ||||||
| 	this.alphaSlider.SetValue(float64(this.value.A) / 0xFFFF) | 	this.alphaSlider.SetValue(float64(this.value.A) / 0xFFFF) | ||||||
| 	this.pickerMap.Invalidate() | 	this.pickerMap.Invalidate() | ||||||
| @ -152,7 +152,7 @@ func (this *hsvaColorPickerMap) Draw (can canvas.Canvas) { | |||||||
| 		xx := x - bounds.Min.X | 		xx := x - bounds.Min.X | ||||||
| 		yy := y - bounds.Min.Y | 		yy := y - bounds.Min.Y | ||||||
| 		 | 		 | ||||||
| 		pixel := internal.HSVA { | 		pixel := icolor.HSVA { | ||||||
| 			H: this.parent.value.H, | 			H: this.parent.value.H, | ||||||
| 			S:     float64(xx) / float64(bounds.Dx()), | 			S:     float64(xx) / float64(bounds.Dx()), | ||||||
| 			V: 1 - float64(yy) / float64(bounds.Dy()), | 			V: 1 - float64(yy) / float64(bounds.Dy()), | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| package internal | package color | ||||||
| 
 | 
 | ||||||
| import "fmt" | import "fmt" | ||||||
| import "image/color" | import "image/color" | ||||||
| @ -8,7 +8,7 @@ import "git.tebibyte.media/tomo/tomo/input" | |||||||
| import "git.tebibyte.media/tomo/tomo/event" | import "git.tebibyte.media/tomo/tomo/event" | ||||||
| import "git.tebibyte.media/tomo/tomo/canvas" | import "git.tebibyte.media/tomo/tomo/canvas" | ||||||
| import "git.tebibyte.media/tomo/objects/layouts" | import "git.tebibyte.media/tomo/objects/layouts" | ||||||
| import "git.tebibyte.media/tomo/objects/internal" | import icolor "git.tebibyte.media/tomo/objects/internal/color" | ||||||
| 
 | 
 | ||||||
| var _ tomo.Object = new(Swatch) | var _ tomo.Object = new(Swatch) | ||||||
| 
 | 
 | ||||||
| @ -117,7 +117,7 @@ func (this *Swatch) Choose () { | |||||||
| 	 | 	 | ||||||
| 	updateHexInput := func () { | 	updateHexInput := func () { | ||||||
| 		nrgba := color.NRGBAModel.Convert(colorPicker.Value()).(color.NRGBA) | 		nrgba := color.NRGBAModel.Convert(colorPicker.Value()).(color.NRGBA) | ||||||
| 		hexInput.SetValue(internal.FormatNRGBA(nrgba)) | 		hexInput.SetValue(icolor.FormatNRGBA(nrgba)) | ||||||
| 	} | 	} | ||||||
| 	updateHexInput() | 	updateHexInput() | ||||||
| 	commit := func () { | 	commit := func () { | ||||||
| @ -130,7 +130,7 @@ func (this *Swatch) Choose () { | |||||||
| 	}) | 	}) | ||||||
| 	hexInput.OnConfirm(commit) | 	hexInput.OnConfirm(commit) | ||||||
| 	hexInput.OnValueChange(func () { | 	hexInput.OnValueChange(func () { | ||||||
| 		nrgba := internal.ParseNRGBA(hexInput.Value()) | 		nrgba := icolor.ParseNRGBA(hexInput.Value()) | ||||||
| 		this.userSetValue(nrgba) | 		this.userSetValue(nrgba) | ||||||
| 		colorPicker.SetValue(nrgba) | 		colorPicker.SetValue(nrgba) | ||||||
| 	}) | 	}) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user