In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Introduction:
In the agg/examples directory, many examples are provided with scroll bars, and through the scroll bar, you can dynamically see the image color gradient process. So click agg::slider_ctrl utility class.
Graphics:
/*
*(x2,y2)
* *
* *
* *
* *
* *
* *
* *
(x1,y1)**************************************(x2,y1)
*/
Function:
constructor: slider_ctrl(double x1, double y1, double lex 2, double y2, bool flip_y=false)
m_slider1.range(1, 100);//Set the value range of the scroll bar
m_slider1.num_steps(10);//Set the step width of the scroll bar,
m_slider1.value(1.0);//Set initial value
m_slider1.label("Pixel size=%1.0f");//Displays the value of the current scroll bar
m_slider1.no_transform();//scaling is not allowed
int nScaleX =m_slider1.value();//Get current value
1) Add header file
#include "agg/include/ctrl/agg_slider_ctrl.h"
2) Definition:
agg::slider_ctrl m_slider1;
3) Add to Event Response List
Added to windows platform example:
add_ctrl(m_slider1);
/*
Add the control element to the event listening list through the above function. When an event occurs on the mouse or keyboard,
, will be passed to the control, and the control will determine whether it is its own event (whether it is sliding the scroll bar).
By commenting on this function, the author can appreciate that sliding the progress bar does not reflect anything.
*/
4) Rendering controls
agg::render_ctrl(ras, sl, renb, m_slider1);
5) Because the code is placed on_draw, it needs to be forcibly refreshed.
force_redraw();
Simple examples of applications are as follows:
#include "agg/include/agg_basics.h"
#include "agg/include/agg_conv_curve.h"
#include "agg/include/agg_trans_perspective.h"
#include "agg/include/agg_renderer_scanline.h"
#include "agg/include/agg_rendering_buffer.h"
#include "agg/include/agg_rasterizer_scanline_aa.h"
#include "agg/include/agg_scanline_u.h"
#include "agg/include/agg_pixfmt_rgb.h"
#include "agg/include/platform/agg_platform_support.h"
#include "agg/include/agg_ellipse.h"
#include "agg/include/agg_conv_contour.h"
#include "agg/include/agg_conv_stroke.h"
#include "agg/include/agg_renderer_base.h"
#include "agg/include/agg_path_storage.h"
#include "agg/include/ctrl/agg_slider_ctrl.h"
class the_application:public agg::platform_support
{
public:
the_application(agg::pix_format_e format, bool flip_y):agg::platform_support(format,flip_y),pix_fmt(rbuf_window()),ren_bas(pix_fmt),
m_slider1(80, 250, 600-10, 276, ! flip_y),
{
add_ctrl(m_slider1);
m_slider1.range(1.0, 100.0);
m_slider1.num_steps(10);
m_slider1.value(1.0);
m_slider1.label("Pixel size=%1.0f");
m_slider1.no_transform();
}
void draw_ellipse()
{
//Rendering Buffer The rendered memory block is the color memory block that will display the interface, where agg::rendering_buffer
//class provides a series of functions that directly manipulate the color of a coordinate point, such as row_ptr();
agg::rendering_buffer &rbuf = rbuf_window();
agg::pixfmt_bgr24 pixf(rbuf);
agg::rgba8 color(255,0,0);
agg::rgba c(344,1);
//Renderers Renderers, we can think of as paint, paint,
typedef agg::renderer_base renderer_base_type;
renderer_base_type renb(pixf);
//Scanline Rasterizer rasterizes, says she's a picture book, describes all the patterns, colors, lines we're going to paint
//But not exactly, because it is just a container, a specification that describes the line segment, logo, detailed parameters,
//It's not even a sketch, it's more like a recipe, it records the ingredients, it records the cooking process, that's all.
agg::rasterizer_scanline_aa ras;
agg::scanline_u8 sl;
ren_bas.clear(agg::rgba8(255,255,255));
int nScaleX = 0;
int nScaleY = 0;
agg::path_storage ps;
ps.move_to(300,300);
ps.line_to(320,300);
ps.line_to(320,320);
ps.line_to(300,320);
ps.line_to(300,300);
nScaleX = int(m_slider1.value())/10;
nScaleY = int(m_slider2.value())/10;
agg::trans_affine mtx;
mtx.scale(nScaleX,nScaleY); //x-axis reduced to half
// mtx.rotate(agg::deg2rad(40));//rotate 30 degrees
mtx.translate(-320*(nScaleX-1) ,-320 *(nScaleY-1));//X, Y coordinates translate 100 respectively
typedef agg::conv_transform ell_ct_type;
ell_ct_type ctell(ps,mtx); //matrix transform
typedef agg::conv_stroke ell_cc_cs_type;
ell_cc_cs_type csccell(ctell);
ras.add_path(csccell);
agg::render_scanlines_aa_solid(ras,sl,renb,agg::rgba8(255,0,0));
ras.reset();
// Render the controls
agg::render_ctrl(ras, sl, renb, m_slider1);
return;
}
virtual void on_draw()
{
draw_ellipse();
}
virtual void on_mouse_button_down(int x, int y, unsigned flags)
{
if (flags == agg::mouse_left)
{
char str[50];
sprintf(str,"Mouse location:(%d,%d)", x, y);
message(str);
}
}
private:
agg::slider_ctrl m_slider1;
agg::pixfmt_rgb24 pix_fmt;
agg::renderer_base ren_bas;
};
int agg_main(int argc, char* argv[])
{
the_application app(agg::pix_format_bgr24,false);
app.caption("AGG Example.Anti_Aliasing Demo");
if (app.init(1800, 1800, agg::window_resize))
{
return app.run();
}
return -1;
}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.