Code Library

Shapes & Gradients

· By Media La Vista

SVG primitive shapes and gradient fills. Animations, effects and frames cannot be applied to a shape directly: add the shape to a group, e.g. $.g().add($.circle(params)), and apply them to the group.

Shape Constructors

ConstructorKey Attributes
$.rect()x, y, width, height, rx, ry
$.circle()cx, cy, r
$.ellipse()cx, cy, rx, ry
$.line()x1, y1, x2, y2 (stroke only, never filled)
$.path()d (SVG path data)
$.polyline()points
$.polygon()points
$.solidColor(color, opacity)Color element to reference in fill or stroke
new $.pathData()Builds the d value for $.path(): .moveTo(), .lineTo(), .curveTo(), .arcTo(), .close()

Common: fill, fillOpacity, stroke, strokeWidth, strokeOpacity

Rounded Rectangle

$.rect({ x: 200, y: 100, width: 600, height: 400,
         rx: 20, ry: 20, fill: 'green'}).addTo('svg');

Gradients

Linear Gradient

$(function() {
  var gr = $.linearGradient({
    x1: 0, y1: 0, x2: 1280, y2: 0,
    stops: [{ offset: 0, color: 'blue'}, { offset: 1, color: 'red'}]
  }).addTo('svg');
  $.rect({ x: 0, y: 0, width: 1280, height: 720, fill: gr.ref() }).addTo('svg');
});

Radial Gradient

$(function() {
  var gr = $.radialGradient({
    cx: 640, cy: 360, r: 300,
    stops: [{ offset: 0, color: 'white'}, { offset: 1, color: 'blue'}]
  }).addTo('svg');
  $.circle({ cx: 640, cy: 360, r: 300, fill: gr.ref() }).addTo('svg');
});

Related Pages

SpinetiX Wiki Reference
SVG shapes (rect, circle, ellipse, line, path, polygon) and linear/radial gradients.

Need Help With Your Project?

Media La Vista provides Tier 1–3 local support across the Middle East. 10-minute response for Partner Club members.

This page is available in English only
هذه الصفحة متوفرة باللغة الإنجليزية فقط
NS
Media La Vista support
Typically replies natively
مرحباً بكم في دعم SpinetiX عبر واتساب

كيف يمكنني مساعدتكم في حلول اللوحات الرقمية، أو البنية التحتية AV/IT، أو منتجات SpinetiX؟
Hello and welcome to SpinetiX Support on WhatsApp.

How can I help you with digital signage solutions, AV/IT infrastructure, or SpinetiX products?