Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polar chart (in progress) #106

Open
wants to merge 79 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
061b343
Add a list of built-in colors
areebg9 Jan 18, 2020
8aefb3d
Create PolarChart.swift
areebg9 Jan 19, 2020
9576045
Delete PolarChart.swift
areebg9 Jan 19, 2020
dfcd57f
Update README.md
areebg9 Jan 19, 2020
64e5084
Update README.md
areebg9 Jan 19, 2020
1bc8502
Create PolarChart.swift
areebg9 Jan 19, 2020
fdf91a7
Adding .addFunction capability, small change
areebg9 Jan 19, 2020
e84d1d0
Update PolarChart.swift
areebg9 Jan 19, 2020
32224a8
Update PolarChart.swift
areebg9 Jan 19, 2020
fa3d492
Update PolarChart.swift
areebg9 Jan 19, 2020
ef016bf
Update PolarChart.swift
areebg9 Jan 19, 2020
dbee6c4
Update SVGRenderer.swift
areebg9 Jan 20, 2020
4007298
Update PolarChart.swift
areebg9 Jan 20, 2020
bfb1cc4
Update PolarChart.swift
areebg9 Jan 20, 2020
c7618ca
Update PolarChart.swift
areebg9 Jan 20, 2020
444d101
Update PolarChart.swift
areebg9 Jan 20, 2020
be423dd
Update PolarChart.swift
areebg9 Jan 20, 2020
d3eb4eb
Update Renderer.swift
areebg9 Jan 20, 2020
c367f01
Update PolarChart.swift
areebg9 Jan 20, 2020
da6fb93
Update PolarChart.swift
areebg9 Jan 20, 2020
8048cea
Update PolarChart.swift
areebg9 Jan 20, 2020
d70cb2b
Update SVGRenderer.swift
areebg9 Jan 20, 2020
3a32d79
Update SVGRenderer.swift
areebg9 Jan 20, 2020
e205f79
Update CPPAGGRenderer.cpp
areebg9 Jan 21, 2020
0cfd296
Update AGGRenderer.swift
areebg9 Jan 21, 2020
1c190b1
Update CAGGRenderer.cpp
areebg9 Jan 21, 2020
d2aff29
Update CAGGRenderer.cpp
areebg9 Jan 21, 2020
616e2fe
Update CAGGRenderer.h
areebg9 Jan 21, 2020
6922c06
Update CPPAGGRenderer.h
areebg9 Jan 21, 2020
3d3fb06
Update CPPAGGRenderer.cpp
areebg9 Jan 21, 2020
cb1aeda
Update CPPAGGRenderer.cpp
areebg9 Jan 21, 2020
45d8e03
Update CPPAGGRenderer.cpp
areebg9 Jan 21, 2020
2d56bc1
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
c759a98
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
d615012
Update PolarChart.swift
areebg9 Jan 23, 2020
eadf998
Update PolarChart.swift
areebg9 Jan 23, 2020
8911805
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
c2a63de
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
d66c900
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
98119dc
Update PolarChart.swift
areebg9 Jan 23, 2020
292a5f1
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
ad196fc
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
267e38f
Update PolarChart.swift
areebg9 Jan 23, 2020
9e181bd
Update PolarChart.swift
areebg9 Jan 23, 2020
6a0d6d1
Update CPPAGGRenderer.h
areebg9 Jan 23, 2020
be8a365
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
3eadc8d
Update CAGGRenderer.h
areebg9 Jan 23, 2020
a0fd600
Update CAGGRenderer.cpp
areebg9 Jan 23, 2020
d4d2546
Update AGGRenderer.swift
areebg9 Jan 23, 2020
1d22cd4
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
8225643
Update Renderer.swift
areebg9 Jan 23, 2020
a53a52f
Update PolarChart.swift
areebg9 Jan 23, 2020
18a474b
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
92220a2
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
6a51e7b
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
7036f0f
Update PolarChart.swift
areebg9 Jan 23, 2020
36927f3
Update PolarChart.swift
areebg9 Jan 23, 2020
6883847
Update PolarChart.swift
areebg9 Jan 23, 2020
700ca7f
Update PolarChart.swift
areebg9 Jan 23, 2020
f5b55e2
Update PolarChart.swift
areebg9 Jan 23, 2020
7dadb24
Update CPPAGGRenderer.cpp
areebg9 Jan 23, 2020
b4cf273
Update SVGRenderer.swift
areebg9 Jan 23, 2020
00661e3
Update SVGRenderer.swift
areebg9 Jan 23, 2020
cf3eb45
Update SVGRenderer.swift
areebg9 Jan 24, 2020
dd0c0ff
Update SVGRenderer.swift
areebg9 Jan 24, 2020
7a5a7e2
Update SVGRenderer.swift
areebg9 Jan 24, 2020
656065d
Update SVGRenderer.swift
areebg9 Jan 24, 2020
6e39440
Update PolarChart.swift
areebg9 Jan 24, 2020
82c65f4
Update PolarChart.swift
areebg9 Jan 24, 2020
f3154d3
Update CPPAGGRenderer.cpp
areebg9 Feb 19, 2020
27168c4
Update CPPAGGRenderer.cpp
areebg9 Feb 19, 2020
94b83be
Update GraphLayout.swift
areebg9 Feb 21, 2020
74838d1
Update CPPAGGRenderer.cpp
areebg9 Feb 21, 2020
5ded194
add transparent color
areebg9 Feb 21, 2020
977a609
Update PolarChart.swift
areebg9 Mar 2, 2020
7852a2a
Update PolarChart.swift
areebg9 Mar 2, 2020
dacbe11
Update PolarChart.swift
areebg9 Mar 2, 2020
fdd752a
Update PolarChart.swift
areebg9 Mar 2, 2020
1e87449
Update agg_blur.h
areebg9 Apr 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ In order to display the plots in Jupyter notebook, we encode the image(which is
|---------------------------------------------------|
|cgColor: CGColor (return the corresponding CGColor)|

Built-in Colors can be found [here](https://github.com/KarthikRIyer/swiftplot/blob/master/Sources/SwiftPlot/Color.swift).


### PlotLabel

Expand Down
4 changes: 2 additions & 2 deletions Sources/AGG/include/agg_blur.h
Original file line number Diff line number Diff line change
Expand Up @@ -1487,13 +1487,13 @@ namespace agg
}

template<class PixFmt>
void apply_slight_blur(renderer_base<PixFmt>& img, const rect_i& bounds, double r = 1)
void apply_slight_blur(blender_base<PixFmt>& img, const rect_i& bounds, double r = 1)
{
if (r > 0) slight_blur<PixFmt>(r).blur(img.ren(), bounds);
}

template<class PixFmt>
void apply_slight_blur(renderer_base<PixFmt>& img, double r = 1)
void apply_slight_blur(blender_base<PixFmt>& img, double r = 1)
{
if (r > 0) slight_blur<PixFmt>(r).blur(img.ren(), img.clip_box());
}
Expand Down
10 changes: 10 additions & 0 deletions Sources/AGGRenderer/AGGRenderer/AGGRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ public class AGGRenderer: Renderer{
fillColor.a,
agg_object)
}

