fc

package module
v0.0.0-...-42aeab8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2024 License: BSD-3-Clause Imports: 8 Imported by: 1

README

fc - high-level canvas for the fyne toolkit

hello world

is created with:

package main

import (
	"image/color"

	"github.com/ajstarks/fc"
)

func main() {
	width := 500
	height := 500
	blue := color.RGBA{0, 0, 255, 255}
	white := color.RGBA{255, 255, 255, 255}

	canvas := fc.NewCanvas("hello", width, height)

	canvas.Circle(50, 0, 100, blue)
	canvas.CText(50, 25, 10, "hello, world", white)
	canvas.Image(50, 75, 200, 200, "earth.jpg")

	canvas.EndRun()
}

Introduction

There are methods for Text (begin, centered, and end aligned), Circles, Lines, Rectangles, and Images.

Percent coordinate based methods

NewCanvas makes a new canvas
NewCanvas(name string, w, h int) Canvas
EndRun shows the content and runs the app
(canvas *Canvas) EndRun()
Text places text within a container, using percent coordinates
(canvas *Canvas) Text(x, y float64, size float64, s string, color color.RGBA) {
CText places centered text using percent coordinates
(canvas *Canvas) CText(x, y float64, size float64, s string, color color.RGBA) {
EText places end-aligned text within a container, using percent coordinates
(canvas *Canvas) EText(x, y float64, size float64, s string, color color.RGBA) {
Circle places a circle within a container, using percent coordinates
(canvas *Canvas) Circle(x, y, r float64, color color.RGBA) {
Line places a line within a container, using percent coordinates
(canvas *Canvas) Line(x1, y1, x2, y2, size float64, color color.RGBA) {
Rect places a rectangle centered on (x,y) within a container, using percent coordinates
(canvas *Canvas) Rect(x, y, w, h float64, color color.RGBA) {
CornerRect places a rectangle with upper left corner on (x,y) within a container, using percent coordinates
(canvas *Canvas) CornerRect(x, y, w, h float64, color color.RGBA) {
Image places an image centered at (x, y) within a container, using percent coordinates
(canvas *Canvas) Image(x, y float64, w, h int, name string) {

Absolute methods: uses absolute coordinate system and fyne structures directly

AbsStart -- begin the application
func AbsStart(name string, w, h int) (fyne.Window, *fyne.Container)
AbsEndRun -- run the app
func AbsEnd(window fyne.Window, content *fyne.Container, w, h int) {
AbsText -- Add text at (x,y) with the specified size and color
func AbsText(c *fyne.Container, x, y int, s string, size int, color color.RGBA)
AbsTextMid -- Add Center text
func AbsTextMid(c *fyne.Container, x, y int, s string, size int, color color.RGBA)
AbsTectEnd -- Add End-Aligned text
func AbsTextEnd(c *fyne.Container, x, y int, s string, size int, color color.RGBA)
AbsLine -- Add a colored line from (x1,y1) to (x2, y2)
func AbsLine(c *fyne.Container, x1, y1, x2, y2 int, size float32, color color.RGBA)
AbsCircle --- Add a circle object centered at (x,y) with radius r
func AbsCircle(c *fyne.Container, x, y, r int, color color.RGBA)
AbsCornerRect -- Add a rectangle with (c *fyne.Container, x,y) at the upper left, with dimension (w, h)
func AbsCornerRect(c *fyne.Container, x, y, w, h int, color color.RGBA)
AbsRect -- Add a rectangle centered at (c *fyne.Container, x,y), with dimension (w, h)
func AbsRect(c *fyne.Container, x, y, w, h int, color color.RGBA)
AbsAdd an image named as name centered at (x, y) with dimensions ( w, h)
func AbsImage(c *fyne.Container, x, y, w, h int, name string)
AbsAdd an named image with upper left at (x, y) with dimensions (w, h)
func AbsCornerImage(c *fyne.Container, x, y, w, h int, name string)

Documentation

Overview

Package fc is fyne high-level canvas

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsCircle

func AbsCircle(cont *fyne.Container, x, y, r int, color color.RGBA)

AbsCircle is a containerized circle within a container

func AbsCornerImage

func AbsCornerImage(cont *fyne.Container, x, y, w, h int, name string)

AbsCornerImage places the image centered at x, y within a container

func AbsCornerRect

func AbsCornerRect(cont *fyne.Container, x, y, w, h int, color color.RGBA)

AbsCornerRect makes a rectangle within a container

func AbsEndRun

func AbsEndRun(window fyne.Window, c *fyne.Container, w, h int)

AbsEndRun shows the content and runs the app using bare windows and containers

func AbsImage

func AbsImage(cont *fyne.Container, x, y, w, h int, name string)

AbsImage places the image centered at x, y within a container

func AbsLine

func AbsLine(cont *fyne.Container, x1, y1, x2, y2 int, size float32, color color.RGBA)

AbsLine draws a line within a container

func AbsRect

func AbsRect(cont *fyne.Container, x, y, w, h int, color color.RGBA)

AbsRect makes a rectangle centered at x,y within a container

func AbsStart

func AbsStart(name string, w, h int) (fyne.Window, *fyne.Container)

AbsStart initiates the canvas

func AbsText

func AbsText(cont *fyne.Container, x, y int, s string, size int, color color.RGBA)

AbsText places text within a container

func AbsTextEnd

func AbsTextEnd(cont *fyne.Container, x, y int, s string, size int, color color.RGBA)

AbsTextEnd end-aligns text within a container

func AbsTextMid

func AbsTextMid(cont *fyne.Container, x, y int, s string, size int, color color.RGBA)

AbsTextMid centers text within a container

func ColorLookup

func ColorLookup(s string) color.RGBA

ColorLookup returns a color.RGBA corresponding to the named color or "rgb(r)", "rgb(r,b)", "rgb(r,g,b), "rgb(r,g,b,a)", "#rr", "#rrgg", "#rrggbb", "#rrggbbaa" string. On error, return black

func MapRange

func MapRange(value, low1, high1, low2, high2 float64) float64

MapRange -- given a value between low1 and high1, return the corresponding value between low2 and high2

func Polar

func Polar(x, y, r, angle float64) (float64, float64)

Polar returns the euclidian corrdinates from polar coordinates

func PolarRadians

func PolarRadians(x, y, r, angle float64) (float64, float64)

PolarRadians returns the euclidian corrdinates from polar coordinates

func Radians

func Radians(deg float64) float64

Radians converts degrees to radians

Types

type Canvas

type Canvas struct {
	Window    fyne.Window
	Container *fyne.Container
	Width     float64
	Height    float64
}

Canvas is where objects are drawn into

func NewCanvas

func NewCanvas(name string, w, h int) Canvas

NewCanvas makes a new canvas

func (*Canvas) ArcLine

func (c *Canvas) ArcLine(x, y, r, a1, a2, size float64, color color.RGBA)

ArcLine makes a stroked arc centered at (x, y), with radius r

func (*Canvas) CText

func (c *Canvas) CText(x, y float64, size float64, s string, color color.RGBA)

CText places centered text using percent coordinates

func (*Canvas) Circle

func (c *Canvas) Circle(x, y, r float64, color color.RGBA)

Circle places a circle within a container, using percent coordinates

func (*Canvas) CornerRect

func (c *Canvas) CornerRect(x, y, w, h float64, color color.RGBA)

CornerRect places a rectangle with upper left corner on (x,y) within a container, using percent coordinates

func (*Canvas) EText

func (c *Canvas) EText(x, y float64, size float64, s string, color color.RGBA)

EText places end-aligned text within a container, using percent coordinates

func (*Canvas) EndRun

func (c *Canvas) EndRun()

EndRun shows the content and runs the app

func (*Canvas) Image

func (c *Canvas) Image(x, y float64, w, h int, name string)

Image places an image centered at (x, y) within a container, using percent coordinates

func (*Canvas) Line

func (c *Canvas) Line(x1, y1, x2, y2, size float64, color color.RGBA)

Line places a line within a container, using percent coordinates

func (*Canvas) Rect

func (c *Canvas) Rect(x, y, w, h float64, color color.RGBA)

Rect places a rectangle centered on (x,y) within a container, using percent coordinates

func (*Canvas) Text

func (c *Canvas) Text(x, y float64, size float64, s string, color color.RGBA)

Text places text within a container, using percent coordinates

func (*Canvas) TextWidth

func (c *Canvas) TextWidth(s string, size float64) float64

TextWidth returns the width of a string

Directories

Path Synopsis
Package chart makes charts using the fync canvas package
Package chart makes charts using the fync canvas package
fchart
fchart -- command line chart using fc chart packages
fchart -- command line chart using fc chart packages
cmd
aconcentric
concentric gray scale circles
concentric gray scale circles
aconfetti
confetti -- random shapes
confetti -- random shapes
aeclipse
eclipse illustrates the eclipse
eclipse illustrates the eclipse
amondrian
mondrian makes Composition II with Red Blue and Yellow by Piet Mondrian
mondrian makes Composition II with Red Blue and Yellow by Piet Mondrian
arc
arl
mondrian makes Composition II with Red Blue and Yellow by Piet Mondrian
mondrian makes Composition II with Red Blue and Yellow by Piet Mondrian
concentric
concentric gray scale circles
concentric gray scale circles
confetti
confetti -- random shapes
confetti -- random shapes
eclipse
eclipse illustrates the eclipse
eclipse illustrates the eclipse
elections
elections: show election results on a state grid
elections: show election results on a state grid
mondrian
mondrian makes Composition II with Red Blue and Yellow by Piet Mondrian
mondrian makes Composition II with Red Blue and Yellow by Piet Mondrian
rl
rl makes random gray scale lines
rl makes random gray scale lines

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL