123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- package mvg
- import "image/color"
- import "github.com/hajimehoshi/ebiten/v2"
- type Color color.RGBA
- func (c Color) Eval(gc *GraphicContext) Value {
- return c
- }
- type Compliance int
- const ComplianceSVG = Compliance(1)
- const ComplianceMVG = Compliance(2)
- type Stroke int
- const StrokeNone = 0
- const StrokeSolid = 1
- type FillRule = ebiten.FillRule
- const FillRuleAll = FillRule(0)
- const FillRuleEvenOdd = FillRule(1)
- type GradientUnits int
- const (
- GradientUnitUserSpace = GradientUnits(iota)
- GradientUnitUserSpaceOnUse = GradientUnits(iota)
- GradientUnitObjectBoundingBox = GradientUnits(iota)
- )
- func (LinearGradient) IsDef() {
- }
- type Encoding int
- // only utf-8 is supported for now.
- const EncodingUtf8 = Encoding(0)
- type Box struct {
- X, Y, W, H float32
- }
- type Coord struct {
- X, Y float32
- }
- type GraphicContext struct {
- Parent *GraphicContext
- Children []*GraphicContext
- Variables map[string]Value
- Name string
- Compliance
- Fill Color
- FillOpacity float32
- Stroke
- StrokeWidth float32
- FillRule
- Encoding
- ViewBox Box
- Affine ebiten.GeoM
- Defs map[string]DefValue
- FontSize float32
- FontStyle string
- FontWeight string
- FontFamily string
- }
- type Def interface {
- IsDef()
- }
- type DefValue struct {
- Def
- }
- func (d DefValue) Eval(gc *GraphicContext) Value {
- return d
- }
- type Stop []struct {
- Name string
- Index int
- Color Color
- }
- type CommonGradient struct {
- Name string
- Stops []Stop
- GradientUnits
- Affine ebiten.GeoM
- }
- func (CommonGradient) IsDef() {
- }
- type LinearGradient struct {
- From Coord
- To Coord
- CommonGradient
- }
- type RadialGradient struct {
- CommonGradient
- Center Coord
- Focus Coord
- Radius float32
- }
- /*
- push graphic-context "svg5"
- compliance "SVG"
- fill "black"
- fill-opacity 1
- stroke "none"
- stroke-width 1
- stroke-opacity 1
- fill-rule nonzero
- encoding "UTF-8"
- viewbox 0 0 794 1123
- affine 3.78095 0 0 3.78114 0 0
- push defs
- push gradient "linearGradient5432" linear 0,0 0,0
- stop-color "#ffff00" 0
- stop-color "#ffff00" 1
- pop gradient
- push gradient "linearGradient5344" linear 0,0 0,0
- stop-color "#0000ff" 0
- stop-color "#0000ff" 1
- pop gradient
- push gradient "linearGradient5346" linear 89.1931,92.1651 177.979,92.1651
- gradient-units "userSpaceOnUse"
- pop gradient
- push gradient "radialGradient5434" radial 70.2149,52.3642 70.2149,52.3642 39.4705
- affine 1 0 0 0.954439 0 2.38575
- gradient-units "userSpaceOnUse"
- pop gradient
- pop defs
- push graphic-context "layer1"
- push graphic-context "path49"
- fill "url(#radialGradient5434)"
- stroke-width 0.264583
- fill-opacity "1"
- class "ellipse"
- ellipse 70.2149,52.3642 39.4705,37.6722 0,360
- pop graphic-context
- push graphic-context "text1574"
- class "text"
- translate 59.1728,104.719
- font-size 10.5833
- font-style "normal"
- font-weight "normal"
- font-size 10.5833
- font-family "sans-serif"
- fill "#000000"
- fill-opacity "1"
- stroke "none"
- stroke-width 0.264583
- text 0,0 " "
- push graphic-context "tspan1576"
- stroke-width 0.264583
- class "tspan"
- text 0,0 "hello"
- pop graphic-context
- pop graphic-context
- push graphic-context "rect4440"
- fill "url(#linearGradient5346)"
- stroke-width 0.264583
- fill-opacity "1"
- class "rect"
- rectangle 89.1931,51.9326 177.979,132.398
- pop graphic-context
- push graphic-context "rect5458"
- fill "#0000ff"
- stroke-width 0.264583
- class "rect"
- rectangle 31.8962,133.123 68.7693,155.595
- pop graphic-context
- pop graphic-context
- pop graphic-context
- */
|