public func drawEmptyCircle(center c: Point,
radius rx: Float,
radius2 ry: Float) {
draw_empty_circle(c.x + xOffset,
c.y + yOffset,
rx,
ry,
agg_object)
}

public func drawSolidTriangle(point1: Point,
point2: Point,
Expand Down
4 changes: 4 additions & 0 deletions Sources/AGGRenderer/CAGGRenderer/CAGGRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ void draw_solid_circle(float cx, float cy, float radius, float r, float g, float
CPPAGGRenderer::draw_solid_circle(cx, cy, radius, r, g, b, a, object);
}

void draw_empty_circle(float cx, float cy, float rx, float ry, const void *object){
CPPAGGRenderer::draw_empty_circle(cx, cy, rx, ry, object);
}

void draw_solid_triangle(float x1, float x2, float x3, float y1, float y2, float y3, float r, float g, float b, float a, const void *object){
CPPAGGRenderer::draw_solid_triangle(x1, x2, x3, y1, y2, y3, r, g, b, a, object);
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/AGGRenderer/CAGGRenderer/include/CAGGRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ void draw_rect(const float *x, const float *y, float thickness, float r, float g
void draw_solid_rect(const float *x, const float *y, float r, float g, float b, float a, int hatch_pattern, const void *object);

void draw_solid_circle(float cx, float cy, float radius, float r, float g, float b, float a, const void *object);

void draw_empty_circle(float cx, float cy, float rx, float ry, const void *object);

void draw_solid_triangle(float x1, float x2, float x3, float y1, float y2, float y3, float r, float g, float b, float a, const void *object);

Expand Down
25 changes: 24 additions & 1 deletion Sources/AGGRenderer/CPPAGGRenderer/CPPAGGRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ typedef agg::rgba Color;
const Color black(0.0,0.0,0.0,1.0);
const Color blue_light(0.529,0.808,0.922,1.0);
const Color white(1.0,1.0,1.0,1.0);
const Color white_translucent(1.0,1.0,1.0,0.8);
const Color gray_translucent(0.66,0.66,0.66,0.2);
const Color transparent(1.0, 1.0, 1.0, 0.0);

namespace CPPAGGRenderer{

Expand Down Expand Up @@ -293,6 +294,23 @@ namespace CPPAGGRenderer{
ren_aa.color(c);
agg::render_scanlines(m_ras, m_sl_p8, ren_aa);
}

void draw_empty_circle(float cx, float cy, float rx, float ry) {
agg::rendering_buffer rbuf = agg::rendering_buffer(buffer, frame_width, frame_height, -frame_width*3);
pixfmt pixf = pixfmt(rbuf);
renderer_base rb = renderer_base(pixf);
ren_aa = renderer_aa(rb);
agg::ellipse circle(cx, cy, rx, ry, 100);
agg::trans_affine matrix;
matrix *= agg::trans_affine_translation(0, 0);
agg::conv_transform<agg::ellipse, agg::trans_affine> trans(circle, matrix);
agg::conv_curve<agg::conv_transform<agg::ellipse, agg::trans_affine>> curve(trans);
agg::conv_stroke<agg::conv_curve<agg::conv_transform<agg::ellipse, agg::trans_affine>>> stroke(curve);
stroke.width(1);
m_ras.add_path(stroke);
ren_aa.color(gray_translucent);
agg::render_scanlines(m_ras, m_sl_p8, ren_aa);
}

void draw_solid_triangle(float x1, float x2, float x3, float y1, float y2, float y3, float r, float g, float b, float a) {
agg::rendering_buffer rbuf = agg::rendering_buffer(buffer, frame_width, frame_height, -frame_width*3);
Expand Down Expand Up @@ -503,6 +521,11 @@ namespace CPPAGGRenderer{
Plot *plot = (Plot *)object;
plot -> draw_solid_circle(cx, cy, radius, r, g, b, a);
}

void draw_empty_circle(float cx, float cy, float rx, float ry, const void *object){
Plot *plot = (Plot *)object;
plot -> draw_empty_circle(cx, cy, rx, ry);
}

void draw_solid_triangle(float x1, float x2, float x3, float y1, float y2, float y3, float r, float g, float b, float a, const void *object){
Plot *plot = (Plot *)object;
Expand Down
2 changes: 2 additions & 0 deletions Sources/AGGRenderer/CPPAGGRenderer/include/CPPAGGRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace CPPAGGRenderer{
void draw_solid_rect(const float *x, const float *y, float r, float g, float b, float a, int hatch_pattern, const void *object);

void draw_solid_circle(float cx, float cy, float radius, float r, float g, float b, float a, const void *object);

void draw_empty_circle(float cx, float cy, float rx, float ry, const void *object);

void draw_solid_triangle(float x1, float x2, float x3, float y1, float y2, float y3, float r, float g, float b, float a, const void *object);

Expand Down
9 changes: 9 additions & 0 deletions Sources/SVGRenderer/SVGRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ public class SVGRenderer: Renderer{
let circle: String = #"<circle cx="\#(c.x)" cy="\#(c.y)" r="\#(r)" style="fill:\#(fillColor.svgColorString);opacity:\#(fillColor.a)" />"#
lines.append(circle)
}

public func drawEmptyCircle(center c: Point,
radius rx: Float,
radius2 ry: Float) {
let c = convertToSVGCoordinates(c)
let color = "gray"
let circle: String = #"<ellipse cx="\#(c.x)" cy="\#(c.y)" rx="\#(rx)" ry="\#(ry)" stroke="\#(color)" stroke-width="\#(0.5)" fill-opacity="\#(0.0)" />"#
lines.append(circle)
}

public func drawSolidTriangle(point1: Point,
point2: Point,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftPlot/GraphLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ extension Plot where Self: HasGraphLayout {
let tup = layoutData(size: size, renderer: renderer)
return (tup.0, tup.1, self.legendLabels)
}
layout.drawBackground(results: results, renderer: renderer)
// layout.drawBackground(results: results, renderer: renderer)
renderer.withAdditionalOffset(results.plotBorderRect.origin) { renderer in
drawData(drawingData, size: results.plotBorderRect.size, renderer: renderer)
}
Expand Down
Loading