Documentation ¶
Overview ¶
onthefly can generate TinySVG, HTML and CSS on the fly
Index ¶
- Constants
- func AddBodyStyle(page *Page, bgimageurl string, stretchBackground bool)
- func AddGoogleFonts(page *Page, googleFonts []string)
- func AddHeader(page *Page, js string)
- func AddScriptToHeader(page *Page, js string) error
- func Alert(msg string) string
- func DocumentReadyJS(source string) string
- func Focus(tagname string) string
- func Hide(tagname string) string
- func HideAnimated(tagname string) string
- func HideIfNot(booleanURL, tagname string) string
- func JS(source string) string
- func Load(tagname, url string) string
- func NewThreeJS(args ...string) (*Page, *Tag)
- func NewThreeJSWithGiven(titleText, js string) (*Page, *Tag)
- func OnClick(tagname, source string) string
- func OnDocumentReady(source string) string
- func Redirect(URL string) string
- func SampleSVG1() []byte
- func SampleSVG2() []byte
- func SampleStar(svg *tinysvg.Tag) error
- func ScrollDownAnimated() string
- func SetHTML(tagname, html string) string
- func SetPixelPosition(tag *Tag, xpx, ypx int)
- func SetRawValue(tagname, val string) string
- func SetRelativePosition(tag *Tag, x, y string)
- func SetText(tagname, text string) string
- func SetValue(tagname, val string) string
- func SetWidthAndSide(tag *Tag, width string, leftSide bool)
- func Show(tagname string) string
- func ShowAnimated(tagname string) string
- func ShowAnimatedIf(booleanURL, tagname string) string
- func ShowInline(tagname string) string
- func ShowInlineAnimated(tagname string) string
- func ShowInlineAnimatedIf(booleanURL, tagname string) string
- func StandaloneTag(tagname string) (*Page, *Tag)
- func TagString(tagname string) string
- type Element
- type Geometry
- type Material
- type Mesh
- type Page
- func (page *Page) AddContent(content string) (*Tag, error)
- func (page *Page) AddScriptToBody(js string) (*Tag, error)
- func (page *Page) AddScriptToHead(js string) (*Tag, error)
- func (page *Page) AddStyle(s string) (*Tag, error)
- func (page *Page) FullCanvas()
- func (page *Page) GetCSS() string
- func (page *Page) GetHTML() string
- func (page *Page) GetRoot() *Tag
- func (page *Page) GetTag(name string) (*Tag, error)
- func (page *Page) GetXML(indent bool) string
- func (page *Page) LinkToCSS(cssurl string) error
- func (page *Page) LinkToFavicon(favurl string) error
- func (page *Page) LinkToGoogleFont(name string) error
- func (page *Page) LinkToJS(jsURL string) error
- func (page *Page) LinkToJSInBody(jsURL string) (*Tag, error)
- func (page *Page) LinkToJSInHead(jsURL string) (*Tag, error)
- func (page *Page) MetaCharset(charset string) error
- func (page *Page) NoScrollbars() (*Tag, error)
- func (page *Page) Publish(mux *http.ServeMux, htmlurl, cssurl string, refresh bool)
- func (page *Page) SaveSVG(filename string) error
- func (page *Page) SetColor(fgColor string, bgColor string) (*Tag, error)
- func (page *Page) SetFontFamily(fontFamily string) (*Tag, error)
- func (page *Page) SetMargin(em int) (*Tag, error)
- func (page *Page) SetMarginAndBackgroundImage(imageURL string, stretchBackground bool)
- func (page *Page) String() string
- type RenderFunc
- type SimpleWebHandle
- type Tag
- func (tag *Tag) AddAttrib(attrName, attrValue string)
- func (tag *Tag) AddBox(id string, rounded bool, em, text, fgColor, bgColor, leftPadding string) *Tag
- func (three *Tag) AddCamera()
- func (tag *Tag) AddChild(child *Tag)
- func (tag *Tag) AddContent(content string)
- func (tag *Tag) AddImage(url string, width string) *Tag
- func (tag *Tag) AddLastContent(content string)
- func (tag *Tag) AddNewTag(name string) *Tag
- func (three *Tag) AddRenderFunction(r *RenderFunc, call bool)
- func (three *Tag) AddRenderer()
- func (tag *Tag) AddSingularAttrib(attrName string)
- func (tag *Tag) AddStyle(styleName, styleValue string)
- func (tag *Tag) AddTag(child *Tag)
- func (three *Tag) AddTestCube() *Mesh
- func (three *Tag) AddToScene(mesh *Mesh)
- func (tag *Tag) AppendContent(content string)
- func (three *Tag) CameraPos(axis string, value int)
- func (tag *Tag) CountChildren() int
- func (tag *Tag) CountSiblings() int
- func (tag *Tag) CustomSansSerif(custom string)
- func (tag *Tag) GetAttrString() string
- func (tag *Tag) GetCSS() (ret string)
- func (tag *Tag) GetChildren() []*Tag
- func (tag *Tag) GetTag(name string) (*Tag, error)
- func (tag *Tag) LastChild() *Tag
- func (tag *Tag) RepeatBackground(bgimageurl, repeat string)
- func (tag *Tag) RoundedBox()
- func (tag *Tag) SansSerif()
- func (tag *Tag) SetColor(fgColor, bgColor string)
- func (tag *Tag) SetMargin(em int)
- func (tag *Tag) SetRounded(value string)
- func (tag *Tag) SetRoundedEm(em int)
- func (tag *Tag) String() string
- type TemplateValues
Constants ¶
const (
Version = 1.2
)
Variables ¶
This section is empty.
Functions ¶
func AddBodyStyle ¶
AddBodyStyle styles the given page with a background image to the given page. Deprecated, use SetMarginAndBackgroundImage and also SansSerif instead.
func AddGoogleFonts ¶
AddGoogleFonts links to a given Google Font name
func AddScriptToHeader ¶
Add JavaScript code in a script tag in the head tag Deprecated, use AddScriptToHead instead.
func Alert ¶
Alert returns JavaScript code that displays a pretty intruding message box. The "msg" will be quoted.
func DocumentReadyJS ¶
Returns HTML that will run the given JavaScript code once the document is ready. Returns an empty string if there is no JavaScript code to run.
func HideAnimated ¶
HideAnimated returns JavaScript code that hides the given tag name in an animated way
func NewThreeJS ¶
Create a HTML5 page that links with Three.JS and sets up a scene
func NewThreeJSWithGiven ¶
Create a HTML5 page that includes the given JavaScript code at the end of the <body> tag, before </body>. The given JS code must be the contents of the http://threejs.org/build/three.min.js script for this to work.
func OnClick ¶
OnClick returns JavaScript code that runs the given JavaScript code when the given tag name is clicked on
func OnDocumentReady ¶
OnDocumentReady returns JavaScript code the runs the given JavaScript code when the HTML document is ready in the browser.
func SampleStar ¶
SampleStar draws a star at the given position
func ScrollDownAnimated ¶
func ScrollDownAnimated() string
ScrollDownAnimated returns JavaScript code that will slowly scroll the page down
func SetPixelPosition ¶
SetPixelPosition sets the absolute CSS position of a HTML tag
func SetRawValue ¶
SetRawValue returns JavaScript code that sets the contents of a given tag name, without quoting
func SetRelativePosition ¶
SetRelativePosition sets the relative CSS position of a HTML tag
func SetValue ¶
SetValue returns JavaScript code that quotes and then sets the contents of the given tag name
func SetWidthAndSide ¶
SetWidthAndSide sets the "width" and also "float: left" or "float: right"
func ShowAnimated ¶
ShowAnimated returns JavaScript code that displays the given tag name in an animated way
func ShowAnimatedIf ¶
ShowAnimatedIf returns JavaScript that will show a tag if booleanURL returns "1"
func ShowInline ¶
ShowInline returns JavaScript code that styles the given tag with "display:inline"
func ShowInlineAnimated ¶
ShowInlineAnimated returns JavaScript code that show the given tag with "display:inline", then hides it and then shows it in an animated way
func ShowInlineAnimatedIf ¶
ShowInlineAnimatedIf returns JavaScript that shows the given tag in an animated way if the value from the given URL is "1"
func StandaloneTag ¶
StandaloneTag creates an empty page the only contains a tag with the given name. Returns both the Page and the Tag.
Types ¶
type Element ¶
type Element struct { ID string // name of the variable JS string // javascript code for creating the element }
For Three.JS elements, like a mesh or material
type Material ¶
type Material Element
func NewNormalMaterial ¶
func NewNormalMaterial() *Material
Create a material which reflects the normals of the geometry
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
func NewAngularPage ¶
Create a blank HTML5 page that links with Angular.JS
func NewPage ¶
NewPage creates a new XML/HTML/SVG page, with a root tag. If rootTagName contains "<" or ">", it can be used for preceding declarations, like <!DOCTYPE html> or <?xml version=\"1.0\"?>. Returns a pointer to a Page.
func (*Page) AddContent ¶
AddContent adds content to the body tag. Returns the body tag and nil if successful. Returns and an error if no body tag is found, else nil.
func (*Page) AddScriptToBody ¶
Add javascript code in a script tag at the end of the body tag
func (*Page) AddScriptToHead ¶
Add javascript code in a script tag in the head tag
func (*Page) FullCanvas ¶
func (page *Page) FullCanvas()
Prepare for a canvas/webgl tag that covers the entire page
func (*Page) LinkToCSS ¶
Link a page up with a CSS file Takes the url to a CSS file as a string The given page must have a "head" tag for this to work Returns an error if no "head" tag is found, or nil
func (*Page) LinkToFavicon ¶
Link a page up with a Favicon file Takes the url to a favicon file as a string The given page must have a "head" tag for this to work Returns an error if no "head" tag is found, or nil
func (*Page) LinkToGoogleFont ¶
Link to Google Fonts
func (*Page) LinkToJS ¶
Link a page up with a JS file Takes the url to a JS file as a string The given page must have a "head" tag for this to work Returns an error if no "head" tag is found, or nil
func (*Page) LinkToJSInBody ¶
Link to JavaScript, at the end of the body
func (*Page) LinkToJSInHead ¶
Link to JavaScript in the head
func (*Page) MetaCharset ¶
Takes a charset, for example UTF-8, and creates a <meta> tag in <head>
func (*Page) NoScrollbars ¶
Disable scrollbars. Needed when using "<!doctype html>" together with fullscreen canvas/webgl
func (*Page) Publish ¶
Publish the linked HTML and CSS for a Page. If refresh is true, the contents are generated every time. If refresh is false, the contents are cached.
func (*Page) SetFontFamily ¶
Set the font family
func (*Page) SetMarginAndBackgroundImage ¶
SetMarginAndBackgroundImage sets a small margin of 1em and a given background image
type RenderFunc ¶
type RenderFunc struct {
// contains filtered or unexported fields
}
The Three.JS render function, where head and tail are standard
func NewRenderFunction ¶
func NewRenderFunction() *RenderFunc
Create a new render function, which is called at every animation frame
func (*RenderFunc) AddJS ¶
func (r *RenderFunc) AddJS(s string)
Add javascript code to the body of a render function
type SimpleWebHandle ¶
Various function signatures for handling requests
type Tag ¶
type Tag struct {
// contains filtered or unexported fields
}
func NewTag ¶
NewTag creates a new tag based on the given name. "name" is what will appear right after "<" when rendering as XML/HTML/SVG.
func (*Tag) AddBox ¶
func (tag *Tag) AddBox(id string, rounded bool, em, text, fgColor, bgColor, leftPadding string) *Tag
AddBox adds a <div> box
func (*Tag) AddContent ¶
AddContent adds text to a tag. This is what will appear between two tag markers, for example: <tag>content</tag> If the tag contains child tags, they will be rendered after this content.
func (*Tag) AddLastContent ¶
AddLastContent appends content to the end of the exising content of a tag. Deprecated.
func (*Tag) AddNewTag ¶
AddNewTag adds a new tag to another tag. This will place it one step lower in the hierarchy of tags. You can for example add a body tag to an html tag.
func (*Tag) AddRenderFunction ¶
func (three *Tag) AddRenderFunction(r *RenderFunc, call bool)
Add a render function. If call is true, the render function is called at the end of the script.
func (*Tag) AddRenderer ¶
func (three *Tag) AddRenderer()
Add a WebGL renderer with default settings
func (*Tag) AddSingularAttrib ¶
AddSingularAttrib adds attribute without a value
func (*Tag) AppendContent ¶
AppendContent appends content to the end of the exising content of a tag
func (*Tag) CountChildren ¶
CountChildren returns the number of children a tag has
func (*Tag) CountSiblings ¶
CountSiblings returns the number of siblings a tag has
func (*Tag) CustomSansSerif ¶
CustomSansSerif styles the tag with some sort of sans-serif font, where a custom font can be given and put first in the list of fonts.
func (*Tag) GetAttrString ¶
GetAttrString returns a string that represents all the attribute keys and values of a tag. This can be used when generating XML, SVG or HTML.
func (*Tag) GetChildren ¶
GetChildren returns all children for a given tag. Returns a slice of pointers to tags.
func (*Tag) GetTag ¶
GetTag finds a tag by name and returns an error if not found. Returns the first tag that matches.
func (*Tag) RepeatBackground ¶
Repeat the background. repeat can be for instance "repeat-x"
func (*Tag) RoundedBox ¶
func (tag *Tag) RoundedBox()
RoundedBox styles the tag as a box with a rounded border
func (*Tag) SansSerif ¶
func (tag *Tag) SansSerif()
SansSerif styles the tag with some sort of sans-serif font
func (*Tag) SetRounded ¶
SetRounded applies rounded corners to an HTML tag
func (*Tag) SetRoundedEm ¶
SetRoundedEm applies rounded corners to an HTML tag em is the roundedness, given as "em"