Code Monkey home page Code Monkey logo

Comments (3)

mcarpenter622 avatar mcarpenter622 commented on May 8, 2024

So for drawing SVG, Couldn't you render the SVG to an image object (not the screen) like in the example you linked. Then use that image with ebitenui?

from ebitenui.

jasoncmcg avatar jasoncmcg commented on May 8, 2024

Awesome! Thanks so much! I had no idea I could do that!

I added these to images.go

func createTriangle(size int, c color.Color) *ebiten.Image {
	// Create a new image of the desired size
	img := ebiten.NewImage(size, size)

	// Get the RGBA values of the color
	r, g, b, a := c.RGBA()

	// Iterate over the pixels in the image
	for y := 0; y < size; y++ {
		for x := 0; x < size; x++ {
			// If the pixel is within the bounds of the triangle, set its color
			if x >= y && x < size-y {
				img.Set(x, y, color.RGBA{uint8(r), uint8(g), uint8(b), uint8(a)})
			}
		}
	}

	return img
}

func createTriangeDown(size int) *widget.ButtonImageImage {
	// Create the images
	triangleIdle := createTriangle(size, primaryColor)
	triangleDisabled := createTriangle(size, secondaryColor)

	// Return the ButtonImageImage
	return &widget.ButtonImageImage{
		Idle:     triangleIdle,
		Disabled: triangleDisabled,
	}
}

Then, just replaced arrowDown with this arrowDown := createTriangeDown(15) and it worked great!

Now, there is a dropdown triangle that is rendered on the fly.

from ebitenui.

mcarpenter622 avatar mcarpenter622 commented on May 8, 2024

That's great!, I am going to close this issue for now. Please feel free to reach out if you have any further questions.
-Mark

from ebitenui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.